pyoculus 0.1.1
Loading...
Searching...
No Matches
specpjh Module Reference

Fortran module for SPEC Pressure Jump Hamiltonian problems. More...

Functions/Subroutines

subroutine, public get_pjhfield (phi, ptt, dptt)
 Compute the ODEs for PJH system, \(dp_\theta/d\varphi\), \(d\theta/d\varphi\).
 
subroutine, public get_pjhfield_tangent (phi, ptt, dptt)
 Compute the ODEs for PJH system, \(dp_\theta/d\varphi\), \(d\theta/d\varphi\), with tangent.
 
subroutine, public get_covariant_field (theta, phi, bco)
 Get the covariant component of known side of magnetic field \(\bf B_1\), i.e. \(B_{1,\theta}, B_{1,\varphi}\). Can be used to estimate the initial condition for \(p_\theta\).
 
subroutine, public get_b2_interface (db2, ioi, theta, phi, guvij, sg, ideriv)
 An internal subroutine that computes the squared magnetic field strength on the interface \(B_1^2\) and its first and second \(\theta\) derivatives. This is a private subroutine that is not interfaced with Python.
 
subroutine, public init_pjh (dp, inside_or_outside, plus_or_minus)
 Initialize the PJH system. Whenever \(\delta p\) is modified, you will need to call this subroutine (in Python interface) again.
 
subroutine, public destroy_pjh ()
 This subroutine frees the memory space allocated by specpjh::init_pjh.
 

Detailed Description

Fortran module for SPEC Pressure Jump Hamiltonian problems.

Author
Stuart Hudson (shuds.nosp@m.on@p.nosp@m.ppl.g.nosp@m.ov)
Adapted by Zhisong Qu (zhiso.nosp@m.ng.q.nosp@m.u@anu.nosp@m..edu.nosp@m..au)

Interfaced to Python, see pyoculus.problems.SPECPJH.SPECPJH

Todo
non-stellarator symmetric cases

Pressure Jump Hamiltonian (PJH) Fortran module

Please note that in the Python module pyoculus.problems.SPECPJH.SPECPJH, \(\zeta\) is equivalent to \(\varphi\)

Usage in Python:

To use the pjh module, one needs to initialize the fortran module first in Python (using class pyoculus.problems.SPECProblem or classes derived from it), then initialize pjh in Python by calling its Python wrap in pyoculus.problems.SPECfortran.fortran_module

init_pjh(dp, inside_or_outside, plus_or_minus)
Parameters
dp\(\delta p\), the pressure jump
inside_or_outsidefor the specified volume, we compute things on the inner interface or outer
plus_or_minuswhether to take the plus or minus sign in computing \(p_\varphi\)

After initialization, one can call

rhs = get_pjhfield(phi, ptt)

or for rhs and tangent,

rhs = get_pjhfield_tangent(phi, ptt)
Parameters
phithe \(\varphi\) angle
pttthe state vector ( \(p_\theta\), \(\theta\)), or ( \(p_\theta\), \(\theta\), dp1, dt1, dp2, dt2)
Returns
array of size 2 (for get_pjhfield) or array of size 6 (for get_pjhfield_tangent)

To estimate the initial value for \(p_\theta\), sometimes we need \(B_\theta\) on the known side of the interface. This can be obtained by calling

(Btheta, Bphi) = get_covariant_field(theta, phi)
Parameters
theta\(\theta\)
phi\(\varphi\)
Returns
the covariant component on the known side of the interface, \((B_{1,\theta}, B_{1,\varphi})\)

Function/Subroutine Documentation

◆ destroy_pjh()

subroutine, public specpjh::destroy_pjh

This subroutine frees the memory space allocated by specpjh::init_pjh.

◆ get_b2_interface()

subroutine, public specpjh::get_b2_interface ( real(kind=real_kind), dimension(0:2), intent(out) db2,
integer, intent(in) ioi,
real(kind=real_kind), intent(in) theta,
real(kind=real_kind), intent(in) phi,
real(kind=real_kind), dimension(3,3,0:2), intent(in) guvij,
real(kind=real_kind), dimension(0:2), intent(in) sg,
integer, intent(in) ideriv )

An internal subroutine that computes the squared magnetic field strength on the interface \(B_1^2\) and its first and second \(\theta\) derivatives. This is a private subroutine that is not interfaced with Python.

