PB3D  [2.45]
Ideal linear high-n MHD stability in 3-D
Functions/Subroutines
helena_ops Module Reference

Operations on HELENA variables. More...

Functions/Subroutines

integer function, public read_hel (n_r_in, use_pol_flux_H)
 Reads the HELENA equilibrium data. More...
 
integer function get_ang_interp_data_hel (grid_in, grid_out, theta_i, fund_theta_int_displ, tb_sym, use_E)
 Calculate interpolation factors for angular interpolation in grid_out of quantities defined on grid_in. More...
 
integer function, public interp_hel_on_grid (grid_in, grid_out, eq_2, X_1, X_2, eq_2_out, X_1_out, X_2_out, eq_1, grid_name)
 Interpolate variables resulting from HELENA equilibria to another grid (angularly). More...
 
integer function, public test_metrics_h ()
 Checks whether the metric elements provided by HELENA are consistent with a direct calculation using the coordinate transformations [17]. More...
 
integer function, public test_harm_cont_h ()
 Investaige harmonic content of the HELENA variables. More...
 

Detailed Description

Operations on HELENA variables.

Function/Subroutine Documentation

◆ get_ang_interp_data_hel()

integer function helena_ops::get_ang_interp_data_hel ( type(grid_type), intent(in)  grid_in,
type(grid_type), intent(in)  grid_out,
real(dp), dimension(:,:,:), intent(inout), allocatable  theta_i,
integer, dimension(:,:,:), intent(inout), allocatable  fund_theta_int_displ,
logical, intent(in), optional  tb_sym,
logical, intent(in), optional  use_E 
)

Calculate interpolation factors for angular interpolation in grid_out of quantities defined on grid_in.

This version is specific for an input grid corresponding to axisymmetric variables with optional top-down symmetry, as is the case for variables resulting from HELENA equilibria.

The output of a 3-D array of real values for the poloidal angle \(\theta\) where the floored integer of each value indicates the base index of the interpolated value in the output grid and the modulus is the the fraction towards the next integer.

The flag tb_sym indicates optionally that there is top-bottom symmetry as well as axisymmetry. When there is top-down symmetry, the variables in the lower half (i.e. \(-\pi < \theta < 0\)) are calculated from the variables in the upper half using the symmetry properties of the variables. To indicate this, the sign of the interpolation factor is inverted to a negative value.

The displacement of the theta interval towards the fundamental theta interval is also outputted. For asymmetric variables this is for example:

  • 1 for \(-2\pi \ldots 0\)
  • 0 for \( 0 \ldots 2\pi\)
  • -1 for \( 2\pi \ldots 4\pi\)

etc.

For symmetric variables, this is for example:

  • 1 for \(-3\pi \ldots -2\pi\), with symmetry property
  • 1 for \(-2\pi \ldots -\pi\)
  • 0 for \(-\pi \ldots 0\), with symmetry property
  • 0 for \( 0 \ldots \pi\)
  • -1 for \( \pi \ldots 2\pi\), with symmetry property
  • -1 for \( 3\pi \ldots 3\pi\) etc.

By default, the variables in the Flux coord. system are used, but this can be changed optionally with the flag "use_E.

Returns
ierr
Parameters
[in]grid_ininput grid
[in]grid_outoutput grid
[in,out]theta_iinterpolation index
[in,out]fund_theta_int_displdisplacement of fundamental theta interval
[in]tb_symtop-bottom symmetry
[in]use_ewhether E is used instead of F

Definition at line 413 of file HELENA_ops.f90.

+ Here is the caller graph for this function:

◆ interp_hel_on_grid()

integer function, public helena_ops::interp_hel_on_grid ( type(grid_type), intent(in)  grid_in,
type(grid_type), intent(in)  grid_out,
type(eq_2_type), intent(inout), optional  eq_2,
type(x_1_type), intent(inout), optional  X_1,
type(x_2_type), intent(inout), optional  X_2,
type(eq_2_type), intent(inout), optional  eq_2_out,
type(x_1_type), intent(inout), optional  X_1_out,
type(x_2_type), intent(inout), optional  X_2_out,
type(eq_1_type), intent(in), optional  eq_1,
character(len=*), intent(in), optional  grid_name 
)

Interpolate variables resulting from HELENA equilibria to another grid (angularly).

The input and output grid to be provided depend on the quantities to be interpolated:

  • equilibrium variables: flux variables (no need to convert) and derived quantities (need equilibrium grid)
  • metric variables: jac_FD (need equilibrium grid)
  • vectorial perturbation variables: U_i, DU_i (need perturbation grid)
  • tensorial perturbation variables: PV_i, KV_i (need perturbation grid)

Also, a message can be printed if a grid name is passed.

Note
  1. The metric coefficients are interpolated and then compensated for the straight-field-line coordinates as in [17] .
  2. By default the interpolated quantities overwrite the original ones, but alternative output variables can be provided.
  3. as the equilibrium and perturbation grid are not generally identical, this routine has to be called separately for the variables tabulated in either grid.
