tornadobox
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tornadobox [2025/03/18 16:22] – admin | tornadobox [2025/04/13 07:58] (current) – admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ==== Tornado Box==== | + | ==== 3-D Fortran CFD code for tornado-like vortices |
| - | This page provides | + | Grab the code: [[https:// |
| + | |||
| + | This page describes | ||
| {{ : | {{ : | ||
| I also still offer [[https:// | I also still offer [[https:// | ||
| that provides some results and animation, but no Fortran program. | that provides some results and animation, but no Fortran program. | ||
| - | The coding style evolved from a program passed down to Prof. Fiedler by his dissertation adviser, in the late 1970s. Notable ancient features are the Fortran 77 style, for the '' | + | The coding style evolved from a program passed down to Prof. Fiedler by his dissertation adviser, in the late 1970s. Notable ancient features are the Fortran 77 style, for the '' |
| + | see the Fortran code at [[https:// | ||
| === FORTRAN === | === FORTRAN === | ||
| Line 75: | Line 78: | ||
| The program '' | The program '' | ||
| + | |||
| + | Make your own browser with [[https:// | ||
| + | < | ||
| + | f90tohtml tornadobox.f2h | ||
| + | </ | ||
| === An example case === | === An example case === | ||
| Line 206: | Line 214: | ||
| $ ^C | $ ^C | ||
| $ logout | $ logout | ||
| - | |||
| - | Let's have a break. | ||
| - | |||
| - | === ancient, to be revised === | ||
| - | Ancient, to be revised: | ||
| - | |||
| - | Assumes: | ||
| - | |||
| - | * You have the Intel Fortran compiler installed in '' | ||
| - | |||
| - | untar the '' | ||
| - | |||
| - | * You have the Anaconda distribution of python. At the time of this writing, '' | ||
| - | |||
| - | |||
| - | |||
| - | < | ||
| - | [L boxprogram]$ python | ||
| - | Python 2.7.6 |Anaconda 2.0.0 (64-bit)| (default, May 27 2014, 14: | ||
| </ | </ | ||
| + | Let's have a break. | ||
| + | On one of my ancient computers with '' | ||
| + | that required 45 minutes of wall clock. | ||
| - | + | double the resolution, | |
| - | * you have '' | + | |
| - | + | ||
| < | < | ||
| - | PARAMETER(In=91,Jn=91,kn=46, | + | $ dubl91 bf10d015000.sav |
| - | & im=In-1,Jm=Jn-1,km=kn-1) | + | enter ' |
| - | </code> | + | ' |
| + | $ ln -s bF10E015000.sav restart.sav | ||
| + | $ makefiletimes.py 0 202 .05 > filetimes.txt | ||
| - | + | continue from previous case? | |
| - | + | 1 | |
| - | + | | |
| - | < | + | |
| - | $ cd ~ | + | |
| - | $ gunzip boxprogram.tar.gz | + | |
| - | $ tar xvf boxprogram | + | |
| - | $ cd boxprogram | + | |
| - | $ chmod u+x sourceintel | + | |
| - | $ ./ | + | |
| - | $ ifort -o gridmaker gridmaker.f | + | |
| - | $ ./ | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | Two files will be produced: | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | $ chmod u+x compileit | + | |
| - | $ ./ | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | That will produce two fortran programs: | + | |
| - | + | ||
| - | * '' | + | |
| - | * '' | + | |
| - | + | ||
| - | Now we run the model '' | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | $ cd ~ | + | |
| - | $ mkdir out_test | + | |
| - | $ ln -s out_test boxout | + | |
| - | $ cd boxprogram | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | Cases are identified with prefixes of four characters, which is short for historical reasons: it fits within four bytes. For example, '' | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | ===== running the model ===== | + | |
| - | + | ||
| - | + | ||
| - | The frequency | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | $ ln -s aaaa.input box.input | + | |
| - | $ ./boxn91 | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | This is what you enter at the prompts. It will take the model out to the dump of the dump of '' | + | |
| - | + | ||
| - | < | + | |
| - | [L boxprogram]$ ./boxn91 | + | |
| - | | + | |
| - | 0 | + | |
| - | enter four characters: ' | + | |
| - | ' | + | |
| Current parameters are: | Current parameters are: | ||
| & | & | ||
| - | | + | |
| | | ||
| - | | + | |
| | | ||
| | | ||
| Line 330: | Line 254: | ||
| enter yes, and store=2, yes, no store=1, no=0 | enter yes, and store=2, yes, no store=1, no=0 | ||
| 0 | 0 | ||
| - | dtdif= | + | time now = 15.00064 |
| - | time now = 0.0000000E+00 | + | 15.1,.01 |
| - | 10,.01 | + | |
| </ | </ | ||
| - | + | That should finish in a few minutes. To simulate | |
| - | + | Your previous | |
| - | After about ten minutes | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | 4844. 9.980 0.002060 | + | |
| - | | + | |
| - | 4854. | + | |
| - | FINISHED! | + | |
| - | | + | |
| - | | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | The numbers you see are also within | + | |
| - | + | ||
| - | < | + | |
| - | 4854. | + | |
| - | step # | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | The numbers are diagnosed for the central part of the domain, and z<.5, roughly the domain portion seen in the above snapshot. | + | |
| - | + | ||
| - | Next we show how to restart the model. | + | |
| < | < | ||
| $ rm restart.sav | $ rm restart.sav | ||
| - | $ ln -s ../ | + | $ ln -s bF10D015100.sav restart.sav |
| - | $ ./boxn91 | + | $ nohup boxn181 < answers > |
| + | $ tail -f outstuff.txt | ||
| + | $ ^C | ||
| + | $ logout | ||
| </ | </ | ||
| + | Check it in the morning. | ||
| - | Here is way it looks for me. Note there is a dump of the vertical profile of viscosity. Apparently I was having some confusion/ | + | === plotting results === |
| + | Let's make the three images seen above. | ||
| + | Again, assuming your '' | ||
| < | < | ||
| - | [L boxprogram]$ ./boxn91 | + | $ cd ~/boxout |
| - | continue from previous case? | + | $ hist2png.py bf10.hist bF10.hist |
| - | 1 | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | 10 5.2308001E-02 | + | |
| - | 11 6.1175998E-02 | + | |
| - | 12 7.0941001E-02 | + | |
| - | 13 8.1660002E-02 | + | |
| - | 14 9.3382001E-02 | + | |
| - | 15 0.1061500 | + | |
| - | 16 0.1200000 | + | |
| - | 17 0.1349580 | + | |
| - | 18 0.1510460 | + | |
| - | 19 0.1682760 | + | |
| - | 20 0.1866550 | + | |
| - | 21 0.2061860 | + | |
| - | 22 0.2268610 | + | |
| - | 23 0.2486730 | + | |
| - | 24 0.2716050 | + | |
| - | 25 0.2956400 | + | |
| - | 26 0.3207550 | + | |
| - | 27 0.3469230 | + | |
| - | 28 0.3741180 | + | |
| - | 29 0.4023070 | + | |
| - | 30 0.4314580 | + | |
| - | 31 0.4615390 | + | |
| - | 32 0.4925120 | + | |
| - | 33 0.5243420 | + | |
| - | 34 0.5569940 | + | |
| - | 35 0.5904310 | + | |
| - | 36 0.6246150 | + | |
| - | 37 0.6595120 | + | |
| - | 38 0.6950850 | + | |
| - | 39 0.7313000 | + | |
| - | 40 0.7681220 | + | |
| - | 41 0.8055170 | + | |
| - | 42 0.8434540 | + | |
| - | 43 0.8819000 | + | |
| - | 44 0.9208260 | + | |
| - | 45 0.9602020 | + | |
| - | 46 | + | |
| - | continuing with aaaa | + | |
| - | | + | |
| - | Current parameters are: | + | |
| - | & | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | / | + | |
| - | Do you want to change any parameters? | + | |
| - | enter yes, and store=2, yes, no store=1, no=0 | + | |
| - | 0 | + | |
| - | | + | |
| - | time now = | + | |
| - | 200,.01 | + | |
| </ | </ | ||
| - | + | Now let's plot the isosurfaces of the fields. | |
| - | You will need more than 190 minutes for the model to complete. As the tornado spins up, the model reduces the time step to satisfy the CFL condition. | + | |
| - | + | ||
| - | ===== plotting some results ===== | + | |
| - | + | ||
| - | + | ||
| - | After the model finishes, you should have time series in '' | + | |
| < | < | ||
| - | $ python plothist.py aaaa | + | $ ls b*.sav |
| </ | </ | ||
| - | + | You should see you have a lot of '' | |
| - | + | Such files are easily readable by our plotting programs. | |
| - | You should see something like this, traces of the maximum values of speed, w and q: | + | |
| - | + | ||
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | Note q in the plot is a way of plotting pressure as a speed. It is the speed that Bernuolli's equation predicts could be accelerated by the low pressure $q=\sqrt{2|p|}$. | + | |
| - | + | ||
| - | The absolute value just keeps the code from blowing up; the negative values of p are producing the extreme values of q that are plotted. | + | |
| - | + | ||
| - | ==== pickle files ==== | + | |
| - | + | ||
| - | + | ||
| - | The python plotting programs for the fields within the ''%%.sav%%'' | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | $ python | + | $ sav2pkl.py |
| </ | </ | ||
| - | + | If your python does not have the '' | |
| - | + | To make the times tidy and complete, let's rename | |
| - | To see the grid at the surface | + | |
| < | < | ||
| - | $ python gridplot.py ~/ | + | $ mv bF10E015000.pkl bF10D015000.pkl |
| - | $ display grid_xy.svg | + | $ pkl2png.py -s -hg -vg |
| - | $ display grid_xz.svg | + | |
| </ | </ | ||
| + | Note that '' | ||
| + | The '' | ||
| - | + | Next we zoom in to 25% of the camera distance, and plot at $t=30$: | |
| - | To a see an ugly plot of the vertical velocity | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | $ python plotpkl.py ~/ | + | $ pkl2png.py -s -hg -c .25 bF10D030000 |
| - | $ eog w20000.png | + | |
| </ | </ | ||
| - | + | And add a $w$ isosurface: | |
| - | + | ||
| - | Plots of the fields will be more effective after we focus on the region where the vortex is. The domain is -2< | + | |
| - | + | ||
| - | Currently, '' | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | $ cd ../boxout | + | $ pkl2png.py -s -hg -w -c .25 bF10D030000 |
| - | $ ~/ | + | |
| </ | </ | ||
| - | + | $ Now we go for it, and plot the frames for movie. | |
| - | + | ||
| - | + | ||
| - | You need to enter some text at the query: | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | [L out_aaaa]$ ~/ | + | $ mkdir pngs |
| - | enter ' | + | $ pkl2png.py -hg -w -c .25 bF10D0 pngs |
| - | ' | + | |
| </ | </ | ||
| - | + | That required 10 minutes on my computer | |
| - | + | ||
| - | Here is the tail end of what I see dumped | + | |
| < | < | ||
| - | | + | $ cd pngs |
| - | minimum model grid size= 1.3805000E-02 | + | $ eog bF10D015000.png |
| - | | + | |
| </ | </ | ||
| - | + | The '' | |
| - | + | ||
| - | Note the fifth character in the original | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | $ cd ~/ | + | |
| - | $ python sav2pkl.py ~/ | + | |
| - | $ python plotpkl.py ~/ | + | |
| - | $ eog w20000.png | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | Here is what I see: | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | ==== 3d renderings with mayavi ==== | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | python isovectpkl.py ~/ | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | A GUI should pop open, showing | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | ==== doubling the resolution ==== | + | |
| - | + | ||
| - | + | ||
| - | Note that it is possible to identify a time period of interest and restart the model from a '' | + | |
| - | + | ||
| - | It is also possible | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| $ cd ~/boxout | $ cd ~/boxout | ||
| - | $ ../boxprogram/ | + | $ maketitle.py pngs/ |
| + | $ pip install moviepy | ||
| + | $ png2mp4.py -t title.png pngs/bF10D | ||
| + | $ mpv video.mp4 | ||
| </ | </ | ||
| - | + | **FINISHED!** | |
| - | + | ||
| - | Here is what I did: | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | [L out_aaaa]$ ../ | + | |
| - | enter ' | + | |
| - | ' | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | This makes a new file '' | + | |
| - | + | ||
| - | < | + | |
| - | c | + | |
| - | c | + | |
| - | PARAMETER(In=181, | + | |
| - | & | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | and then compile again | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | $ ifort -o boxn181 boxn.f boxs.f | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | Proceed with your computations using '' | + | |
| - | + | ||
| - | ==== left undone ==== | + | |
| - | + | ||
| - | + | ||
| - | What isn't shown in this tutorial is how to make animations, such as seen here: http:// | + | |
| - | + | ||
| - | + | ||
| - | box (last edited 2014-06-17 10:24:43 by [[http:// | + | |
tornadobox.1742332959.txt.gz · Last modified: by admin
