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

Operations on the solution vectors such as decompososing the energy, etc... More...

Functions/Subroutines

subroutine, public plot_sol_vals (sol, last_unstable_id)
 Plots Eigenvalues. More...
 
integer function, public plot_sol_vec (mds_X, mds_sol, grid_eq, grid_X, grid_sol, eq_1, eq_2, X, sol, XYZ, X_id, plot_var)
 Plots Eigenvectors. More...
 
integer function, public plot_harmonics (mds, grid_sol, sol, X_id, res_surf)
 Plots the harmonics and their maximum in 2-D. More...
 
integer function, public decompose_energy (mds_X, mds_sol, grid_eq, grid_X, grid_sol, eq_1, eq_2, X, sol, vac, X_id, B_aligned, XYZ, E_pot_int, E_kin_int)
 Decomposes the plasma potential and kinetic energy in its individual terms for an individual Eigenvalue. More...
 
integer function calc_e (mds_X, mds_sol, grid_eq, grid_X, grid_sol, eq_1, eq_2, X, sol, vac, B_aligned, X_id, E_pot, E_kin, E_pot_int, E_kin_int)
 Calculate the energy terms in the energy decomposition. More...
 
integer function, public print_output_sol (grid, sol, data_name, rich_lvl, remove_previous_arrs)
 Print solution quantities to an output file: More...
 

Variables

logical, public debug_plot_sol_vec = .false.
 plot debug information for plot_sol_vec() More...
 
logical, public debug_calc_e = .false.
 plot debug information for calc_E() More...
 
logical, public debug_x_norm = .false.
 plot debug information X_norm More...
 
logical, public debug_du = .false.
 plot debug information for calculation of DU More...
 

Detailed Description

Operations on the solution vectors such as decompososing the energy, etc...

Function/Subroutine Documentation

◆ calc_e()

integer function sol_ops::calc_e ( type(modes_type), intent(in)  mds_X,
type(modes_type), intent(in)  mds_sol,
type(grid_type), intent(in)  grid_eq,
type(grid_type), intent(in)  grid_X,
type(grid_type), intent(in)  grid_sol,
type(eq_1_type), intent(in)  eq_1,
type(eq_2_type), intent(in)  eq_2,
type(x_1_type), intent(in)  X,
type(sol_type), intent(in)  sol,
type(vac_type), intent(in)  vac,
logical, intent(in)  B_aligned,
integer, intent(in)  X_id,
complex(dp), dimension(:,:,:,:), intent(inout), allocatable  E_pot,
complex(dp), dimension(:,:,:,:), intent(inout), allocatable  E_kin,
complex(dp), dimension(7), intent(inout)  E_pot_int,
complex(dp), dimension(2), intent(inout)  E_kin_int 
)

Calculate the energy terms in the energy decomposition.

Note
see explanation of routine in decompose_energy().
Returns
ierr
Parameters
[in]mds_xgeneral modes variables in perturbation grid
[in]mds_solgeneral modes variables in solution grid
[in]grid_eqequilibrium grid
[in]grid_xperturbation grid
[in]grid_soland solution grid
[in]eq_1flux equilibrium
[in]eq_2metric equilibrium
[in]xperturbation variables
[in]solsolution variables
[in]vacvacuum variables
[in]b_alignedwhether grid is field-aligned
[in]x_idnr. of Eigenvalue
[in,out]e_potpotential energy
[in,out]e_kinkinetic energy
[in,out]e_pot_intintegrated potential energy
[in,out]e_kin_intintegrated kinetic energy

Definition at line 1205 of file sol_ops.f90.

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

◆ decompose_energy()

integer function, public sol_ops::decompose_energy ( type(modes_type), intent(in)  mds_X,
type(modes_type), intent(in)  mds_sol,
type(grid_type), intent(in)  grid_eq,
type(grid_type), intent(in)  grid_X,
type(grid_type), intent(in)  grid_sol,
type(eq_1_type), intent(in)  eq_1,
type(eq_2_type), intent(in)  eq_2,
type(x_1_type), intent(in)  X,
type(sol_type), intent(in)  sol,
type(vac_type), intent(in)  vac,
integer, intent(in)  X_id,
logical, intent(in)  B_aligned,
real(dp), dimension(:,:,:,:), intent(in), optional  XYZ,
complex(dp), dimension(7), intent(inout), optional  E_pot_int,
complex(dp), dimension(2), intent(inout), optional  E_kin_int 
)

Decomposes the plasma potential and kinetic energy in its individual terms for an individual Eigenvalue.