Returns
ierr
Parameters
[in]grid_ininput grid
[in]grid_outoutput grid
[in,out]eq_2general metric equilibrium variables
[in,out]x_1general vectorial perturbation variables
[in,out]x_2general tensorial perturbation variables
[in,out]eq_2_outfield-aligned metric equilibrium variables
[in,out]x_1_outfield-aligned vectorial perturbation variables
[in,out]x_2_outfield-aligned tensorial perturbation variables
[in]eq_1general flux equilibrium variables for metric interpolation
[in]grid_namename of grid to which to adapt quantities

Definition at line 550 of file HELENA_ops.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_hel()

integer function, public helena_ops::read_hel ( integer, intent(inout)  n_r_in,
logical, intent(inout)  use_pol_flux_H 
)

Reads the HELENA equilibrium data.

Adapted from HELENA routine IODSK.

The variales in the HELENA mapping file are globalized in two ways:

  • X and Y are normalized w.r.t. vacuum geometric axis R_vac and toroidal field at the geometric axis B_vac.
  • R[m] = R_vac[m] (1 + eps X[]) ,
  • Z[m] = R_vac[m] eps Y[] .

The covariant toroidal field F_H, pres_H and poloidal flux are normalized w.r.t magnetic axis R_m and total toroidal field at magnetic axis B_m:

  • RBphi[Tm] = F_H[] R_m[m] B_m[T] ,
  • pres[N/m^2] = pres_H[] (B_m[T])^2/mu_0[N/A^2] ,
  • flux_p[Tm^2] = 2pi (s[])^2 cpsurf[] B_m[T] (R_m[m])^2 .

The first normalization type is the HELENA normalization, whereas the second is the MISHKA normalization.

Everything is translated to MISHKA normalization to make comparison with MISHKA simple. This is done using the factors:

  • radius[] = a[m] / R_m[m] ,
  • eps[] = a[m] / R_vac[m] , so that the expressions become:
  • R[m] = radius[] (1/eps[] + X[]) R_m[m],
  • Z[m] = radius[] Y[] R_m[m],
  • RBphi[Tm] = F_H[] B_m[T] R_m[m],
  • pres[N/m^2] = pres_H[] B_m[T]^2 mu_0[N/A^2]^-1,
  • flux_p[Tm^2] = 2pi (s[])^2 cpsurf[] B_m[T] R_m[T]^2.

Finally, in HELENA, the total current I, the poloidal beta and the density at the geometric axis can be prescribed through:

  • XIAB = mu_0 I / (a_vac B_vac) ,
  • BETAP = 8 pi S <p> / (I^2 mu_0) ,
  • ZN ,

where a_vac = eps R_vac and B_vac are vacuum quantities, S is the 2-D cross-sectional area and <p> is the 2-D averaged pressure.

Note
To translate this to the MISHKA normalization factors as
  • R_m = (eps/radius) R_vac ,
  • B_m = B_vac / B0 ,
where
  • radius is in the mapping file (12), as well as in the HELENA output (20).
  • eps is in the mapping file (12), as well as in the HELENA input (10) and output (20).
  • B0 is in the mapping file (12), as well as in the HELENA output (20).
Furthermore, the density on axis can be specified as ZN0 from HELENA input (10).
The other variables should probably not be touched for consistency.
Finally, the variables IAS and B0 are in the mapping file (12) only in patched versions. See Getting the Equilibrium.
Returns
ierr
Parameters
[in,out]n_r_innr. of normal points in input grid
[in,out]use_pol_flux_h.true. if HELENA equilibrium is based on pol. flux

Definition at line 84 of file HELENA_ops.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_harm_cont_h()

integer function, public helena_ops::test_harm_cont_h

Investaige harmonic content of the HELENA variables.

Note
Run with one process.

Definition at line 1485 of file HELENA_ops.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_metrics_h()

integer function, public helena_ops::test_metrics_h

Checks whether the metric elements provided by HELENA are consistent with a direct calculation using the coordinate transformations [17].

Direct calculations used:

\[\begin{aligned} \left|\nabla \psi\right|^2 &= \frac{1}{\mathcal{J}^2} \left(\left(\frac{\partial Z}{\partial \chi}\right)^2 + \left(\frac{\partial R}{\partial \chi}\right)^2\right) \\ \left|\nabla \psi \cdot \nabla \chi\right| &= \frac{1}{\mathcal{J}^2} \left( \frac{\partial Z}{\partial \chi} \frac{\partial Z}{\partial \psi} - \frac{\partial R}{\partial \chi} \frac{\partial R}{\partial \psi} \right) \\ \left|\nabla \chi\right|^2 &= \frac{1}{\mathcal{J}^2} \left(\left(\frac{\partial Z}{\partial \psi}\right)^2 + \left(\frac{\partial R}{\partial \psi}\right)^2\right) \\ \left|\nabla \phi\right|^2 &= \frac{1}{R^2} \end{aligned}\]

with

\[\mathcal{J} = \frac{\partial Z}{\partial \psi} \frac{\partial R}{\partial \chi} - \frac{\partial R}{\partial \psi} \frac{\partial Z}{\partial \chi}\]

Also, test whether the pressure balance \(\nabla p = \vec{J}\times\vec{B} \) is satisfied.

Note
Debug version only
Returns
ierr

Definition at line 1289 of file HELENA_ops.f90.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: