SPINS Science Files: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


Unless otherwise mentioned, the functions below work for both unmapped and mapped domains where the mapping is along the bottom of the domain (where the bottom is at the 0-index in the z-dimension, as opposed to at the <math> N_z-1 </math> index). Another way to say this is that z increases with the index.
Unless otherwise mentioned, the functions below work for both unmapped and mapped domains where the mapping is along the bottom of the domain (where the bottom is at the 0-index in the z-dimension, as opposed to at the <math> N_z-1 </math> index). Another way to say this is that z increases with the index.
== Notation ==
{{Warning|te}} Multiple different notations are used below. Subscripts of <math> u </math>, <math> v </math>, and <math> w </math> are always derivatives with respect to the subscript variable. However, subscripts of <math> \omega </math> and <math> t </math> are components. That is, <math> u_x </math> and <math> \omega_x </math> are the x-derivative of <math> u </math> and the x-component of vorticity.


== Units ==
== Units ==
Line 23: Line 27:
== bottom_slope.cpp ==
== bottom_slope.cpp ==
Compute the vector of the bottom slope at each x-grid point. This is used for calculating the stresses along the bottom boundary (cf. [[#bottom_stress_x.cpp|bottom_stress_x.cpp]] and  [[#bottom_stress_y.cpp|bottom_stress_y.cpp]]).
Compute the vector of the bottom slope at each x-grid point. This is used for calculating the stresses along the bottom boundary (cf. [[#bottom_stress_x.cpp|bottom_stress_x.cpp]] and  [[#bottom_stress_y.cpp|bottom_stress_y.cpp]]).


<div id="bottom_stress_x.cpp"></div>
<div id="bottom_stress_x.cpp"></div>
Line 65: Line 70:
<math> E_b = g \int_V \rho_* z_* dV  </math>
<math> E_b = g \int_V \rho_* z_* dV  </math>


where <math> z_* </math> is the depth of an element of the sorted density field which minimized the potential energy (ie. <math> \rho_*</math>). For more information see Winters et al. (1995).
where <math> z_* </math> is the depth of an element of the sorted density field which minimized the potential energy (ie. <math> \rho_*</math>). For more information see Winters et al. (1995). It is assumed that gravity points in the negative z direction.
 


<div id="compute_BPE_from_internal.cpp"></div>
<div id="compute_BPE_from_internal.cpp"></div>
Line 74: Line 80:


where <math> z_u </math> and <math> z_l </math> are the depths of the upper and lower boundaries, respectively. The integral is taken over the horizontal extent.  
where <math> z_u </math> and <math> z_l </math> are the depths of the upper and lower boundaries, respectively. The integral is taken over the horizontal extent.  
For more information see Winters et al. (1995).
For more information see Winters et al. (1995). It is assumed that gravity points in the negative z direction.


== compute_quadweights.cpp ==
== compute_quadweights.cpp ==
Line 112: Line 118:
== enstrophy_stretch_production.cpp ==
== enstrophy_stretch_production.cpp ==
Compute the enstrophy production due to vortex tilting/stretching  
Compute the enstrophy production due to vortex tilting/stretching  
<math> \sum_{ij} \omega_i \omega_j e_{ij} =  \sum_{ij} \omega_i \omega_j \frac{\partial u_i}{\partial x_j} </math> where,
<math> \sum_{ij} \omega_i \omega_j e_{ij} =  \sum_{ij} \omega_i \omega_j \frac{\partial u_i}{\partial x_j} </math>


<math> e_{ij} = \frac{1}{2} (\frac{\partial u_i}{\partial x_j} + \frac{\partial u_j}{\partial x_i})</math>
where, <math> e_{ij} = \frac{1}{2} (\frac{\partial u_i}{\partial x_j} + \frac{\partial u_j}{\partial x_i})</math>
is the strain rate tensor.
is the strain rate tensor.


cf. The [[Enstrophy equation]].
cf. The [[Enstrophy equation]].
== find_expansion.cpp  ==
Returns the expansion types for each field.
{| class="wikitable"
!colspan="1"|Boundary Condition
!colspan="4"|Flow Variable
|-
|-
|
|style="text-align:center;"|u
|style="text-align:center;"|v
|style="text-align:center;"|w
|style="text-align:center;"|otherwise
|-
|Fourier
|Periodic
|Periodic
|Periodic
|Periodic
|-
|No slip
|Chebyshev
|Chebyshev
|Chebyshev
|Chebyshev
|-
|Free slip in x
|sine
|cosine
|cosine
|cosine
|-
|Free slip in y
|cosine
|sine
|cosine
|cosine
|-
|Free slip in z
|cosine
|cosine
|sine
|cosine
|}
Spins assumes that a variable ending in <code>_x</code>, <code>_y</code>, or <code>_z</code> is the x, y, or z derivative of that particular variable. This is needed to get the proper expansion type for the derivative of the given variable.
== get_quad.cpp ==
Fairly certain that this is a deprecated function
== overturning_2d.cpp ==
Details to be added. It's an old function and probably deprecated.
== read_2d_restart.cpp ==
For reading 2D spins files and (likely) extending to 3D.
Unsure why this is in /Science. IO should also be cleaned up since there's a bunch of overlapping functions.
== read_2d_slice.cpp ==
For reading 2D matlab files or 2D slices.
Unsure why this is in /Science. IO should also be cleaned up since there's a bunch of overlapping functions.
== swap_trig.cpp ==
Change cosine expansion to sine expansion and vice versa. To be used in find_expansion for variables of derivatives.
== top_stress_x.cpp ==
Compute the 2D vector of the x-component of stress on the top boundary. The z boundary condition must be no slip and have no mapping along the top boundary. Implementation for mapping is missing as of 2020 (it's just copying what is done on the bottom boundary).
<math> t_x = -\mu u_z </math>
where <math> \mu = \nu \rho_0 </math> is the dynamic viscosity.
== top_stress_y.cpp ==
Compute the 2D vector of the y-component of stress on the top boundary. The z boundary condition must be no slip and have no mapping along the top boundary. Implementation for mapping is missing as of 2020 (it's just copying what is done on the bottom boundary).
<math> t_y = -\mu v_z </math>
where <math> \mu = \nu \rho_0 </math> is the dynamic viscosity.
== vortex_stretch_x ==
Compute the x-component of the vorticity production due to stretching/tilting
<math> \omega_x u_x + \omega_y u_y + \omega_z u_z </math>

Revision as of 16:38, 18 September 2020

SPINS comes with a variety of Science files which help with simulation data analysis. Below is a list of currently available functions with a brief description of their purpose and the assumptions behind their implementation. These Science files are in spins/src/Science.

Unless otherwise mentioned, the functions below work for both unmapped and mapped domains where the mapping is along the bottom of the domain (where the bottom is at the 0-index in the z-dimension, as opposed to at the index). Another way to say this is that z increases with the index.

Notation

Template:Warning Multiple different notations are used below. Subscripts of , , and are always derivatives with respect to the subscript variable. However, subscripts of and are components. That is, and are the x-derivative of and the x-component of vorticity.

Units

The units of each of the functions have been built under the assumption that physical units are being used in the simulation. These computations will work for nondimensional simulations, but more care must be taken to ensure the scalings are appropriate. Physical units are typically:

Length m
Time s
Density kg/m^3

The reference density should be 1000 kg/m^3 for the stress and dissipation calculations to be physically correct. The density field can be (and often is) non-dimensionalized to . If nondimensionalized, compute_Background_PE.cpp and compute_BPE_from_internal.cpp assume this form of scaling. These two functions also need to know if the density field is dimensional or not.


bottom_slope.cpp

Compute the vector of the bottom slope at each x-grid point. This is used for calculating the stresses along the bottom boundary (cf. bottom_stress_x.cpp and bottom_stress_y.cpp).


bottom_stress_x.cpp

Compute the 2D vector of the x-component of stress on the bottom boundary. The z boundary condition must be no slip.

If the case is unmapped:

where is the dynamic viscosity.

If the case is mapped:

where and where is the bottom slope.


bottom_stress_y.cpp

Compute the 2D vector of the y-component of stress on the bottom boundary. The z boundary condition must be no slip.

If the case is unmapped:

where is the dynamic viscosity.

If the case is mapped:

where and where is the bottom slope.


compute_Background_PE.cpp

Compute the value of the background potential energy,

where is the depth of an element of the sorted density field which minimized the potential energy (ie. ). For more information see Winters et al. (1995). It is assumed that gravity points in the negative z direction.


compute_BPE_from_internal.cpp

Compute the rate of energy transfer from internal energy into background potential energy.

where and are the depths of the upper and lower boundaries, respectively. The integral is taken over the horizontal extent. For more information see Winters et al. (1995). It is assumed that gravity points in the negative z direction.

compute_quadweights.cpp

Compute the quadrature weights for each dimension.

If the boundary condition is no-slip, use the Clenshaw-Curtis quadrature weights:

If the boundary condition is free-slip, use the trapezoid rule:

compute_vorticity.cpp

Compute all vorticity components.

compute_vort_x.cpp

Compute the x-component of vorticity:

compute_vort_y.cpp

Compute the y-component of vorticity:

compute_vort_z.cpp

Compute the z-component of vorticity:

dissipation.cpp

Compute the viscous dissipation where

is the strain rate tensor.

enstrophy_density.cpp

Compute the enstrophy density


enstrophy_stretch_production.cpp

Compute the enstrophy production due to vortex tilting/stretching

where, is the strain rate tensor.

cf. The Enstrophy equation.


find_expansion.cpp

Returns the expansion types for each field.

Boundary Condition Flow Variable
u v w otherwise
Fourier Periodic Periodic Periodic Periodic
No slip Chebyshev Chebyshev Chebyshev Chebyshev
Free slip in x sine cosine cosine cosine
Free slip in y cosine sine cosine cosine
Free slip in z cosine cosine sine cosine

Spins assumes that a variable ending in _x, _y, or _z is the x, y, or z derivative of that particular variable. This is needed to get the proper expansion type for the derivative of the given variable.


get_quad.cpp

Fairly certain that this is a deprecated function

overturning_2d.cpp

Details to be added. It's an old function and probably deprecated.

read_2d_restart.cpp

For reading 2D spins files and (likely) extending to 3D.

Unsure why this is in /Science. IO should also be cleaned up since there's a bunch of overlapping functions.

read_2d_slice.cpp

For reading 2D matlab files or 2D slices.

Unsure why this is in /Science. IO should also be cleaned up since there's a bunch of overlapping functions.

swap_trig.cpp

Change cosine expansion to sine expansion and vice versa. To be used in find_expansion for variables of derivatives.

top_stress_x.cpp

Compute the 2D vector of the x-component of stress on the top boundary. The z boundary condition must be no slip and have no mapping along the top boundary. Implementation for mapping is missing as of 2020 (it's just copying what is done on the bottom boundary).

where is the dynamic viscosity.

top_stress_y.cpp

Compute the 2D vector of the y-component of stress on the top boundary. The z boundary condition must be no slip and have no mapping along the top boundary. Implementation for mapping is missing as of 2020 (it's just copying what is done on the bottom boundary).

where is the dynamic viscosity.


vortex_stretch_x

Compute the x-component of the vorticity production due to stretching/tilting