Stellarator-Tools
pchelms Module Reference

This file solves the helmholtz equation to set inital fields that match vmec and vacuum currents from the vector potential. Initial vector potential on the edge is supplied by the BMW code. More...

Functions/Subroutines

subroutine run_pchelms
 Run the pchelms code to solve for inital jbsup values.
 
subroutine curla_pchelms (Asubsmnf, Asubumnf, Asubvmnf,
 Compute real-space components of contravariant jac*B^i on half radial grid from curl(A). More...
 
subroutine curlb_pchelms (ksupsmnf, ksupumnf, ksupvmnf, asubsmnf,
 Compute real-space components of contravariant jac*J^i on full radial grid from curl(B). More...
 
subroutine cyl2vmec_a (A_r, A_p, A_z, cA_s, cA_u, cA_v)
 Convert cylindical vector potential to contravariant components. More...
 
subroutine get_e_s (rij_h, zij_h, rs, zs, parity)
 Get the e_s basis vector. More...
 
subroutine init_a (cA_s, cA_u, cA_v, A_s, A_u, A_v, parity)
 Initialize vector potential. More...
 
subroutine init_f (Fsupsmn, Fsupumn, Fsupvmn, jcurrumn, jcurrvmn, p
 Initialize expected currents. More...
 
subroutine compare_current (Fsupsmn, Fsupumn, Fsupvmn, jcurrumn, jc
 Compare Curl(Curl(A)) with the expected VMEC and vacuum currents. More...
 
subroutine dump_b (js, iunit)
 Write out magnetic field to file. More...
 
subroutine getfsq_pchelms
 The the current residual.
 
subroutine cleanup
 Deallocate arrays.
 
subroutine check_current
 Check that the line integral of Bsubuij equals the integrated toroidal current.
 
subroutine compute_forces_lin
 Compute linear forces.
 
subroutine backslv
 Update solution.
 
subroutine init_pchelms
 Initialize helmholtz solver.
 
subroutine compute_forces (lNLinear)
 Compute Fourier components of Curl(Curl(A)) - mu0J operator on full radial grid. More...
 
subroutine boundaryconditions (Fsupsmn, Fsupumn, Fsupvmn, iparity)
 Apply boundary conditions. More...
 
subroutine gmres_pchelms
 Setup and run GMRES solver for the helmholtz problem. More...
 
subroutine matvec_pchelms (p, Ap, ndim)
 Serial callback function for MatVec GMRES routine. More...
 
subroutine matvec_par_pchelms (ploc, Ap, nloc)
 Parallel callback function for MatVec GMRES routine. More...
 
subroutine getnlforce_pchelms (xcstate, fsq_nl, bnorm)
 Non linear force callback. More...
 

Detailed Description

This file solves the helmholtz equation to set inital fields that match vmec and vacuum currents from the vector potential. Initial vector potential on the edge is supplied by the BMW code.

Function/Subroutine Documentation

◆ boundaryconditions()

subroutine pchelms::boundaryconditions (   Fsupsmn,
  Fsupumn,
  Fsupvmn,
  iparity 
)

Apply boundary conditions.

Parameters
[in,out]FsupsmnContravariant current in the s direction.
[in,out]FsupumnContravariant current in the u direction.
[in,out]FsupvmnContravariant current in the v direction.
[in]iparityFourier parity of the residuals.

◆ compare_current()

subroutine pchelms::compare_current ( real (dp), dimension(:,:,:), intent(in)  Fsupsmn,
real (dp), dimension(:,:,:), intent(in)  Fsupumn,
real (dp), dimension(:,:,:), intent(in)  Fsupvmn,
real (dp), dimension(:,:,:), intent(in)  jcurrumn,
  jc 
)

Compare Curl(Curl(A)) with the expected VMEC and vacuum currents.

Parameters
[in]FsupsmnContravariant current in the s direction on the full grid.
[in]FsupumnContravariant current in the u direction on the full grid.
[in]FsupvmnContravariant current in the v direction on the full grid.
[in]jcurrumnContravariant VMEC current in the u direction on the full grid.
[in]jcurrvmnContravariant VMEC current in the v direction on the full grid.
[in]iparityParity flag to indicate stellaratory symmetry.

◆ compute_forces()

subroutine pchelms::compute_forces ( logical, intent(in)  lNLinear)

Compute Fourier components of Curl(Curl(A)) - mu0J operator on full radial grid.

Parameters
[in]lNLinearUse Non linear equations.

◆ curla_pchelms()

subroutine pchelms::curla_pchelms (   Asubsmnf,
  Asubumnf,
  Asubvmnf 
)

Compute real-space components of contravariant jac*B^i on half radial grid from curl(A).

Parameters
[in]AsubsmnfCovariant vector potential in the s direction.
[in]AsubumnfCovariant vector potential in the u direction.
[in]AsubvmnfCovariant vector potential in the v direction.
[in,out]jbsupsmnhContravariant B field and jacobian in the s direction.
[in,out]jbsupumnhContravariant B field and jacobian in the u direction.
[in,out]jbsupvmnhContravariant B field and jacobian in the v direction.
[in]parityParity flag to indicate stellaratory symmetry.

◆ curlb_pchelms()

subroutine pchelms::curlb_pchelms ( real(dp), dimension(:,:,:), pointer  ksupsmnf,
real(dp), dimension(:,:,:), pointer  ksupumnf,
real(dp), dimension(:,:,:), pointer  ksupvmnf,
real(dp), dimension(:,:,:), pointer  asubsmnf 
)

Compute real-space components of contravariant jac*J^i on full radial grid from curl(B).

Parameters
[in,out]ksupsmnfContravariant current and jacobian in the s direction on the full grid.
[in,out]ksupumnfContravariant current and jacobian in the u direction on the full grid.
[in,out]ksupvmnfContravariant current and jacobian in the v direction on the full grid.
[in,out]asubsmnfCovariant vector potential in the s direction on the full grid.
[in]bsupsmnhContravariant current and jacobian in the v direction on the half grid.
[in]iparityParity flag to indicate stellaratory symmetry.
[in,out]curtorCurrent enclosed at the boundary.

◆ cyl2vmec_a()

subroutine pchelms::cyl2vmec_a ( real (dp), dimension(:,:,:), intent(inout)  A_r,
real (dp), dimension(:,:,:), intent(inout)  A_p,
real (dp), dimension(:,:,:), intent(inout)  A_z,
real (dp), dimension(:,:,:), intent(out)  cA_s,
real (dp), dimension(:,:,:), intent(out)  cA_u,
real (dp), dimension(:,:,:), intent(out)  cA_v 
)

Convert cylindical vector potential to contravariant components.

Parameters
[in]A_rCylindical r component of the vector potential at the last surface.
[in]A_pCylindical p component of the vector potential at the last surface.
[in]A_zCylindical z component of the vector potential at the last surface.
[out]cA_sContravariant vector potential in the s direction on the last surface grid.
[out]cA_uContravariant vector potential in the u direction on the last surface grid.
[out]cA_vContravariant vector potential in the v direction on the last surface grid.

◆ dump_b()

subroutine pchelms::dump_b ( integer, intent(in)  js,
integer, intent(in)  iunit 
)

Write out magnetic field to file.

Parameters
[in]jsRadial index.
[in]iunitFile unit to write to.

◆ get_e_s()

subroutine pchelms::get_e_s ( real (dp), dimension(:,:,:), intent(in)  rij_h,
real (dp), dimension(:,:,:), intent(in)  zij_h,
real (dp), dimension(:,:,:), intent(inout)  rs,
real (dp), dimension(:,:,:), intent(inout)  zs,
integer, intent(in)  parity 
)

Get the e_s basis vector.

Parameters
[in]rij_hReal space R on the half grid.
[in]zij_hReal space Z on the half grid.
[in,out]rsR' on the full grid.
[in,out]zsZ' on the full grid.
[in]parityFourier parity.

◆ getnlforce_pchelms()

subroutine pchelms::getnlforce_pchelms ( real (dp), dimension(neqs), intent(in)  xcstate,
real (dp), intent(out)  fsq_nl,
real (dp), intent(in)  bnorm 
)

Non linear force callback.

Parameters
[in]xcstateDisplacement parameters.
[out]fsq_nl|F^2| non-linear residual.
[in]bnormInternal GMRES normalization

◆ gmres_pchelms()

subroutine pchelms::gmres_pchelms

Setup and run GMRES solver for the helmholtz problem.

GMRES solves r == b + Ax = 0

◆ init_a()

subroutine pchelms::init_a ( real (dp), dimension(:,:,:), intent(inout)  cA_s,
real (dp), dimension(:,:,:), intent(inout)  cA_u,
real (dp), dimension(:,:,:), intent(inout)  cA_v,
real (dp), dimension(0:mpol,-ntor:ntor,ns), intent(out)  A_s,
real (dp), dimension(0:mpol,-ntor:ntor,ns), intent(out)  A_u,
real (dp), dimension(0:mpol,-ntor:ntor,ns), intent(out)  A_v,
integer, intent(in)  parity 
)

Initialize vector potential.

This subroutine is only called once so no need to parallelize. Linearly extrapolat to the center or match surface.

Parameters
[in,out]cA_sContravariant vector potential in the s direction on the full grid.
[in,out]cA_uContravariant vector potential in the u direction on the full grid.
[in,out]cA_vContravariant vector potential in the v direction on the full grid.
[out]A_sContravariant fourier vector potential in the s direction on the full grid.
[out]A_uContravariant fourier vector potential in the u direction on the full grid.
[out]A_vContravariant fourier vector potential in the v direction on the full grid.
[in]parityParity flag to indicate stellaratory symmetry.

◆ init_f()

subroutine pchelms::init_f ( real (dp), dimension(0:mpol,-ntor:ntor,ns), intent(out)  Fsupsmn,
real (dp), dimension(0:mpol,-ntor:ntor,ns), intent(out)  Fsupumn,
real (dp), dimension(0:mpol,-ntor:ntor,ns), intent(out)  Fsupvmn,
  jcurrumn,
  jcurrvmn,
  p 
)

Initialize expected currents.

Up to the vmec last closed flux surface, initialize with the VMEC currents. outside, initalize to zero.

Parameters
[out]FsupsmnContravariant current in the s direction on the full grid.
[out]FsupumnContravariant current in the u direction on the full grid.
[out]FsupvmnContravariant current in the v direction on the full grid.
[in]jcurrumnContravariant VMEC current in the u direction on the full grid.
[in]jcurrvmnContravariant VMEC current in the v direction on the full grid.
[in]parityFourier parity of the residuals.

◆ matvec_par_pchelms()

subroutine pchelms::matvec_par_pchelms ( real(dp), dimension(nloc), intent(in)  ploc,
real(dp), dimension(nloc), intent(out)  Ap,
integer, intent(in)  nloc 
)

Parallel callback function for MatVec GMRES routine.

Parameters
[in]plocLocal displacement parameters.
[out]ApLocal Matrix element.
[in]nlocLocal number of dimensiona.

◆ matvec_pchelms()

subroutine pchelms::matvec_pchelms ( real(dp), dimension(ndim), intent(in)  p,
real(dp), dimension(ndim), intent(out)  Ap,
integer, intent(in)  ndim 
)

Serial callback function for MatVec GMRES routine.

Parameters
[in]pDisplacement parameters.
[out]ApMatrix element.
[in]ndimNumber of dimensiona.