SPINS derivatives: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
(Create SPINS derivative page)
 
No edit summary
Line 70: Line 70:


Higher derivatives are essentially not available. In practice, higher derivatives of tracer fields are available, but the resultant field will contain multiple underscores which could become confusing. Higher derivatives of velocity fields will only be correct in only a small subset of boundary conditions. Try higher derivatives at your peril.
Higher derivatives are essentially not available. In practice, higher derivatives of tracer fields are available, but the resultant field will contain multiple underscores which could become confusing. Higher derivatives of velocity fields will only be correct in only a small subset of boundary conditions. Try higher derivatives at your peril.
== Bottom shear stress ==
Setting <code>do_stress = true</code> in <code>spins.conf</code> enables the computation of bottom and top shear stress, while setting <code>deriv_files = u</code> and <code>v</code> tells the program to compute the streamwise stress and spanwise stress, respectively. Currently, the program works only for a flat top or bottom boundary without topography. Instead of writing the data onto the disk at each output step, the program saves them in the form of 3D arrays <code>stress_bot_x</code>, <code>stress_bot_y</code>, <code>stress_top_x</code>, and <code>stress_top_y</code>, whose third dimension is determined by the total number of output steps.

Revision as of 15:26, 22 February 2019

A case file has been created for efficiently computing derivatives and secondary variables from a completed SPINS run. This case file uses the internal operations of SPINS and are therefore spectrally accurate, parallel and quick. The case file is called derivatives.cpp in cases/derivatives and can calculate:

  • 1st and 2nd derivatives of any field
  • Each component of vorticity
  • Enstrophy
  • Dissipation

Running derivatives.x

Compile the case file and transfer the executable and configuration file into your case directory. Since you will likely have a configuration file for your initial case you should rename the derivatives configuration file as spins.conf_deriv. Keeping the configuration file for the original case is good practice as you will want to reference it a lot.

After setting the parameters and specifying which derivatives and secondary variables to calculate in the configuration file you will run the derivatives case file. Since the configuration file for this is not called spins.conf you will need to adjust your execution command. The command you want is:

mpirun -np N ./derivatives.x --config=spins.conf_deriv

Derivative fields (once computed) will contain an underscore followed by a letter indicating which dimension the field was differentiated with respect to. For example u_y corresponds to the y-derivative of the u field, and u_yy corresponds to the second y-derivative of the u field. This is in contrast to vorty which is the y component of the vorticity field (the other two being vortx and vortz).

Specifying fields and indices/outputs

The deriv_files option in the configuration file will specify which fields will be differentiated. You can specify multiple fields by placing a space between each field name. For example, if you'd like the derivatives of u, v, w, and rho then set the deriv_files line to

deriv_files = u v w rho

Make sure there is only a single space. If multiple spaces exist then empty files will be created. If you are not calculating derivatives (just the vorticity, enstrophy, or dissipation) then the inputs on this line will be ignored.

Specify which secondary variables are computed with the do_... options:

do_vor_x = false
do_vor_y = true
do_vor_z = false
do_enstrophy = false
do_dissipation = false

do_vor_y = true will calculate the y-component of vorticity. The enstrophy and dissipation options are similar. True for compute the derivative, and false if not.

You will specify which outputs to compute by using the start_sequence, final_sequence, and step_sequence options. These options are like creating a vector in Matlab with colon notation. The start_sequence sets the first output number to compute, the step_sequence sets the increment between output numbers, and the final_sequence is the last output number to compute. If you want to compute the 3,5, and 7th outputs then set:

start_sequence = 3
final_sequence = 7
step_sequence =  2

If you only want a single output computed (say, the 7th) then set:

start_sequence = 7
final_sequence = 7

step_sequence will be ignored.

2D/3D

If your simulation is three-dimensional (or contains the span-wise velocity v) then you must specify that the v-velocity is present within the working directory. This is the very last option in the configuration file.

If the simulation is 3D then set v_exist = true.

If the simulation is 2D then you'll likely want to set v_exist = false. However, if the simulation is 2-1/2 dimensions (has periodic flow in y with only a single grid point, probably due to rotation) then you'll need to include the v-velocity for the vorticity, enstrophy, and dissipation calculations.

Second derivatives

Second derivatives can be computed immediately with first derivatives, but require them to also be computed. Essentially it's a serial process in that the first derivative will be calculated, written to disk, then read from disk, and the second derivative calculated. It's not ideal, but it's simpler code.

To calculate the second x-derivative of rho set:

deriv_files = rho rho_x
deriv_x = true

The order of the deriv_files is key. The first derivative will be calculated first since rho is listed first, then the second derivative will be calculated. You can do this for multiple fields, such as

deriv_files = rho rho_x u u_x
deriv_x = true

You can also compute all secondary derivatives with:

deriv_files = rho rho_x rho_y rho_z
deriv_x = true
deriv_y = true
deriv_z = true

Though you'll get 12 files since each cross-derivative will be computed. You should then delete unneeded cross-derivative files afterwards to clear-up some storage.

Higher derivatives are essentially not available. In practice, higher derivatives of tracer fields are available, but the resultant field will contain multiple underscores which could become confusing. Higher derivatives of velocity fields will only be correct in only a small subset of boundary conditions. Try higher derivatives at your peril.

Bottom shear stress

Setting do_stress = true in spins.conf enables the computation of bottom and top shear stress, while setting deriv_files = u and v tells the program to compute the streamwise stress and spanwise stress, respectively. Currently, the program works only for a flat top or bottom boundary without topography. Instead of writing the data onto the disk at each output step, the program saves them in the form of 3D arrays stress_bot_x, stress_bot_y, stress_top_x, and stress_top_y, whose third dimension is determined by the total number of output steps.