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¶
- 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¶
- usecols = [0, 1]¶
- vzConstCOM = 0¶
- 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¶
- cmanim.reanimate()[source]¶
runs the previous animation again.
helpful after manually changing parameters
- cmanim.runCont2D(path='.', *morepaths)[source]¶
animates contact movie from interSheet frames
with stress-displacement curve if applicable.
- 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.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)