Tutorial: Difference between revisions

From openpipeflow.org
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 119: Line 119:
<pre>
<pre>
  > gnuplot
  > gnuplot
  > plot 'vel_energy.dat' w l             [with lines]
  > plot 'vel_energy.dat' w l               [with lines]
  > plot 'vel_energy.dat' u 1:($2-$3) w l
  > plot 'vel_energy.dat' u 1:($2-$3) w l   [using column1 and column2-column3]
</pre>
</pre>
The last line here plots 'E_{k\ne0}', the energy in the axially dependent modes only.  This quantity decays rapidly after relaminarisations, and the simulation will stop if it drops below the parameter value for <tt>d_minE3d</tt>, e.g. <tt>1d-5</tt>.  Note that this parameter has no effect if it is set to e.g. <tt>-1d0</tt>.
The last line here plots 'E_{k\ne0}', the energy in the axially dependent modes only.  This quantity decays rapidly after relaminarisations, and the simulation will stop if it drops below the parameter value for <tt>d_minE3d</tt>, e.g. <tt>1d-5</tt>.  Note that this parameter has no effect if it is set to e.g. <tt>-1d0</tt>.
Line 128: Line 128:
<pre>
<pre>
  > set log
  > set log
  > plot 'vel_spec0001.dat' u ($1+1):2 w lp         [with lines and points]
  > plot 'vel_spec0001.dat' u ($1+1):2 w lp   [with lines and points]
  ...
  ...
  > quit
  > quit
Line 143: Line 143:
Wait a few seconds then press enter again. There should be a message like,
Wait a few seconds then press enter again. There should be a message like,
'[1]+ Done nohup ./main.out ...', to say that the job has has ended.
'[1]+ Done nohup ./main.out ...', to say that the job has has ended.
To see how long and how fast it was running, do
> tail OUT
  step=      10480  its=          1
  step=      10490  its=          1
  step=      10500  its=          1
RUNNING deleted !
cleanup...
  sec/step  =  0.1118212   
  CPU time  =          19  mins.
  saving state0006  t=  105.100000000017   
...done!


=== Make a util ===
=== Make a util ===

Revision as of 02:24, 9 September 2014

If you haven't already, read through the Getting_started page. Skip the Getting_started#Compiling_libraries section if someone has set up the libraries and Makefile for you.