Use is made of variables representing the potential and kinetic energy [17].

  • \(E_\text{pot}\):
    • normal line bending term: \(\frac{1}{\mu_0} \frac{Q_n^2}{h^{22}}\),
    • geodesic line bending term: \(\frac{1}{\mu_0} \mathcal{J}^2 \frac{h^{22}}{g_{33}} Q_g^2\),
    • normal ballooning term: \(-2 p' X^2 \kappa_n\),
    • geodesic ballooning term: \(-2 p' X U^* \kappa_g\),
    • normal kink term: \(-\sigma X^*Q_g\),
    • geodesic kink term: \(\sigma U^*Q_n\),
  • \(E_\text{kin}\):
    • normal kinetic term: \(\rho \frac{X^2}{h^{22}}\),
    • geodesic kinetic term: \(\rho \mathcal{J}^2 \frac{h^{22}}{g_{33}} U^2\).

The energy terms are calculated normally on the sol grid, interpolating the quantities defined on the eq grid, and angularly in the eq grid.

Optionally, the results can be plotted by providing X, Y and Z. By default, they are instead written to an output file.

Also, the fraction between potential and kinetic energy can be returned, compared with the eigenvalue.

Returns
ierr
Parameters
[in]mds_xgeneral modes variables in pertubation grid
[in]mds_solgeneral modes variables in solution grid
[in]grid_eqequilibrium grid
[in]grid_xperturbation grid
[in]grid_solsolution grid
[in]eq_1flux equilibrium
[in]eq_2metric equilibrium
[in]xperturbation variables
[in]solsolution variables
[in]vacvacuum variables
[in]x_idnr. of Eigenvalue
[in]b_alignedwhether grid is field-aligned
[in]xyzX, Y and Z for plotting
[in,out]e_pot_intintegrated potential energy
[in,out]e_kin_intintegrated kinetic energy

Definition at line 991 of file sol_ops.f90.

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

◆ plot_harmonics()

integer function, public sol_ops::plot_harmonics ( type(modes_type), intent(in)  mds,
type(grid_type), intent(in)  grid_sol,
type(sol_type), intent(in)  sol,
integer, intent(in)  X_id,
real(dp), dimension(:,:), intent(in)  res_surf 
)

Plots the harmonics and their maximum in 2-D.

Returns
ierr
Parameters
[in]mdsgeneral modes variables in solution grid
[in]grid_solsolution grid
[in]solsolution variables
[in]x_idnr. of Eigenvalue (for output name)
[in]res_surfresonant surfaces

Definition at line 646 of file sol_ops.f90.

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

◆ plot_sol_vals()

subroutine, public sol_ops::plot_sol_vals ( type(sol_type), intent(in)  sol,
integer, intent(in)  last_unstable_id 
)

Plots Eigenvalues.

Parameters
[in]solsolution variables
[in]last_unstable_idindex of last unstable EV

Definition at line 37 of file sol_ops.f90.

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

◆ plot_sol_vec()

integer function, public sol_ops::plot_sol_vec ( type(modes_type), intent(in)  mds_X,
type(modes_type), intent(in)  mds_sol,
type(grid_type), intent(in)  grid_eq,
type(grid_type), intent(in)  grid_X,
type(grid_type), intent(in)  grid_sol,
type(eq_1_type), intent(in)  eq_1,
type(eq_2_type), intent(in)  eq_2,
type(x_1_type), intent(in)  X,
type(sol_type), intent(in)  sol,
real(dp), dimension(:,:,:,:), intent(in)  XYZ,
integer, intent(in)  X_id,
logical, dimension(2), intent(in)  plot_var 
)

Plots Eigenvectors.

This is done using the angular part of the the provided equilibrium grid and the normal part of the provided solution grid.

The perturbation grid is assumed to have the same angular coordinates as the equilibrium grid, and the normal coordinates correspond to either the equilibrium grid (X_grid_style 1), the solution grid (X_grid_style 2) or the enriched equilibrium grid (X_grid_style 3).

The output grid, furthermore, has the angular part corresponding to the equilibrium grid, and the normal part to the solution grid.

Note
The normalization factors are taken into account and the output is transformed back to unnormalized values:

\[\begin{aligned} \vec{\xi} &\sim \frac{X_0}{R_0 B_0} \ , \\ \vec{Q} &\sim \frac{X_0}{R_0^2} \ , \\ \end{aligned}\]

which translates to

\[\begin{aligned} X &\sim X_0 \ , \\ U &\sim \frac{X_0}{R_0^2 B_0} \ , \\ Qn &\sim \frac{X_0 B_0}{R_0} \ , \\ Qg &\sim \frac{X_0}{R_0^3} \ , \end{aligned}\]

where \(X_0\) is not determined but is common to all factors.

Returns
ierr
Parameters
[in]mds_xgeneral modes variables in perturbation grid
[in]mds_solgeneral modes variables in solution grid
[in]grid_eqequilibrium grid
[in]grid_xperturbation grid
[in]grid_solsolution grid
[in]eq_1flux equilibrium
[in]eq_2metric equilibrium
[in]xperturbation variables
[in]solsolution variables
[in]xyzX, Y and Z of extended eq_grid
[in]x_idnr. of Eigenvalue (for output name)
[in]plot_varwhether variables are plotted (1: plasma perturbation, 2: magnetic perturbation)

Definition at line 116 of file sol_ops.f90.

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

◆ print_output_sol()

integer function, public sol_ops::print_output_sol ( type(grid_type), intent(in)  grid,
type(sol_type), intent(in)  sol,
character(len=*), intent(in)  data_name,
integer, intent(in), optional  rich_lvl,
logical, intent(in), optional  remove_previous_arrs 
)

Print solution quantities to an output file:

  • sol:
    • val
    • vec

If rich_lvl is provided, "_[R_rich_lvl]" is appended to the data name if it is >0.

Returns
ierr
Parameters
[in]gridsolution grid variables
[in]solsolution variables
[in]data_namename under which to store
[in]rich_lvlRichardson level to print
[in]remove_previous_arrsremove previous variables if present

Definition at line 1566 of file sol_ops.f90.

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

Variable Documentation

◆ debug_calc_e

logical, public sol_ops::debug_calc_e = .false.

plot debug information for calc_E()

Note
Debug version only

Definition at line 29 of file sol_ops.f90.

◆ debug_du

logical, public sol_ops::debug_du = .false.

plot debug information for calculation of DU

Note
Debug version only

Definition at line 31 of file sol_ops.f90.

◆ debug_plot_sol_vec

logical, public sol_ops::debug_plot_sol_vec = .false.

plot debug information for plot_sol_vec()

Note
Debug version only

Definition at line 27 of file sol_ops.f90.

◆ debug_x_norm

logical, public sol_ops::debug_x_norm = .false.

plot debug information X_norm

Note
Debug version only

Definition at line 30 of file sol_ops.f90.