SPEC 3.20
Stepped Pressure Equilibrium Code
|
Functions/Subroutines | |
subroutine | bfield (zeta, st, Bst) |
Compute the magnetic field. More... | |
subroutine | hesian (NGdof, position, Mvol, mn, LGdof) |
Computes eigenvalues and eigenvectors of derivative matrix, \(\nabla_{\bf xi}{\bf F}\). More... | |
subroutine | jo00aa (lvol, Ntz, lquad, mn) |
Measures error in Beltrami equation, \(\nabla \times {\bf B} - \mu {\bf B}\). More... | |
subroutine | pp00aa |
Constructs Poincaré plot and "approximate" rotational-transform (driver). More... | |
subroutine | pp00ab (lvol, sti, Nz, nPpts, poincaredata, fittedtransform, utflag) |
Constructs Poincaré plot and "approximate" rotational-transform (for single field line). More... | |
subroutine | stzxyz (lvol, stz, RpZ) |
Calculates coordinates, \({\bf x}(s,\theta,\zeta) \equiv R \, {\bf e}_R + Z \, {\bf e}_Z\), and metrics, at given \((s,\theta,\zeta)\). More... | |
subroutine bfield | ( | real, intent(in) | zeta, |
real, dimension(1:node), intent(in) | st, | ||
real, dimension(1:node), intent(out) | Bst | ||
) |
Compute the magnetic field.
Returns the magnetic field field line equations, \( d{\bf x}/d\phi = {\bf B}/B^\phi \) .
Equations of field line flow
\begin{equation} \dot s \equiv \frac{B^s }{B^\zeta}, \qquad \dot \theta \equiv \frac{B^\theta}{B^\zeta}. \label{eq:stdot_bfield} \end{equation}
Representation of magnetic field
\begin{eqnarray} A_\theta(s,\theta,\zeta) &=& \sum_{i,l} {\color{red} A_{\theta,e,i,l}} \; {\overline T}_{l,i}(s) \cos\alpha_i + \sum_{i,l} {\color{Orange} A_{\theta,o,i,l}} \; {\overline T}_{l,i}(s) \sin\alpha_i, \label{eq:At_bfield} \\ A_\zeta( s,\theta,\zeta) &=& \sum_{i,l} {\color{blue} A_{\zeta, e,i,l}} \; {\overline T}_{l,i}(s) \cos\alpha_i + \sum_{i,l} {\color{Cerulean}A_{\zeta ,o,i,l}} \; {\overline T}_{l,i}(s) \sin\alpha_i, \label{eq:Az_bfield} \end{eqnarray}
where \({\overline T}_{l,i}(s) \equiv \bar s^{m_i/2} \, T_l(s)\), \(T_l(s)\) is the Chebyshev polynomial, and \(\alpha_j \equiv m_j\theta-n_j\zeta\). The regularity factor, \(\bar s^{m_i/2}\), where \(\bar s \equiv (1+s)/2\), is only included if there is a coordinate singularity in the domain (i.e. only in the innermost volume, and only in cylindrical and toroidal geometry.)\begin{eqnarray} \begin{array}{ccccrcrcrcrcccccccccccccccccccccccccccccccccccccccccccccccccccc} \sqrt g \, {\bf B} & = & {\bf e}_s & \sum_{i,l} [ ( & - m_i {\color{blue} A_{\zeta, e,i,l}} & - & n_i {\color{red} A_{\theta,e,i,l}} & ) {\overline T}_{l,i} \sin\alpha_i + ( & + m_i {\color{Cerulean}A_{\zeta ,o,i,l}} & + & n_i {\color{Orange} A_{\theta,o,i,l}} & ) {\overline T}_{l,i} \cos\alpha_i ] \\ & + & {\bf e}_\theta & \sum_{i,l} [ ( & & - & {\color{blue} A_{\zeta, e,i,l}} & ) {\overline T}_{l,i}^\prime \cos\alpha_i + ( & & - & {\color{Cerulean}A_{\zeta ,o,i,l}} & ) {\overline T}_{l,i}^\prime \sin\alpha_i ] \\ & + & {\bf e}_\zeta & \sum_{i,l} [ ( & {\color{red} A_{\theta,e,i,l}} & & & ) {\overline T}_{l,i}^\prime \cos\alpha_i + ( & {\color{Orange} A_{\theta,o,i,l}} & & & ) {\overline T}_{l,i}^\prime \sin\alpha_i ] \end{array} \end{eqnarray}
IT IS REQUIRED TO SET IVOL THROUGH GLOBAL MEMORY BEFORE CALLING BFIELD.
The format of this subroutine is constrained by the NAG ode integration routines.
[in] | zeta | toroidal angle \( \zeta \) |
[in] | st | radial coordinate \(s\) and poloidal angle \(\theta\) |
[out] | Bst | tangential magnetic field directions \(B_s, B_\theta\) |
References allglobal::ate, allglobal::ato, allglobal::aze, allglobal::azo, bfield(), allglobal::cpus, allglobal::gbzeta, get_cheby(), get_zernike(), constants::half, allglobal::halfmm, allglobal::im, allglobal::in, allglobal::ivol, allglobal::lcoordinatesingularity, inputlist::lrad, allglobal::mn, allglobal::mpi_comm_spec, inputlist::mpol, allglobal::myid, allglobal::ncpu, allglobal::node, allglobal::notstellsym, constants::one, fileunits::ounit, allglobal::regumm, numerical::small, constants::two, numerical::vsmall, inputlist::wmacros, and constants::zero.
Referenced by bfield(), bfield_tangent(), jo00aa(), pp00ab(), and sphdf5::write_grid().
subroutine hesian | ( | integer, intent(in) | NGdof, |
real, dimension(0:ngdof) | position, | ||
integer, intent(in) | Mvol, | ||
integer, intent(in) | mn, | ||
integer, intent(in) | LGdof | ||
) |
Computes eigenvalues and eigenvectors of derivative matrix, \(\nabla_{\bf xi}{\bf F}\).
[in] | NGdof | number of global degrees of freedom |
[in,out] | position | internal geometrical degrees of freedom |
[in] | Mvol | total number of volumes in computation |
[in] | mn | number of Fourier harmonics |
[in] | LGdof | what is this? |
construction of Hessian matrix
Igeometry==3
then also the derivatives of the "artificial" spectral constraints, \(I_j \equiv (R_\theta X + Z_\theta Y)_j\). Lconstraint
determines how the enclosed fluxes, \(\Delta \psi_t\) and \(\Delta \psi_p\), and the helicity multiplier, \(\mu\), vary as the geometry is varied; see global.f90 and mp00ac() for more details. construction of eigenvalues and eigenvectors
LHevalues==T
then the eigenvalues of the Hessian are computed using the NAG routine F02EBF
. LHevectors==T
then the eigenvalues and the eigenvectors of the Hessian are computed. Igeometry==3
, then the derivative-matrix also contains information regarding how the "artificial" spectral constraints vary with geometry; so, the eigenvalues and eigenvectors are not purely "physical". The eigenvalues and eigenvectors (if required) are written to the file .ext.GF.ev as follows:
evecr
, eveci
, as described by the NAG documentation for F02EBF
. References allglobal::cpus, allglobal::dbbdmp, allglobal::dbbdrz, allglobal::denergydrr, allglobal::denergydrz, allglobal::denergydzr, allglobal::denergydzz, allglobal::dessian, allglobal::dessian2d, allglobal::dffdrz, dforce(), allglobal::dmupfdx, inputlist::dpp, inputlist::dqq, allglobal::drbc, allglobal::drbs, allglobal::dzbc, allglobal::dzbs, allglobal::energy, constants::half, allglobal::hdffdrz, inputlist::helicity, hesian(), allglobal::hessian, allglobal::hessian2d, fileunits::hunit, inputlist::igeometry, allglobal::im, allglobal::in, allglobal::irbc, allglobal::irbs, allglobal::izbc, allglobal::izbs, allglobal::lbbintegral, inputlist::lcheck, inputlist::lfindzero, inputlist::lfreebound, allglobal::lhessian2dallocated, allglobal::lhessian3dallocated, allglobal::lhessianallocated, inputlist::lhevalues, inputlist::lhevectors, inputlist::lhmatrix, allglobal::localconstraint, inputlist::lperturbed, allglobal::mpi_comm_spec, inputlist::mu, fileunits::munit, allglobal::myid, allglobal::ncpu, allglobal::notstellsym, inputlist::nvol, constants::one, fileunits::ounit, packxi(), inputlist::pflux, preset(), allglobal::psifactor, numerical::small, numerical::sqrtmachprec, constants::ten, constants::two, numerical::vsmall, inputlist::wmacros, allglobal::yesstellsym, and constants::zero.
Referenced by hesian(), and spec().
subroutine jo00aa | ( | integer, intent(in) | lvol, |
integer, intent(in) | Ntz, | ||
integer, intent(in) | lquad, | ||
integer, intent(in) | mn | ||
) |
Measures error in Beltrami equation, \(\nabla \times {\bf B} - \mu {\bf B}\).
This routine is called by xspech() as a post diagnostic and only if Lcheck==1
.
construction of current, \({\bf j} \equiv \nabla \times \nabla \times {\bf A}\)
\begin{eqnarray} A_\theta(s,\theta,\zeta) &=& \sum_{i,l} {\color{red} A_{\theta,e,i,l}} \; {\overline T}_{l,i}(s) \cos\alpha_i + \sum_{i,l} {\color{Orange} A_{\theta,o,i,l}} \; {\overline T}_{l,i}(s) \sin\alpha_i, \label{eq:At_jo00aa} \\ A_\zeta (s,\theta,\zeta) &=& \sum_{i,l} {\color{blue} A_{\zeta, e,i,l}} \; {\overline T}_{l,i}(s) \cos\alpha_i + \sum_{i,l} {\color{Cerulean}A_{\zeta ,o,i,l}} \; {\overline T}_{l,i}(s) \sin\alpha_i, \label{eq:Az_jo00aa} \end{eqnarray}
where \({\overline T}_{l,i}(s) \equiv \bar s^{m_i/2} \, T_l(s)\), \(T_l(s)\) is the Chebyshev polynomial, and \(\alpha_j \equiv m_j\theta-n_j\zeta\). The regularity factor, \(\bar s^{m_i/2}\), where \(\bar s \equiv (1+s)/2\), is only included if there is a coordinate singularity in the domain (i.e. only in the innermost volume, and only in cylindrical and toroidal geometry.)\begin{eqnarray} \begin{array}{ccccrcrcrcrcccccccccccccccccccccccccccccccccccccccccccccccccccc} \sqrt g \, {\bf B} & = & {\bf e}_s & \sum_{i,l} [ ( & - m_i {\color{blue} A_{\zeta, e,i,l}} & - & n_i {\color{red} A_{\theta,e,i,l}} & ) {\overline T}_{l,i} \sin\alpha_i + ( & + m_i {\color{Cerulean}A_{\zeta ,o,i,l}} & + & n_i {\color{Orange} A_{\theta,o,i,l}} & ) {\overline T}_{l,i} \cos\alpha_i ] \\ & + & {\bf e}_\theta & \sum_{i,l} [ ( & & - & {\color{blue} A_{\zeta, e,i,l}} & ) {\overline T}_{l,i}^\prime \cos\alpha_i + ( & & - & {\color{Cerulean}A_{\zeta ,o,i,l}} & ) {\overline T}_{l,i}^\prime \sin\alpha_i ] \\ & + & {\bf e}_\zeta & \sum_{i,l} [ ( & {\color{red} A_{\theta,e,i,l}} & & & ) {\overline T}_{l,i}^\prime \cos\alpha_i + ( & {\color{Orange} A_{\theta,o,i,l}} & & & ) {\overline T}_{l,i}^\prime \sin\alpha_i ] \end{array} \end{eqnarray}
\begin{eqnarray} \sqrt g \, {\bf j} = ( \partial_\theta B_\zeta - \partial_\zeta B_\theta) \; {\bf e}_s + ( \partial_\zeta B_s - \partial_s B_\zeta ) \; {\bf e}_\theta + ( \partial_s B_\theta - \partial_\theta B_s ) \; {\bf e}_\zeta , \end{eqnarray}
where (for computational convenience) the covariant components of \({\bf B}\) are computed as\begin{eqnarray} B_s & = & (\sqrt g B^s) \, g_{ss } / \sqrt g + (\sqrt g B^\theta) \, g_{s \theta} / \sqrt g + (\sqrt g B^\zeta) \, g_{s \zeta} / \sqrt g, \\ B_\theta & = & (\sqrt g B^s) \, g_{s\theta} / \sqrt g + (\sqrt g B^\theta) \, g_{\theta\theta} / \sqrt g + (\sqrt g B^\zeta) \, g_{\theta\zeta} / \sqrt g, \\ B_\zeta & = & (\sqrt g B^s) \, g_{s\zeta } / \sqrt g + (\sqrt g B^\theta) \, g_{\theta\zeta } / \sqrt g + (\sqrt g B^\zeta) \, g_{\zeta \zeta} / \sqrt g. \end{eqnarray}
quantification of the error
\begin{eqnarray} ||\left( {\bf j}-\mu {\bf B}\right)\cdot\nabla s || & \equiv & \int \!\! ds \oint\!\!\!\oint \!d\theta d\zeta \,\,\, \left| \sqrt g \, {\bf j}\cdot\nabla s -\mu \; \sqrt g \, {\bf B} \cdot\nabla s \right|, \label{eq:Es_jo00aa} \\ ||\left( {\bf j}-\mu {\bf B}\right)\cdot\nabla \theta || & \equiv & \int \!\! ds \oint\!\!\!\oint \!d\theta d\zeta \,\,\, \left| \sqrt g \, {\bf j}\cdot\nabla \theta-\mu \; \sqrt g \, {\bf B} \cdot\nabla \theta \right|, \label{eq:Et_jo00aa} \\ ||\left( {\bf j}-\mu {\bf B}\right)\cdot\nabla \zeta || & \equiv & \int \!\! ds \oint\!\!\!\oint \!d\theta d\zeta \,\,\, \left| \sqrt g \, {\bf j}\cdot\nabla \zeta -\mu \; \sqrt g \, {\bf B} \cdot\nabla \zeta \right|. \label{eq:Ez_jo00aa} \end{eqnarray}
comments
[in] | lvol | in which volume should the Beltrami error be computed |
[in] | Ntz | number of grid points in \(\theta\) and \(\zeta\) |
[in] | lquad | degree of Gaussian quadrature |
[in] | mn | number of Fourier harmonics |
details of the numerics
The integration over \(s\) is performed using Gaussian integration, e.g., \(\displaystyle \int \!\! f(s) ds \approx \sum_k \omega_k f(s_k)\); with the abscissae, \(s_k\), and the weights, \(\omega_k\), for \(k=1,\) Iquad
\(_v\), determined by CDGQF
. The resolution, N
\( \equiv \) Iquad
\(_v\), is determined by Nquad
(see global.f90 and preset() ). A fatal error is enforced by jo00aa() if CDGQF
returns an ifail
\(\ne 0\).
Inside the Gaussian quadrature loop, i.e. for each \(s_k\),
The metric elements, \(g_{\mu,\nu} \equiv \) gij(1:6,0,1:Ntz)
, and the Jacobian, \(\sqrt g \equiv \) sg(0,1:Ntz)
, are calculated on a regular angular grid, \((\theta_i,\zeta_j)\), in coords(). The derivatives \(\partial_i g_{\mu,\nu} \equiv\) gij(1:6,i,1:Ntz)
and \(\partial_i \sqrt g \equiv \) sg(i,1:Ntz)
, with respect to \( i \in \{ s,\theta,\zeta \}\) are also returned.
The Fourier components of the vector potential given in Eqn. \((\ref{eq:At_jo00aa})\) and Eqn. \((\ref{eq:Az_jo00aa})\), and their first and second radial derivatives, are summed.
The quantities \(\sqrt g B^s\), \(\sqrt g B^\theta\) and \(\sqrt g B^\zeta\), and their first and second derivatives with respect to \((s,\theta,\zeta)\), are computed on the regular angular grid (using FFTs).
\begin{eqnarray} \sqrt g j^s & = & \sum_u \left[ \partial_\theta (\sqrt g B^u) \; g_{u,\zeta } + (\sqrt g B^u) \; \partial_\theta g_{u,\zeta } - (\sqrt g B^u) g_{u,\zeta } \; \partial_\theta \sqrt g / \sqrt g \right] / \sqrt g \nonumber \\ & - & \sum_u \left[ \partial_\zeta (\sqrt g B^u) \; g_{u,\theta} + (\sqrt g B^u) \; \partial_\zeta g_{u,\theta} - (\sqrt g B^u) g_{u,\theta} \; \partial_\zeta \sqrt g / \sqrt g \right] / \sqrt g, \\ \sqrt g j^\theta & = & \sum_u \left[ \partial_\zeta (\sqrt g B^u) \; g_{u,s } + (\sqrt g B^u) \; \partial_\zeta g_{u,s } - (\sqrt g B^u) g_{u,s } \; \partial_\zeta \sqrt g / \sqrt g \right] / \sqrt g \nonumber \\ & - & \sum_u \left[ \partial_s (\sqrt g B^u) \; g_{u,\zeta } + (\sqrt g B^u) \; \partial_s g_{u,\zeta } - (\sqrt g B^u) g_{u,\zeta } \; \partial_s \sqrt g / \sqrt g \right] / \sqrt g, \\ \sqrt g j^\zeta & = & \sum_u \left[ \partial_s (\sqrt g B^u) \; g_{u,\theta} + (\sqrt g B^u) \; \partial_s g_{u,\theta} - (\sqrt g B^u) g_{u,\theta} \; \partial_s \sqrt g / \sqrt g \right] / \sqrt g \nonumber \\ & - & \sum_u \left[ \partial_\theta (\sqrt g B^u) \; g_{u,s } + (\sqrt g B^u) \; \partial_\theta g_{u,s } - (\sqrt g B^u) g_{u,s } \; \partial_\theta \sqrt g / \sqrt g \right] / \sqrt g. \end{eqnarray}
The error is stored into an array called beltramierror
which is then written to the HDF5 file in hdfint().
References allglobal::ate, allglobal::ato, allglobal::aze, allglobal::azo, allglobal::beltramierror, bfield(), allglobal::cfmn, allglobal::cheby, coords(), allglobal::cpus, allglobal::dpflux, allglobal::dtflux, allglobal::efmn, allglobal::gbzeta, get_cheby_d2(), get_zernike_d2(), allglobal::guvij, constants::half, inputlist::igeometry, allglobal::im, allglobal::in, allglobal::ivol, jo00aa(), allglobal::lcoordinatesingularity, inputlist::lerrortype, inputlist::lrad, allglobal::mpi_comm_spec, inputlist::mpol, inputlist::mu, allglobal::myid, inputlist::nfp, allglobal::node, allglobal::notstellsym, allglobal::nt, inputlist::nvol, allglobal::nz, allglobal::ofmn, constants::one, fileunits::ounit, constants::pi2, allglobal::regumm, allglobal::rij, allglobal::rtt, allglobal::sfmn, allglobal::sg, allglobal::tt, constants::two, inputlist::wmacros, allglobal::zernike, constants::zero, and allglobal::zij.
Referenced by final_diagnostics(), and jo00aa().
subroutine pp00aa |
Constructs Poincaré plot and "approximate" rotational-transform (driver).
relevant input variables
nPtraj
trajectories will be located in each volume; nPpts
iterations per trajectory; odetol
o.d.e. integration tolerance; format of output: Poincaré
The Poincaré data is written to .ext.poincare:xxxx , where
xxxx
is an integer indicating the volume. The format of this file is as follows:
where
data(1,k,j)
is the poloidal angle, data(2,k,j)
is the radial coordinate, data(3,k,j)
is the cylindrical \(R\), data(4,k,j)
is the cylindrical \(Z\), k=0
,Nz-1 labels toroidal planes, so that \(\phi = ( 2 \pi / \texttt{Nfp}) ( k / \texttt{Nz})\), j=1
,nPpts labels toroidal iterations. lvol
is given by \(N+1\), where the radial resolution, \(N\equiv\,\)Ni(lvol)
, is given on input. This will be over-ruled by if nPtrj(lvol)
, given on input, is non-negative. format of output: rotational-transform
.ext.transform:xxxx , where xxxx
is an integer indicating the volume. The format of this file is as follows: References allglobal::cpus, allglobal::diotadxup, sphdf5::finalize_flt_output(), constants::half, inputlist::igeometry, sphdf5::init_flt_output(), inputlist::iota, allglobal::ivol, inputlist::lconstraint, allglobal::lcoordinatesingularity, allglobal::lmns, allglobal::lplasmaregion, inputlist::lrad, allglobal::lvacuumregion, allglobal::mpi_comm_spec, allglobal::myid, allglobal::ncpu, inputlist::nppts, inputlist::nptrj, inputlist::nvol, allglobal::nz, inputlist::odetol, inputlist::oita, constants::one, fileunits::ounit, constants::pi, pp00aa(), pp00ab(), inputlist::ppts, constants::two, inputlist::wmacros, sphdf5::write_poincare(), sphdf5::write_transform(), and constants::zero.
Referenced by final_diagnostics(), and pp00aa().
subroutine pp00ab | ( | integer, intent(in) | lvol, |
real, dimension(1:2) | sti, | ||
integer, intent(in) | Nz, | ||
integer, intent(in) | nPpts, | ||
real, dimension(1:4,0:nz-1,1:nppts) | poincaredata, | ||
real, dimension(1:2) | fittedtransform, | ||
integer, intent(out) | utflag | ||
) |
Constructs Poincaré plot and "approximate" rotational-transform (for single field line).
relevant input variables
nPpts
iterations per trajectory; odetol
o.d.e. integration tolerance; rotational-transform
[in] | lvol | |
sti | ||
[in] | Nz | |
[in] | nPpts | |
poincaredata | ||
fittedtransform | ||
[out] | utflag |
References bfield(), allglobal::cpus, allglobal::ivol, allglobal::mpi_comm_spec, allglobal::myid, allglobal::ncpu, allglobal::node, inputlist::nvol, inputlist::odetol, constants::one, fileunits::ounit, constants::pi2, pp00ab(), numerical::small, stzxyz(), constants::two, volume(), and constants::zero.
Referenced by pp00aa(), and pp00ab().
subroutine stzxyz | ( | integer, intent(in) | lvol, |
real, dimension(1:3), intent(in) | stz, | ||
real, dimension(1:3), intent(out) | RpZ | ||
) |
Calculates coordinates, \({\bf x}(s,\theta,\zeta) \equiv R \, {\bf e}_R + Z \, {\bf e}_Z\), and metrics, at given \((s,\theta,\zeta)\).
[in] | lvol | |
[in] | stz | |
[out] | RpZ |
References allglobal::cpus, constants::half, allglobal::halfmm, inputlist::igeometry, allglobal::im, allglobal::in, allglobal::irbc, allglobal::irbs, allglobal::izbc, allglobal::izbs, allglobal::lcoordinatesingularity, allglobal::mn, allglobal::mpi_comm_spec, allglobal::myid, allglobal::notstellsym, inputlist::ntor, inputlist::nvol, constants::one, fileunits::ounit, stzxyz(), numerical::vsmall, and constants::zero.
Referenced by pp00ab(), and stzxyz().