The following assumes that the code has been downloaded (Main_Page#Download), and that libraries have been correctly installed (Getting_started#Compiling_libraries), so that the command 'make' does not exit with an error.

Where to start from - initial conditions and the main.info file

The best input initial condition is usually the output state from another run, preferably from a run with similar parameter settings. Output state files are named state0000.cdf.dat, state0001.cdf.dat, state0002.cdf.dat, and so on. Any of these could be used as a potential initial condition. If resolution parameters do not match, then they automatically interpolated or truncated to the new resolution (the resolution selected at compile time).

Download the following file from the Database: File:Re2400a1.25.tgz Extract the contents:

> cd .../openpipeflow-1.02b/
> mv .../Re2400a1.25.tgz .
> tar -xvvzf Re2400a1.25.tgz

Replace '...' with appropriate paths. This should produce a directory Re2400a1.25/ containing an output state file state0010.cdf.dat and a main.info file. The main.info file is a record of parameter settings that were used when compiling the executable that produced the state file.

Set your parameters

We will assume serial use (for parallel use see Getting_started#Typical_usage).

The number of cores is set in parallel.h. Ensure that the number beside _Np is 1:

> head parallel.h
  ...
  #define _Np 1
  ...

If not, edit with your favourite text editor, e.g.

> nano parallel.h   [OR]
> pico parallel.h   [OR]
> gedit parallel.h

In another terminal window, take a look at the main.info downloaded a moment ago

> less Re2400a1.25/main.info

In the previous terminal window, edit the parameters so that they are the same as in the given main.info file

> nano program/parameters.f90

You should ignore from 'i_KL' onwards.

Compile and setup a job directory

After setting the parameters, we need to create an executable that will run with the settings we've chosen. To compile the code with the current parameter settings

> make 
> make install

If an error is produced, go back to the top and check that libraries and Makefile are set up correctly. The second command creates the directory install/ and a new main.info file. Optionally, you could check for any differences between the new and given parameters

> diff install/main.info Re2400a1.25/main.info

We'll create a new job directory with an initial condition in there ready for the new run

> cp Re2400a1.25/state0010.cdf.dat install/state.cdf.in
> mkdir ~/runs/
> mv install ~/runs/job0001
> cd ~/runs/job0001
> ls -l
      main.info
      main.out
      state.cdf.in

Start the run

To start the run

> nohup ./main.out > OUT 2> OUT.err &

'&' puts the job in the background. 'nohup' allows you to logout from the terminal window without 'hangup' - otherwise, a forced closure of the window could kill the job. Output and errors normally sent to the terminal window are redirected to the OUT files.

A few seconds after starting the job, press enter again. If there is a message like

'[1]+ Done nohup ./main.out ...'

then it is likely that there was an error. In that case, try

> less OUT 
> less OUT.err

('less' is like 'more', but you can scroll and search (with '/'). Press 'q' to exit.) If there is a message about MPI libraries, and earlier you changed _Np from another value to 1, then you could try running instead with

> mpirun -np 1 ./main.out > OUT 2> OUT.err &

You might need to include a path to mpirun; search your Makefile for the mpirun command.

Monitor the run

> tail OUT
 step=         250  its=           1
 step=         260  its=           1
 step=         270  its=           1
 step=         280  its=           1
 step=         290  its=           1

Or

> tail vel_energy.dat
 0.460000000000E+01  0.212663112589E+00  0.205671549034E+00  0.136527620026E+00
 0.470000000000E+01  0.212838965680E+00  0.205824136857E+00  0.136608501228E+00
 0.480000000000E+01  0.213016257049E+00  0.205977535356E+00  0.136691152721E+00
 0.490000000000E+01  0.213194975547E+00  0.206131729799E+00  0.136775569670E+00
 0.500000000000E+01  0.213375109428E+00  0.206286705178E+00  0.136861746757E+00

Column 1 of vel_energy.dat is the time, column 2 is the energy in the perturbation to the mean flow. Columns 3 and 4 are the energies in the axially averaged (k=0) and azimuthally averaged (m=0) components respectively.

If OUT is an empty file for a while, then your machine is buffering the output. It is more likely that vel_energy.dat gets buffered than the OUT file.

The code outputs snapshot data, which includes a 4-digit number e.g. vel_spec0003.dat and state0012.cdf.dat, and time-series data, e.g. the energy as a function of time vel_energy.dat.

Snapshot data is saved every i_save_rate1 timesteps (typically 2000), and time-series data is saved every i_save_rate2 timesteps (typically 10).

Let the code run for a few minutes, give it a chance to save a few state files. To see the simulation times when the state were saved,

> grep state OUT | less
loading state...
 saving state0000  t=  0.000000000000000E+000
 saving state0001  t=   20.0000000000003     
 saving state0002  t=   40.0000000000006     
Energy vs time

Let's plot the energy as a function of time:

 > gnuplot
 > plot 'vel_energy.dat' w l                [with lines]
 > plot 'vel_energy.dat' u 1:($2-$3) w l    [using column1 and column2-column3]

The last line here plots 'E_{k\ne0}', the energy in the axially dependent modes only. This quantity decays rapidly after relaminarisations, and the simulation will stop if it drops below the parameter value for d_minE3d, e.g. 1d-5. Note that this parameter has no effect if it is set to e.g. -1d0.

Spectrum

It is a good idea to keep track of the resolution. Still in gnuplot

 > set log
 > plot 'vel_spec0001.dat' u ($1+1):2 w lp    [with lines and points]
 ...
 > quit

This is a rough plot indicating the drop-off in amplitude of coefficients (the drop-off in energies will be the square of these values), defined by E_k = max_{nm} a_{nkm}, E_m = max_{nk} a_{nkm}, E_n = max_{km} a_{nkm}, where n is the index of axial resolution, k for axial and m for azimuthal.

Ideally, the lines should all drop by around 3-4 orders of magnitude or more. If there is an upward spike at the end of one of the lines, then this is usually the signature of a timestep that is too large. Ignore the zig-zag for the tail of the line for radial resolution, focus on the upper values in the zig-zag only. It arises because a finite difference scheme is used, but it has been transformed to a spectral basis purely for the purpose of gauging the quality of resolution.

End the run

Type

> rm RUNNING

and press enter. This signals to the job to terminate (cleanly). Wait a few seconds then press enter again. There should be a message like, '[1]+ Done nohup ./main.out ...', to say that the job has has ended.

To see how long and how fast it was running, do

> tail OUT
 step=       10480  its=           1
 step=       10490  its=           1
 step=       10500  its=           1
RUNNING deleted !
cleanup...
 sec/step  =   0.1118212    
 CPU time  =           19  mins.
 saving state0006  t=   105.100000000017     
...done!

Make a util

The core code in program/ rarely needs to be changed. Almost anything can be done by creating a utility instead. There are many examples in utils/. Further information can be found on the Utilities page.

In Makefile, set UTIL = prim2matlab. In the utils/ directory there is a corresponding file prim2matlab.f90.

> make
> make install
> make util

Really, only the last command is necessary, which creates the executable prim2matlab.out. It is good practice, however, to do the previous commands to generate a main.info file to keep alongside the executable.

Visualise

TO DO