tornadobox
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tornadobox [2025/03/17 14:37] – 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 74: | Line 77: | ||
| a text file that contain the '' | a text file that contain the '' | ||
| - | And here is the domain, grid and buoyancy in the model, | + | The program |
| - | {{ : | + | |
| - | + | ||
| - | And here we continue with the simulation from $t=15$ | + | |
| - | + | ||
| - | {{ : | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | ------------- | + | |
| - | 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, '' | + | |
| - | + | ||
| + | Make your own browser with [[https:// | ||
| < | < | ||
| - | [L boxprogram]$ python | + | f90tohtml tornadobox.f2h |
| - | Python 2.7.6 |Anaconda 2.0.0 (64-bit)| (default, May 27 2014, 14: | + | |
| </ | </ | ||
| + | === An example case === | ||
| + | Here is the domain, grid and buoyancy in the model, | ||
| + | ^{{ : | ||
| + | | The gaussian fixed buoyancy field has ellipsoid isosurfaces, | ||
| - | * you have '' | + | And here we continue with the simulation from $t=15$ to $t=30$, after doubling |
| + | ^{{ : | ||
| + | |The pressure | ||
| + | Model runs are identified with a four-character case prefix. Here we suggest the first letter is '' | ||
| - | < | + | Here is a plot of the time history of extreme values of speed $s$, vertical velocity $w$, and $q$. |
| - | PARAMETER(In=91,Jn=91,kn=46, | + | Note $q=\sqrt{2|p|}$ in the plot is a way of plotting pressure as a speed. $q$ can be interpreted as the speed that Bernoulli' |
| - | & im=In-1, | + | |
| - | </ | + | |
| + | ^{{ : | ||
| + | |A time history of extremes in the low-resolution simulation '' | ||
| + | === Running the model === | ||
| + | The FORTRAN programs do not accept command line arguments. They may read in files and, when started, need | ||
| + | a few strings to be input in response to queries. When first started, '' | ||
| + | the simulation at the times specified in '' | ||
| + | the parameter space, you can copy '' | ||
| + | |||
| + | Let us begin. | ||
| < | < | ||
| - | $ cd ~ | + | $ cd tornadobox |
| - | $ gunzip boxprogram.tar.gz | + | $ mkdir ../bf10 |
| - | $ tar xvf boxprogram | + | $ ln -s bf10 ../boxout |
| - | $ cd boxprogram | + | |
| - | $ chmod u+x sourceintel | + | |
| - | $ ./sourceintel | + | |
| - | $ ifort -o gridmaker gridmaker.f | + | |
| $ ./gridmaker | $ ./gridmaker | ||
| - | </code> | + | $ ./makefiletimes.py 0 202 1 |
| - | + | $ ./makefiletimes.py 0 202 1 > filetimes.txt | |
| - | + | ||
| - | Two files will be produced: | + | |
| - | + | ||
| - | * '' | + | |
| - | * '' | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | $ chmod u+x compileit | + | |
| - | $ ./compileit | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | That will produce two fortran programs: | + | |
| - | + | ||
| - | * '' | + | |
| - | * '' | + | |
| - | + | ||
| - | Now we run the model '' | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | <code> | + | |
| - | $ 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 at which the model dumps all the fields (and time derivatives of fields, so the model can in principle be exactly restarted) are within '' | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | < | + | |
| - | $ ln -s aaaa.input box.input | + | |
| $ ./boxn91 | $ ./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 | 0 | ||
| enter four characters: ' | enter four characters: ' | ||
| - | 'aaaa' | + | 'bf10' |
| Current parameters are: | Current parameters are: | ||
| & | & | ||
| - | | + | |
| | | ||
| - | | + | |
| | | ||
| | | ||
| Line 204: | Line 144: | ||
| enter yes, and store=2, yes, no store=1, no=0 | enter yes, and store=2, yes, no store=1, no=0 | ||
| 0 | 0 | ||
| - | | ||
| time now = 0.0000000E+00 | time now = 0.0000000E+00 | ||
| - | 10,.01 | + | 2,.01 |
| </ | </ | ||
| + | **Note**: I always answer '' | ||
| + | In less than a minute the model will say FINISHED! | ||
| - | After about ten minutes of wall clock, | + | Now let's restart |
| - | + | But first, put this line at then end of your '' | |
| - | + | ||
| < | < | ||
| - | 4844. 9.980 0.002060 | + | export PATH="/home/ |
| - | 4849. 9.990 0.002060 | + | |
| - | 4854. | + | |
| - | FINISHED! | + | |
| - | nloc= | + | |
| - | | + | |
| </ | </ | ||
| - | + | And, if you haven't done so, you may want this also: | |
| - | + | ||
| - | The numbers | + | |
| < | < | ||
| - | 4854. 10.001 0.002060 | + | source / |
| - | step # | + | |
| </ | </ | ||
| - | + | Then open a new window, and '' | |
| - | + | ||
| - | 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 | + | |
| - | $ ln -s ../ | + | |
| - | $ ./boxn91 | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | Here is way it looks for me. Note there is a dump of the vertical profile of viscosity. Apparently I was having some confusion/ | + | |
| < | < | ||
| - | [L boxprogram]$ ./boxn91 | + | $ cd ~/bf10 |
| + | $ ls | ||
| + | $ cat bf10.hist | ||
| + | $ ln -s bf10d002000.sav restart.sav | ||
| + | $ makefiletimes.py 0 202 1 > filetimes.txt | ||
| + | $ boxn91 | ||
| | | ||
| 1 | 1 | ||
| - | | + | continuing with bf10 |
| - | 2 4.4620000E-03 | + | |
| - | | + | will write .sav to disk at time: 3.000000 |
| - | | + | |
| - | | + | |
| - | | + | |
| - | 7 3.0393001E-02 | + | |
| - | | + | |
| - | | + | |
| - | 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 | + | |
| - | 20.00000 | + | |
| Current parameters are: | Current parameters are: | ||
| & | & | ||
| - | | + | |
| | | ||
| - | | + | |
| | | ||
| | | ||
| Line 317: | Line 193: | ||
| 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 = 2.002613 |
| - | time now = 10.00070 enter tstop, | + | 5,.01 |
| - | 200,.01 | + | </ |
| + | **Note**: the answer '' | ||
| </ | </ | ||
| - | + | Let's restart | |
| - | 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 | + | Use a text editor to make a file name '' |
| - | + | ||
| - | ===== plotting some results ===== | + | |
| - | + | ||
| - | + | ||
| - | After the model finishes, you should have time series in '' | + | |
| < | < | ||
| - | $ python plothist.py aaaa | + | 1 |
| + | 0 | ||
| + | 30,.01 | ||
| </ | </ | ||
| - | + | Then | |
| - | + | ||
| - | 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' | + | |
| - | + | ||
| - | 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 '' | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | $ python sav2pkl.py ~/ | + | $ remove restart.sav |
| + | $ ln -s bf10d005000.sav restart.sav | ||
| + | $ nohup boxn91 < answers > outstuff.txt & | ||
| + | $ tail -f outstuff.txt | ||
| + | $ ^C | ||
| + | $ logout | ||
| </ | </ | ||
| + | Let's have a break. | ||
| + | On one of my ancient computers with '' | ||
| + | that required 45 minutes of wall clock. | ||
| - | To see the grid at the surface | + | double |
| < | < | ||
| - | $ python gridplot.py ~/ | + | $ dubl91 bf10d015000.sav |
| - | $ display grid_xy.svg | + | enter ' |
| - | $ display grid_xz.svg | + | ' |
| - | </code> | + | $ ln -s bF10E015000.sav restart.sav |
| - | + | $ makefiletimes.py 0 202 .05 > filetimes.txt | |
| - | + | ||
| - | To a see an ugly plot of the vertical velocity at z=.06, together with horizontal wind vector plotted on 1/16th of the grid points, do: | + | |
| - | + | ||
| + | continue from previous case? | ||
| + | 1 | ||
| + | continuing with bF10 | ||
| + | time now: 15.00064 | ||
| + | will write .sav to disk at time: | ||
| + | Current parameters are: | ||
| + | & | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | / | ||
| + | Do you want to change any parameters? | ||
| + | enter yes, and store=2, yes, no store=1, no=0 | ||
| + | 0 | ||
| + | time now = | ||
| + | 15.1,.01 | ||
| + | </ | ||
| + | That should finish in a few minutes. To simulate out to $t=30$, I needed about 11 hours and 100G of disk space. | ||
| + | Your previous '' | ||
| < | < | ||
| - | $ python plotpkl.py ~/ | + | $ rm restart.sav |
| - | $ eog w20000.png | + | $ ln -s bF10D015100.sav restart.sav |
| + | $ nohup boxn181 < answers > | ||
| + | $ tail -f outstuff.txt | ||
| + | $ ^C | ||
| + | $ logout | ||
| </ | </ | ||
| + | Check it in the morning. | ||
| - | Plots of the fields will be more effective after we focus on the region where the vortex is. The domain is -2< | + | === plotting results === |
| - | + | ||
| - | Currently, '' | + | |
| - | + | ||
| + | Let's make the three images seen above. | ||
| + | Again, assuming your '' | ||
| < | < | ||
| - | $ cd ../boxout | + | $ cd ~/boxout |
| - | $ ~/ | + | $ hist2png.py |
| </ | </ | ||
| - | + | Now let's plot the isosurfaces of the fields. | |
| - | + | ||
| - | You need to enter some text at the query: | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | [L out_aaaa]$ ~/ | + | $ ls b*.sav |
| - | enter ' | + | |
| - | ' | + | |
| </ | </ | ||
| - | + | You should see you have a lot of '' | |
| - | + | Such files are easily readable by our plotting programs. This may need about 20 minutes: | |
| - | Here is the tail end of what I see dumped to the monitor: | + | |
| < | < | ||
| - | | + | $ sav2pkl.py b*.sav |
| - | | + | |
| - | | + | |
| </ | </ | ||
| - | + | If your python does not have the '' | |
| - | + | To make the times tidy and complete, let's rename a file: | |
| - | Note the fifth character in the original | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | $ cd ~/ | + | $ mv bF10E015000.pkl bF10D015000.pkl |
| - | $ python sav2pkl.py ~/ | + | $ pkl2png.py -s -hg -vg |
| - | $ python plotpkl.py ~/ | + | |
| - | $ eog w20000.png | + | |
| </ | </ | ||
| + | Note that '' | ||
| + | The '' | ||
| - | + | Next we zoom in to 25% of the camera distance, and plot at $t=30$: | |
| - | Here is what I see: | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | ==== 3d renderings with mayavi ==== | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| < | < | ||
| - | python isovectpkl.py ~/ | + | $ pkl2png.py -s -hg -c .25 bF10D030000 |
| </ | </ | ||
| - | + | And add a $w$ isosurface: | |
| - | + | ||
| - | A GUI should pop open, showing the p=-1 and p=-.5 isosurfaces. Note the upper left icon allows some features of the rendering to be switched on or off. Dexerity and creativity with a two-button mouse is also essential to change the viewing of the rendering. | + | |
| - | + | ||
| - | {{:mayavi200.png}} | + | |
| - | + | ||
| - | ==== 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 to double the resolution before restarting. | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | $ cd ~/boxout | + | $ pkl2png.py -s -hg -w -c .25 bF10D030000 |
| - | $ ../ | + | |
| </ | </ | ||
| - | + | $ Now we go for it, and plot the frames for movie. | |
| - | + | ||
| - | Here is what I did: | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | [L out_aaaa]$ ../ | + | $ mkdir pngs |
| - | enter ' | + | $ pkl2png.py -hg -w -c .25 bF10D0 pngs |
| - | ' | + | |
| </ | </ | ||
| - | + | That required 10 minutes on my computer to produce 301 '' | |
| - | + | ||
| - | This makes a new file '' | + | |
| < | < | ||
| - | c | + | $ cd pngs |
| - | c | + | $ eog bF10D015000.png |
| - | PARAMETER(In=181, | + | |
| - | & | + | |
| </ | </ | ||
| - | + | The '' | |
| - | + | ||
| - | and then compile again | + | |
| - | + | ||
| - | + | ||
| < | < | ||
| - | $ ifort -o boxn181 boxn.f boxs.f | + | $ cd ~/boxout |
| + | $ maketitle.py pngs/ | ||
| + | $ pip install moviepy | ||
| + | $ png2mp4.py | ||
| + | $ mpv video.mp4 | ||
| </ | </ | ||
| - | + | **FINISHED!** | |
| - | + | ||
| - | + | ||
| - | 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.1742240223.txt.gz · Last modified: by admin