◆ get_covariant_field()

subroutine, public specpjh::get_covariant_field ( real(kind=real_kind), intent(in) theta,
real(kind=real_kind), intent(in) phi,
real(kind=real_kind), dimension(2), intent(out) bco )

Get the covariant component of known side of magnetic field \(\bf B_1\), i.e. \(B_{1,\theta}, B_{1,\varphi}\). Can be used to estimate the initial condition for \(p_\theta\).

Parameters
[in]thetathe \(\theta\) angle
[in]phithe \(\phi\) angle
[out]bcothe covariant components ( \(B_{1,\theta}, B_{1,\varphi}\))

◆ get_pjhfield()

subroutine, public specpjh::get_pjhfield ( real(kind=real_kind), intent(in) phi,
real(kind=real_kind), dimension(2), intent(in) ptt,
real(kind=real_kind), dimension(2), intent(out) dptt )

Compute the ODEs for PJH system, \(dp_\theta/d\varphi\), \(d\theta/d\varphi\).

Parameters
[in]phithe \(\varphi\) angle
[in]ptt( \(p_\theta\), \(\theta\))
[out]dptt( \(dp_\theta/d\varphi\), \(d\theta/d\varphi\))
  • We need the metrics \(g_{\theta \theta}, g_{\theta \varphi}, g_{\varphi \varphi}\) and the Jacobian \(J\), as well as their first \(\theta\) derivatives by calling the subroutine coords::get_metric_interface
  • Compute \( G \) and its derivatives.
  • Compute the squared magnetic field strength \(B_1^2\) on the other side of the interface by calling the subroutine specpjh::get_b2_interface
  • Construct \(a, b, c\) for the quadratic equation for solving \(p_\varphi\), then solve it by applying plus_or_minus sign we specified earlier (stored in dP)
  • Computes \(b_2\)
  • Construct the denominator of \(d\theta/d\varphi\)
  • Construct the numerators
  • Get right hand side

◆ get_pjhfield_tangent()

subroutine, public specpjh::get_pjhfield_tangent ( real(kind=real_kind), intent(in) phi,
real(kind=real_kind), dimension(6), intent(in) ptt,
real(kind=real_kind), dimension(6), intent(out) dptt )

Compute the ODEs for PJH system, \(dp_\theta/d\varphi\), \(d\theta/d\varphi\), with tangent.

Parameters
[in]phithe \(\varphi\) angle
[in]ptt( \(p_\theta\), \(\theta\), \(\Delta p_{\theta,1}\), \(\Delta \theta_1\), \(\Delta p_{\theta,2}\), \(\Delta \theta_2\))
[out]dptt( \(dp_\theta/d\varphi\), \(d\theta/d\varphi\))
  • We need the metrics \(g_{\theta \theta}, g_{\theta \varphi}, g_{\varphi \varphi}\) and the Jacobian \(J\), as well as their first \(\theta\) derivatives by calling the subroutine coords::get_metric_interface
  • Compute \( G \) and its derivatives.
  • Compute the squared magnetic field strength \(B_1^2\) on the other side of the interface by calling the subroutine specpjh::get_b2_interface
  • Construct \(a, b, c\) for the quadratic equation for solving \(p_\varphi\), then solve it by applying plus_or_minus sign we specified earlier (stored in dP)
  • Computes \(b_2\)
  • Construct the denominator of \(d\theta/d\varphi\)
  • Construct the numerators
  • Get right hand side

◆ init_pjh()

subroutine, public specpjh::init_pjh ( real(kind=real_kind), intent(in) dp,
integer, intent(in) inside_or_outside,
integer, intent(in) plus_or_minus )

Initialize the PJH system. Whenever \(\delta p\) is modified, you will need to call this subroutine (in Python interface) again.

Parameters
[in]dpthe pressure jump \(\delta p\)
[in]inside_or_outside0 for inside interface of the selected volume ivol (set in SPECvariables::ivol), +1 for outside
[in]plus_or_minusset the sign (-1 or +1) for computing \(p_\varphi\) using the quadratic root equation.

The contravariant component of \(\bf B_1\) is computed on the interface. The Fourier components of \( J B^{\theta}_1\) and \( J B^{\varphi}_1\) are stored for further use.