tadd comments to examples - granular - granular dynamics simulation | |
git clone git://src.adamsgaard.dk/granular | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 8dfae9aca575a8c56aa37df2a7ef43d798cf1d97 | |
parent 800c223ad51fd028760c1a57e24c3f853924a2e9 | |
Author: Anders Damsgaard <[email protected]> | |
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(-) | |
--- | |
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 o… | |
(granulargrain -R -u 1.0 -y 2.5; granularpacking -X 2.2) | granular -e 4.0 -I … | |
+# 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}.… | |
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 | |
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 ${… | |
+# 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%.t… | |
#granular2img -f '$5' -l 'x velocity [m/s]' -t png < "$f" > "${f%.tsv}… | |
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" |