Stellarator-Tools
|
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... | |
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.
subroutine pchelms::boundaryconditions | ( | Fsupsmn, | |
Fsupumn, | |||
Fsupvmn, | |||
iparity | |||
) |
Apply boundary conditions.
[in,out] | Fsupsmn | Contravariant current in the s direction. |
[in,out] | Fsupumn | Contravariant current in the u direction. |
[in,out] | Fsupvmn | Contravariant current in the v direction. |
[in] | iparity | Fourier parity of the residuals. |
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.
[in] | Fsupsmn | Contravariant current in the s direction on the full grid. |
[in] | Fsupumn | Contravariant current in the u direction on the full grid. |
[in] | Fsupvmn | Contravariant current in the v direction on the full grid. |
[in] | jcurrumn | Contravariant VMEC current in the u direction on the full grid. |
[in] | jcurrvmn | Contravariant VMEC current in the v direction on the full grid. |
[in] | iparity | Parity flag to indicate stellaratory symmetry. |
subroutine pchelms::compute_forces | ( | logical, intent(in) | lNLinear | ) |
Compute Fourier components of Curl(Curl(A)) - mu0J operator on full radial grid.
[in] | lNLinear | Use Non linear equations. |
subroutine pchelms::curla_pchelms | ( | Asubsmnf, | |
Asubumnf, | |||
Asubvmnf | |||
) |
Compute real-space components of contravariant jac*B^i on half radial grid from curl(A).
[in] | Asubsmnf | Covariant vector potential in the s direction. |
[in] | Asubumnf | Covariant vector potential in the u direction. |
[in] | Asubvmnf | Covariant vector potential in the v direction. |
[in,out] | jbsupsmnh | Contravariant B field and jacobian in the s direction. |
[in,out] | jbsupumnh | Contravariant B field and jacobian in the u direction. |
[in,out] | jbsupvmnh | Contravariant B field and jacobian in the v direction. |
[in] | parity | Parity flag to indicate stellaratory symmetry. |
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).
[in,out] | ksupsmnf | Contravariant current and jacobian in the s direction on the full grid. |
[in,out] | ksupumnf | Contravariant current and jacobian in the u direction on the full grid. |
[in,out] | ksupvmnf | Contravariant current and jacobian in the v direction on the full grid. |
[in,out] | asubsmnf | Covariant vector potential in the s direction on the full grid. |
[in] | bsupsmnh | Contravariant current and jacobian in the v direction on the half grid. |
[in] | iparity | Parity flag to indicate stellaratory symmetry. |
[in,out] | curtor | Current enclosed at the boundary. |
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.
[in] | A_r | Cylindical r component of the vector potential at the last surface. |
[in] | A_p | Cylindical p component of the vector potential at the last surface. |
[in] | A_z | Cylindical z component of the vector potential at the last surface. |
[out] | cA_s | Contravariant vector potential in the s direction on the last surface grid. |
[out] | cA_u | Contravariant vector potential in the u direction on the last surface grid. |
[out] | cA_v | Contravariant vector potential in the v direction on the last surface grid. |
subroutine pchelms::dump_b | ( | integer, intent(in) | js, |
integer, intent(in) | iunit | ||
) |
Write out magnetic field to file.
[in] | js | Radial index. |
[in] | iunit | File unit to write to. |
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.
[in] | rij_h | Real space R on the half grid. |
[in] | zij_h | Real space Z on the half grid. |
[in,out] | rs | R' on the full grid. |
[in,out] | zs | Z' on the full grid. |
[in] | parity | Fourier parity. |
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.
[in] | xcstate | Displacement parameters. |
[out] | fsq_nl | |F^2| non-linear residual. |
[in] | bnorm | Internal GMRES normalization |
subroutine pchelms::gmres_pchelms |
Setup and run GMRES solver for the helmholtz problem.
GMRES solves r == b + Ax = 0
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.
[in,out] | cA_s | Contravariant vector potential in the s direction on the full grid. |
[in,out] | cA_u | Contravariant vector potential in the u direction on the full grid. |
[in,out] | cA_v | Contravariant vector potential in the v direction on the full grid. |
[out] | A_s | Contravariant fourier vector potential in the s direction on the full grid. |
[out] | A_u | Contravariant fourier vector potential in the u direction on the full grid. |
[out] | A_v | Contravariant fourier vector potential in the v direction on the full grid. |
[in] | parity | Parity flag to indicate stellaratory symmetry. |
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.
[out] | Fsupsmn | Contravariant current in the s direction on the full grid. |
[out] | Fsupumn | Contravariant current in the u direction on the full grid. |
[out] | Fsupvmn | Contravariant current in the v direction on the full grid. |
[in] | jcurrumn | Contravariant VMEC current in the u direction on the full grid. |
[in] | jcurrvmn | Contravariant VMEC current in the v direction on the full grid. |
[in] | parity | Fourier parity of the residuals. |
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.
[in] | ploc | Local displacement parameters. |
[out] | Ap | Local Matrix element. |
[in] | nloc | Local number of dimensiona. |
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.
[in] | p | Displacement parameters. |
[out] | Ap | Matrix element. |
[in] | ndim | Number of dimensiona. |