SPEC 3.20
Stepped Pressure Equilibrium Code
"global" force

Functions/Subroutines

subroutine dforce (NGdof, position, force, LComputeDerivatives, LComputeAxis)
 Calculates \({\bf F}({\bf x})\), where \({\bf x} \equiv \{\mbox{geometry}\} \equiv \{ R_{i,v}, Z_{i,v}\}\) and \({\bf F}\equiv[[p+B^2/2]] + \{\mbox{spectral constraints}\} \), and \(\nabla {\bf F}\). More...
 

Detailed Description

Function/Subroutine Documentation

◆ dforce()

subroutine dforce ( integer, intent(in)  NGdof,
real, dimension(0:ngdof), intent(in)  position,
real, dimension(0:ngdof), intent(out)  force,
logical, intent(in)  LComputeDerivatives,
logical  LComputeAxis 
)

Calculates \({\bf F}({\bf x})\), where \({\bf x} \equiv \{\mbox{geometry}\} \equiv \{ R_{i,v}, Z_{i,v}\}\) and \({\bf F}\equiv[[p+B^2/2]] + \{\mbox{spectral constraints}\} \), and \(\nabla {\bf F}\).

unpacking

  • The geometrical degrees of freedom are represented as a vector, \({\bf x} \equiv \{ R_{i,v}, Z_{i,v}\}\), where \(i=1,\) mn labels the Fourier harmonic and \(v=1,\) Mvol \(-1\) is the interface label. This vector is "unpacked" using packxi(). (Note that packxi() also sets the coordinate axis, i.e. the \(R_{i,0}\) and \(Z_{i,0}\).)

Matrices computation

  • the volume-integrated metric arrays, DToocc, etc. are evaluated in each volume by calling ma00aa()
  • the energy and helicity matrices, dMA(0:NN,0:NN), dMB(0:NN,0:2), etc. are evaluated in each volume by calling matrix()

parallelization over volumes

Two different cases emerge: either a local constraint or a global constraint is considered. This condition is determined by the flag LocalConstraint.

  • Local constraint
    • In each volume, vvol=1,Mvol ,
      • the logical array ImagneticOK(vvol) is set to .false.
      • The MPI node associated to the volume calls dfp100(). This routine calls ma02aa() (and might iterate on mp00ac()) and computes the field solution in each volume consistent with the constraint.
      • The MPI node associated to the volume calls dfp200(). This computes \(p+B^2/2\) (and the spectral constraints if required) at the interfaces in each volumes, as well as the derivatives of the force-balance if LComputeDerivatives=1.
    • After the parallelization loop over the volumes, brcast() is called to broadcast the required information.
  • Global constraint
    The MPI node \(0\) minimizes the constraint with HYBRID1() by iterating on dfp100() until the field matches the constraint. Other MPI nodes enter the subroutine loop_dfp100(). In loop_dfp100(), each MPI node
    • calls dfp100(),
    • solves the field in its associated volumes,
    • communicates the field to the node \(0\) and
    • repeats this loop until the node \(0\) sends a flag iflag=5.

broadcasting

  • The required quantities are broadcast by brcast().

construction of force

  • The force vector, \({\bf F}({\bf x})\), is a combination of the pressure-imbalance Fourier harmonics, \([[p+B^2/2]]_{i,v}\), where \(i\) labels Fourier harmonic and \(v\) is the interface label:

    \begin{eqnarray} F_{i,v} \equiv \left[ ( p_{v+1}+B^2_{i,v+1}/2 ) - ( p_v + B^2_{i,v}/2 ) \right] \times \texttt{BBweight}_i, \end{eqnarray}

    where BBweight_i is defined in preset() ; and the spectral condensation constraints,

    \begin{eqnarray} F_{i,v} \equiv I_{i,v} \times \texttt{epsilon} + S_{i,v,1} \times \texttt{sweight}_v - S_{i,v+1,0} \times \texttt{sweight}_{v+1}, \end{eqnarray}

    where the spectral condensation constraints, \(I_{i,v}\), and the "star-like" poloidal angle constraints, \(S_{i,v,\pm 1}\), are calculated and defined in lforce() ; and the sweight \(_v\) are defined in preset(). All quantities local to a volume are computed in dfp200(), information is then broadcasted to the MPI node \(0\) in dforce() and the global force is evaluated.

construct derivatives of matrix equation

  • Matrix perturbation theory is used to compute the derivatives of the solution, i.e. the Beltrami fields, as the geometry of the interfaces changes:
Parameters
[in]NGdofnumber of global degrees of freedom
[in]positiondegrees-of-freedom = internal geometry (packed by packxi)
[out]forceoutput: Fourier harmonics of B_mn^2 and spectral constraint forces
[in]LComputeDerivativesindicates whether derivatives are to be calculated; 0: no derivatives, 1:
[in,out]LComputeAxis

References allglobal::ate, allglobal::ato, allglobal::aze, allglobal::azo, allglobal::bbe, allglobal::bbo, allglobal::bbweight, allglobal::bemn, allglobal::bomn, brcast(), allglobal::cpus, allglobal::dbbdmp, allglobal::dbdx, allglobal::denergydrr, allglobal::denergydrz, allglobal::denergydzr, allglobal::denergydzz, allglobal::dessian, allglobal::dessian2d, allglobal::dessian3d, allglobal::dffdrz, dforce(), dfp100(), dfp200(), allglobal::diotadxup, allglobal::ditgpdxtp, allglobal::dmupfdx, allglobal::dpflux, inputlist::drz, allglobal::dtflux, allglobal::energy, inputlist::epsilon, allglobal::forceerr, constants::half, allglobal::hdffdrz, allglobal::hessian, allglobal::hessian2d, allglobal::hessian3d, allglobal::iemn, inputlist::igeometry, allglobal::iie, allglobal::iio, allglobal::im, allglobal::imagneticok, allglobal::in, allglobal::iomn, allglobal::ipdtdpf, allglobal::iquad, allglobal::irbc, allglobal::irbs, allglobal::ismyvolume(), allglobal::ismyvolumevalue, allglobal::izbc, allglobal::izbs, allglobal::lbbintegral, inputlist::lcheck, inputlist::lconstraint, allglobal::lcoordinatesingularity, inputlist::lextrap, inputlist::lfreebound, allglobal::lgdof, allglobal::lhessian2dallocated, allglobal::lhessian3dallocated, allglobal::lhessianallocated, inputlist::lhmatrix, allglobal::localconstraint, numerical::logtolerance, allglobal::lplasmaregion, inputlist::lrad, allglobal::lvacuumregion, allglobal::mn, allglobal::mpi_comm_spec, inputlist::mu, inputlist::mupftol, allglobal::myid, allglobal::nadof, allglobal::ncpu, allglobal::notstellsym, inputlist::ntor, inputlist::nvol, constants::one, fileunits::ounit, packab(), packxi(), constants::pi, constants::pi2, allglobal::psifactor, allglobal::semn, allglobal::solution, allglobal::somn, spec(), allglobal::sweight, constants::two, volume(), allglobal::whichcpuid(), inputlist::wmacros, allglobal::xoffset, allglobal::yesstellsym, and constants::zero.

Referenced by allglobal::check_inputs(), dforce(), fcn1(), fcn2(), get_lu_beltrami_matrices(), hesian(), newton(), pc00ab(), and spec().

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