Making a simulation movie with a running plot: Difference between revisions
Jump to navigation
Jump to search
(Created the page.) |
m (Randisi moved page Making a simulation plot with a running plot to Making a simulation movie with a running plot) |
(No difference)
|
Revision as of 11:53, 4 November 2016
Page currently under construction
It's a cool visualisation tool to see a movie of some structure in cogli1 together with some quantity of interest relevant to the structure itself.
In order to do that, the pipeline is:
- Create the simulation snapshots with cogli1 and povray. This might take a few minutes or a few days depending on the length and resolution of your movie, so you want to start doing this before anything else. Also before producing the final high-quality simulation snapshots you might want to produce a low-quality-quickly-generated preview, by lowering the resolution.
- Create the plots of the quantity with gnuplot. This can be done with e.g. the following gnuplot commands ,which should work in gnuplot >=4.6. If you're stuck with an old version of gnuplot that doesn't support for loops, you can use another program to generate a text file that writes the instructions to be performed at every iteration of the loop, and then run the resulting script in gnuplot.
set term png linewidth 4 font 'arial,28pt' size 3200,600 set xrange [25e3:25e3*40] set yrange [-1.42; -1.24] do for [i = 0:39]{ set out 'plot_'.i.'.png'; plot 'energy.dat' every 1000::1000::1000*(i+1) w lp }
notice that several things should be changed here according to your needs, including:
- the term type (to change the font, resolution, linewidth, etc). The resolution should be compatible with the one of the simulation snapshots
- the xrange (to make sure that it fits all the points, just barely)
- the yrange (to make sure that everything fits as needed)
- the plot command (to change the appearence of the plot, the line-type, how many frames do we have, whether to print the observable only when we have a frame or for all the frames up until a point, etc.).
- possibly adding some modifiers before plotting, including title, xlabel, ylabel, etc, a grid, etc.
- any other edit you might wish to make
- After both points above are finished, you can compose the images by either pasting the plots on the simulation snapshots, or appending the images together. This can easily be done with `convert` on linux and cygwin, with either of the following 2 lines: TO SUPERIMPOSE THE PLOT TO THE SIMULATION SNAPSHOT``
for i in {0..39}; do convert trajectory.dat_${i}_time_*.png plot_${i}.png -composite output_${i}.png; done
OR TO APPEND IT ABOVE IT
for i in {0..39}; do convert trajectory.dat_${i}_time_*.png plot_${i}.png -append output_${i}.png; done
swap the order of the plots and the simulations snapshots above to have the plot display below the simulation system instead.
- Convert the png files into a movie, with mencoder or ffmpeg, as usual, with:
ls -1v output_*.png > storyboard.txt mencoder mf://@storyboard.txt -mf w=3200:h=2400:fps=6:type=png -ovc xvid -xvidencopts bitrate=200 -o output.avi` where the keys mean:
- w and h
- respectively the width and hegiht of the movie (in pixels, here 3200 and 2400). This should be the same as the output_*.png files if you don't want the screen to view to be distorted.
- fps
- the number of frames per second (here 6).
- png
- the type of image (here png)
- ovc
- the codec used (here xvid)
- xvidencopts bitrate
- the bitrate, which is an option of the xvid codec (here set to 200)
- o
- the name of the movie file (here output.avi).
An example of this thing is the movie that I'm attaching here sample movie