tadd comments to examples - granular - granular dynamics simulation
 (HTM) git clone git://src.adamsgaard.dk/granular
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 8dfae9aca575a8c56aa37df2a7ef43d798cf1d97
 (DIR) parent 800c223ad51fd028760c1a57e24c3f853924a2e9
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Thu,  6 May 2021 10:21:02 +0200
       
       add comments to examples
       
       Diffstat:
         M many-grain-collision.sh             |       9 +++++++++
         M two-grain-collision.sh              |      14 ++++++++++++++
       
       2 files changed, 23 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/many-grain-collision.sh b/many-grain-collision.sh
       t@@ -1,16 +1,25 @@
        #!/bin/sh
       +
       +# stop the shell script if there's an error
        set -e
        
       +# set a common id string for files
        id=many-grain-collision
        
       +# remove any old files associated with this id
        rm -f ${id}.grains.*.{tsv,png} ${id}.mp4
        
       +# create a single grain and a granular packing, and simulate the interaction over time
        (granulargrain -R -u 1.0 -y 2.5; granularpacking -X 2.2) | granular -e 4.0 -I 0.1 ${id}
        
       +# plot grain positions over time, colored by their horizontal velocity
        for f in ${id}.grains.*.tsv; do
                granular2img -f '$5' -l 'x velocity [m/s]' -t png < "$f" > "${f%.tsv}.png"
        done
        
       +# combine grain plots into animation
        ffmpeg -y -framerate 5 -i ${id}.grains.%05d.png \
                -c:v libx264 -r 30 -pix_fmt yuv420p ${id}.mp4
       +
       +# open animation
        xdg-open ${id}.mp4 
 (DIR) diff --git a/two-grain-collision.sh b/two-grain-collision.sh
       t@@ -1,29 +1,43 @@
        #!/bin/sh
       +
       +# stop the shell script if there's an error
        set -e
        
       +# set a common id string for files
        id=two-grain-collision
        
       +# remove any old files associated with this id
        rm -f ${id}.grains.*.{tsv,png} ${id}.mp4
        
       +# create two grains, and simulate their interaction over time
        (granulargrain -R -u 0.1; granulargrain -f -x 1.2) | granular -e 4.0 -I 0.1 ${id}
        
       +# plot grain positions over time, colored by force magnitude
        for f in ${id}.grains.*.tsv; do
                #granular2img -f '$50' -l 'number of contacts' -t png < "$f" > "${f%.tsv}.png"
                #granular2img -f '$5' -l 'x velocity [m/s]' -t png < "$f" > "${f%.tsv}.png"
                granular2img -f '$14' -l 'force_x [N]' -t png < "$f" > "${f%.tsv}.png"
        done
        
       +# combine grain plots into animation
        ffmpeg -y -framerate 5 -i ${id}.grains.%05d.png \
                -c:v libx264 -r 30 -pix_fmt yuv420p ${id}.mp4
       +
       +# open animation
        xdg-open ${id}.mp4 
        
       +# calculate bulk energy for each output file
        > "${id}.energy.tsv"
        for f in ${id}.grains.*.tsv; do
                granularenergy < "$f" >> "${id}.energy.tsv"
        done
       +
       +# plot energy over time
        gnuplot -e "set term png;\
                    set xlabel 'time step';\
                    set ylabel 'Energy [J]';\
                                plot '-' u 0:1 w lp t 'Total energy'" \
                                 < "${id}.energy.tsv" > "${id}.energy.png"
       +
       +# open energy plot
        xdg-open "${id}.energy.png"