cmanim module

Animation of contMech Simulations

An easy-to-use library for animating simulation results. The focus is on fully automatic usage, where the best possible parameters are read from params.out.

Examples

Example to create and save a contact movie:

import cmanim

animation = cmanim.runCont2D()
cmanim.save(animation, "movie.gif")

Specifying custom parameters is possible by calling individual initialization functions one after the other. E.g. you can animate the cross-sections along x-direction from two different simulations in one figure, limit it to frames 40 to 100, and zoom in to a certain xrange:

cmanim.init("DispX", [path1, path2] )
cmanim.XLIM = [xmin, xmax]
cmanim.START = 40
cmanim.END = 100
cmanim.NFRAMES = 60
animation = cmanim.run()

Essentially, the previously mentioned runCont2D() is just a wrapper for cmanim.init(“Cont2D”,paths=”.”); cmanim.run(), where init(…) automatically determines plot parameters, which you can (but most of the time don’t need to) overwrite.

API documentation

cmanim.animate2D()[source]

run animation from 2D files

cmanim.animate3D()[source]

run animation from 3D files

cmanim.checkDir(path)[source]

Checks <path> directory for “frames” subfolder and “params.out”.

cmanim.dataReset()[source]

hard reset

cmanim.dumpGlobals(path)[source]

shows automatically adjusted parameters for user to check

class cmanim.gfmdSheet(newID)[source]

Bases: object

ID = 0
dTime = 0
data = array([[0.]])
dzRamp = 0
f3dMovie = 0
fKelvinVoigt = 0
fRough = 0
fSteppedRamp = 0
files = []
increment = 1
konfigName = 'konfig'
lengthX = 0
lengthY = 0
minmaxZ = []
nElast = 0
nFrames = 0
nTime = 0
nVeloTurnStep = -1
nx = 0
ny = 0
ramp = array([[0.]])
rampName = ''
rampPeriod = 0
stiffness0 = 0
updateCols()[source]

determines which columns in the data files must be imported

updateData(numFrame)[source]

reads and sets up the data file needed to plot the next frame

updateDims(path)[source]
updateFiles(path)[source]

sets up list of frame files belonging to this object

updateNxNy()[source]
usecols = [0, 1]
vzConstCOM = 0
cmanim.init(mode, paths)[source]
cmanim.initGlobals(paths)[source]

initializes global parameters

goes through all simulation directories in <paths> and tries to find optimal parameters to plot all simulations into one animation

cmanim.initParams(path)[source]

initialize params.out

reads <path>/params.out to recreate sheet and interaction setup, initializes them and checks corresponding files and data to determine optimal plot parameters.

class cmanim.interSheet(newID)[source]

Bases: object

ID = 0
attrFiles = []
contFiles = []
data = array([[0.]])
fDumpFrame = 0
fPotential = 0
increment = 1
konfigName = 'inter'
nFrames = 0
nTime = 0
nx = 0
ny = 0
resolMovie = 512
updateData(numFrame)[source]

reads and sets up the data file needed to plot the next frame

updateFiles(path)[source]

sets up list of frame files belonging to this object

cmanim.reanimate()[source]

runs the previous animation again.

helpful after manually changing parameters

cmanim.run()[source]
cmanim.runCont2D(path='.', *morepaths)[source]

animates contact movie from interSheet frames

with stress-displacement curve if applicable.

cmanim.runCont3D(path='.', *morepaths)[source]

animates contact movie from sheet configs

cmanim.runDisp3D(path='.', *morepaths)[source]

animates displacement movie from elastic sheet config

cmanim.runDispD(path='.', *morepaths)[source]

animates displacement along diagonal direction

with stress-displacement curve if applicable.

cmanim.runDispX(path='.', *morepaths)[source]

animates displacement along X direction

with stress-displacement curve if applicable.

cmanim.runDispY(path='.', *morepaths)[source]

animates displacement along Y direction

with stress-displacement curve if applicable.

cmanim.runDist3D(path='.', *morepaths)[source]

animates surface distance movie from sheet configs

cmanim.runPressD(path='.', *morepaths)[source]

animates displacement along diagonal direction

with stress-displacement curve if applicable.

cmanim.runPressX(path='.', *morepaths)[source]

animates pressure along X direction

with stress-displacement curve if applicable.

cmanim.runPressY(path='.', *morepaths)[source]

animates displacement along Y direction

with stress-displacement curve if applicable.

cmanim.save(animation, filename)[source]

save animation to file

For mp4 files, make sure ffmpg and h264 are installed correctly: conda install -c conda-forge ffmpeg conda install -c conda-forge x264=20131218

(see: https://stackoverflow.com/questions/13316397/matplotlib-animation-no-moviewriters-available) (see: https://github.com/sigsep/sigsep-mus-db/issues/14)