MODgvec_Transform_SFL Module

Module Transform SFL

Transform to Straight-field line angles, PEST / BOOZER


Uses

  • module~~modgvec_transform_sfl~~UsesGraph module~modgvec_transform_sfl MODgvec_Transform_SFL module~modgvec_base MODgvec_base module~modgvec_transform_sfl->module~modgvec_base module~modgvec_fbase MODgvec_fBase module~modgvec_transform_sfl->module~modgvec_fbase module~modgvec_globals MODgvec_Globals module~modgvec_transform_sfl->module~modgvec_globals module~modgvec_hmap MODgvec_hmap module~modgvec_transform_sfl->module~modgvec_hmap module~modgvec_newton MODgvec_Newton module~modgvec_transform_sfl->module~modgvec_newton module~modgvec_sfl_boozer MODgvec_SFL_Boozer module~modgvec_transform_sfl->module~modgvec_sfl_boozer module~modgvec_sgrid MODgvec_sGrid module~modgvec_transform_sfl->module~modgvec_sgrid module~modgvec_base->module~modgvec_fbase module~modgvec_base->module~modgvec_globals module~modgvec_base->module~modgvec_sgrid module~modgvec_sbase MODgvec_sBase module~modgvec_base->module~modgvec_sbase module~modgvec_fbase->module~modgvec_globals iso_fortran_env iso_fortran_env module~modgvec_globals->iso_fortran_env module~modgvec_c_hmap MODgvec_c_hmap module~modgvec_hmap->module~modgvec_c_hmap module~modgvec_hmap_axisnb MODgvec_hmap_axisNB module~modgvec_hmap->module~modgvec_hmap_axisnb module~modgvec_hmap_cyl MODgvec_hmap_cyl module~modgvec_hmap->module~modgvec_hmap_cyl module~modgvec_hmap_frenet MODgvec_hmap_frenet module~modgvec_hmap->module~modgvec_hmap_frenet module~modgvec_hmap_knot MODgvec_hmap_knot module~modgvec_hmap->module~modgvec_hmap_knot module~modgvec_hmap_rz MODgvec_hmap_RZ module~modgvec_hmap->module~modgvec_hmap_rz module~modgvec_newton->module~modgvec_globals module~modgvec_sfl_boozer->module~modgvec_fbase module~modgvec_sfl_boozer->module~modgvec_globals module~modgvec_sfl_boozer->module~modgvec_hmap module~modgvec_sfl_boozer->module~modgvec_newton module~modgvec_sgrid->module~modgvec_globals module~modgvec_c_hmap->module~modgvec_globals module~modgvec_hmap_axisnb->module~modgvec_fbase module~modgvec_hmap_axisnb->module~modgvec_globals module~modgvec_hmap_axisnb->module~modgvec_c_hmap module~modgvec_io_netcdf MODgvec_IO_NETCDF module~modgvec_hmap_axisnb->module~modgvec_io_netcdf module~modgvec_hmap_cyl->module~modgvec_globals module~modgvec_hmap_cyl->module~modgvec_c_hmap module~modgvec_hmap_frenet->module~modgvec_globals module~modgvec_hmap_frenet->module~modgvec_c_hmap module~modgvec_hmap_knot->module~modgvec_globals module~modgvec_hmap_knot->module~modgvec_c_hmap module~modgvec_hmap_rz->module~modgvec_globals module~modgvec_hmap_rz->module~modgvec_c_hmap module~modgvec_sbase->module~modgvec_globals module~modgvec_sbase->module~modgvec_sgrid module~sll_m_bsplines sll_m_bsplines module~modgvec_sbase->module~sll_m_bsplines module~sll_m_spline_interpolator_1d sll_m_spline_interpolator_1d module~modgvec_sbase->module~sll_m_spline_interpolator_1d module~sll_m_spline_matrix sll_m_spline_matrix module~modgvec_sbase->module~sll_m_spline_matrix module~modgvec_io_netcdf->module~modgvec_globals netcdf netcdf module~modgvec_io_netcdf->netcdf module~sll_m_bsplines_base sll_m_bsplines_base module~sll_m_bsplines->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform sll_m_bsplines_non_uniform module~sll_m_bsplines->module~sll_m_bsplines_non_uniform module~sll_m_bsplines_uniform sll_m_bsplines_uniform module~sll_m_bsplines->module~sll_m_bsplines_uniform module~sll_m_working_precision sll_m_working_precision module~sll_m_bsplines->module~sll_m_working_precision module~sll_m_spline_interpolator_1d->module~sll_m_spline_matrix module~sll_m_boundary_condition_descriptors sll_m_boundary_condition_descriptors module~sll_m_spline_interpolator_1d->module~sll_m_boundary_condition_descriptors module~sll_m_spline_interpolator_1d->module~sll_m_bsplines_base module~sll_m_spline_1d sll_m_spline_1d module~sll_m_spline_interpolator_1d->module~sll_m_spline_1d module~sll_m_spline_interpolator_1d->module~sll_m_working_precision module~sll_m_spline_matrix_banded sll_m_spline_matrix_banded module~sll_m_spline_matrix->module~sll_m_spline_matrix_banded module~sll_m_spline_matrix_base sll_m_spline_matrix_base module~sll_m_spline_matrix->module~sll_m_spline_matrix_base module~sll_m_spline_matrix_dense sll_m_spline_matrix_dense module~sll_m_spline_matrix->module~sll_m_spline_matrix_dense module~sll_m_spline_matrix->module~sll_m_working_precision module~sll_m_bsplines_base->module~sll_m_working_precision module~sll_m_bsplines_non_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform->module~sll_m_working_precision module~sll_m_bsplines_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_uniform->module~sll_m_working_precision module~sll_m_spline_1d->module~sll_m_bsplines_base module~sll_m_spline_1d->module~sll_m_working_precision module~sll_m_spline_matrix_banded->iso_fortran_env module~sll_m_spline_matrix_banded->module~sll_m_spline_matrix_base module~sll_m_spline_matrix_banded->module~sll_m_working_precision module~sll_m_spline_matrix_base->module~sll_m_working_precision module~sll_m_spline_matrix_dense->iso_fortran_env module~sll_m_spline_matrix_dense->module~sll_m_spline_matrix_base module~sll_m_spline_matrix_dense->module~sll_m_working_precision

Used by

  • module~~modgvec_transform_sfl~~UsedByGraph module~modgvec_transform_sfl MODgvec_Transform_SFL module~modgvec_gvec_to_castor3d_vars MODgvec_gvec_to_castor3d_Vars module~modgvec_gvec_to_castor3d_vars->module~modgvec_transform_sfl module~modgvec_gvec_to_gene_vars MODgvec_gvec_to_gene_Vars module~modgvec_gvec_to_gene_vars->module~modgvec_transform_sfl module~modgvec_gvec_to_hopr_vars MODgvec_gvec_to_hopr_vars module~modgvec_gvec_to_hopr_vars->module~modgvec_transform_sfl

Interfaces

private interface transform_sfl_new


Abstract Interfaces

abstract interface

  • private function i_func_evalprof(spos)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(in) :: spos

    Return Value real(kind=wp)


Derived Types

type, public ::  t_transform_sfl

Components

Type Visibility Attributes Name Initial
logical, public :: initialized = .FALSE.

set to true in init, set to false in free

integer, public :: whichSFLcoord
integer, public :: fac_nyq
integer, public :: mn_max(2)
integer, public :: deg
integer, public :: continuity
integer, public :: degGP
integer, public :: nfp
integer, public :: mn_nyq(2)

number of integration points in fbase for X1sfl,X2sfl,Gtsfl,GZsfl

integer, public :: mn_nyq_booz(2)

number of integration points in fbase for boozer transform (fbase of GZ_base)

integer, public :: X1sfl_sin_cos
integer, public :: X2sfl_sin_cos
integer, public :: GZ_sin_cos
logical, public :: booz_relambda

=T: recompute lambda from mapping on full fourier series, =F: use LA from eq.

integer, public :: to_angle_method

=1: "interpolate": root search of interpolation points (mn_nyq=2(m_max,n_max)+1) in sfl angles, =2: "integrate": project to sfl angles with trapezoidal rule (integral with transform, mn_nyq=4(m_max,n_max)+1)

type(t_sGrid), public :: sgrid_sfl

grid for SFL coordinates

type(PP_T_HMAP), public, POINTER :: hmap

pointer to hmap class

class(PP_T_HMAP), public, POINTER :: hmap

pointer to hmap class

class(t_base), public, ALLOCATABLE :: X1sfl_base

container for base of variable X1 in SFL coordinates

class(t_base), public, ALLOCATABLE :: X2sfl_base

container for base of variable X2 in SFL coordinates

class(t_base), public, ALLOCATABLE :: GZ_base

container for base of variable Gthet and Gzeta (transforms to BOOZER!)

class(t_base), public, ALLOCATABLE :: GZsfl_base

container for base of variable Gtheta and Gzeta in SFL coordinates

real(kind=wp), public, ALLOCATABLE :: X1sfl(:,:)

data (1:nBase,1:modes) of X1 in SFL coords.

real(kind=wp), public, ALLOCATABLE :: X2sfl(:,:)

data (1:nBase,1:modes) of X2 in SFL coords.

real(kind=wp), public, ALLOCATABLE :: Gthet(:,:)

data (1:nBase,1:modes) of Gthet in GVEC coords. (for BOOZER)

real(kind=wp), public, ALLOCATABLE :: GZ(:,:)

data (1:nBase,1:modes) of GZ in GVEC coords. (for BOOZER)

real(kind=wp), public, ALLOCATABLE :: Gtsfl(:,:)

data (1:nBase,1:modes) of Gt in SFL coords. (for BOOZER)

real(kind=wp), public, ALLOCATABLE :: GZsfl(:,:)

data (1:nBase,1:modes) of GZ in SFL coords. (for BOOZER)

type(t_sfl_boozer), public, ALLOCATABLE :: booz

subclass needed for boozer transform

procedure(i_func_evalprof), public, POINTER, NOPASS :: eval_phiPrime
procedure(i_func_evalprof), public, POINTER, NOPASS :: eval_iota

Type-Bound Procedures

procedure, public :: init => transform_SFL_init
procedure, public :: BuildTransform => BuildTransform_SFL
procedure, public :: free => transform_SFL_free

type, private, extends(c_newton_Root1D_FdF) ::  t_newton_Root1D_FdF_pest

Components

Type Visibility Attributes Name Initial
type(t_fBase), public, POINTER :: LA_fbase_in
real(kind=wp), public, POINTER :: LA_in(:)
real(kind=wp), public :: zeta

Type-Bound Procedures

procedure, public :: FRdFR => pest_newton_FRdFR

Functions

public function get_pest_newton(theta_star, zeta, LA_fbase_in, LA_in) result(thet_out)

This function returns the result of the 1D newton root search for the pest theta angle

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: theta_star
real(kind=wp), intent(in) :: zeta
type(t_fBase), intent(in), TARGET :: LA_fbase_in
real(kind=wp), intent(in), TARGET :: LA_in(1:LA_fbase_in%modes)

Return Value real(kind=wp)

private function pest_newton_FRdFR(sf, x) result(A_FRdFR)

Function for 1D newton root search for PEST

Arguments

Type IntentOptional Attributes Name
class(t_newton_Root1D_FdF_pest), intent(in) :: sf
real(kind=wp), intent(in) :: x

Return Value real(kind=wp), (2)


Subroutines

public subroutine transform_sfl_new(sf, mn_max_in, whichSFL, deg_in, continuity_in, degGP_in, grid_in, hmap_in, X1_base_in, X2_base_in, LA_base_in, eval_phiPrime_in, eval_iota_in, booz_relambda)

Allocate class and call init

Arguments

Type IntentOptional Attributes Name
type(t_transform_sfl), intent(inout), ALLOCATABLE :: sf

self

integer, intent(in) :: mn_max_in(2)
integer, intent(in) :: whichSFL
integer, intent(in) :: deg_in
integer, intent(in) :: continuity_in
integer, intent(in) :: degGP_in
class(t_sGrid), intent(in), TARGET :: grid_in

grid information

type(PP_T_HMAP), intent(in), TARGET :: hmap_in
class(t_base), intent(in), TARGET :: X1_base_in
class(t_base), intent(in), TARGET :: X2_base_in
class(t_base), intent(in), TARGET :: LA_base_in
procedure(i_func_evalprof) :: eval_phiPrime_in

procedure pointers to profile evaluation functions.

procedure(i_func_evalprof) :: eval_iota_in

procedure pointers to profile evaluation functions.

logical, intent(in), optional :: booz_relambda

for boozer transform, recompute lambda (recommended)

private subroutine transform_SFL_init(sf)

get_new

Arguments

Type IntentOptional Attributes Name
class(t_transform_sfl), intent(inout) :: sf

self

private subroutine BuildTransform_SFL(sf, X1_base_in, X2_base_in, LA_base_in, X1_in, X2_in, LA_in)

Builds X1 and X2 in SFL coordinates

Arguments

Type IntentOptional Attributes Name
class(t_transform_sfl), intent(inout) :: sf

self

class(t_base), intent(in) :: X1_base_in
class(t_base), intent(in) :: X2_base_in
class(t_base), intent(in) :: LA_base_in
real(kind=wp), intent(in) :: X1_in(1:X1_base_in%s%nbase,1:X1_base_in%f%modes)
real(kind=wp), intent(in) :: X2_in(1:X2_base_in%s%nbase,1:X2_base_in%f%modes)
real(kind=wp), intent(in) :: LA_in(1:LA_base_in%s%nbase,1:LA_base_in%f%modes)

private subroutine Transform_Angles_3d(q_base_in, q_in, q_name, q_base_out, q_out, thetazeta_IP)

Transform a function from the GVEC angles q(s,theta,zeta) to new angles q(s,theta,zeta*) by using interpolation in angular direction (fourier transform) and spline interpolation in radial direction (at s_IP points of output base) the interpolation points are given by thetazeta_IP, which are the angle positions of an equidistant interpolation grid in PEST/Boozer angles

Arguments

Type IntentOptional Attributes Name
class(t_base), intent(in) :: q_base_in
real(kind=wp), intent(in) :: q_in(1:q_base_in%s%nBase,1:q_base_in%f%modes)
character(len=*), intent(in) :: q_name
class(t_base), intent(in) :: q_base_out
real(kind=wp), intent(inout) :: q_out(q_base_out%s%nBase,1:q_base_out%f%modes)
real(kind=wp), intent(in) :: thetazeta_IP(2,q_base_out%f%mn_IP,q_base_out%s%nBase)

private subroutine to_spline_with_BC(q_base_out, q_m, q_out)

Helper routine to go from spline interpolation points to spline coefficients and apply smooth axis boundary condition.

Arguments

Type IntentOptional Attributes Name
class(t_base), intent(in) :: q_base_out
real(kind=wp), intent(in) :: q_m(1:q_base_out%f%modes,1:q_base_out%s%nBase)
real(kind=wp), intent(out) :: q_out(q_base_out%s%nBase,1:q_base_out%f%modes)

private subroutine Transform_Angles_sinterp(AB_base_in, A_in, q_base_in, q_in, q_name, q_base_out, q_out, B_in)

Transform a function from VMEC angles q(s,theta,zeta) to new angles q(s,theta,zeta) by projection onto the modes of the new angles: sigma_mn(theta,zeta) using a given in s Here, new angles are theta=theta+A(theta,zeta), zeta=zeta+B(theta,zeta), with A,B periodic functions and zero average and same base Note that in this routine, the integral is transformed back to (theta,zeta) q_mn = iint_0^2pi q(theta,zeta) sigma_mn(theta,zeta) dtheta dzeta = iint_0^2pi q(theta,zeta) sigma_mn(theta,zeta) [(1+dA/dtheta)(1+dB/dzeta)-(dA/dzetadB/dzeta)] dtheta dzeta

Arguments

Type IntentOptional Attributes Name
class(t_base), intent(in) :: AB_base_in
real(kind=wp), intent(in) :: A_in(1:AB_base_in%s%nBase,1:AB_base_in%f%modes)
class(t_base), intent(in) :: q_base_in
real(kind=wp), intent(in) :: q_in(1:q_base_in%s%nBase,1:q_base_in%f%modes)
character(len=*), intent(in) :: q_name
class(t_base), intent(in) :: q_base_out
real(kind=wp), intent(inout) :: q_out(q_base_out%s%nBase,1:q_base_out%f%modes)
real(kind=wp), intent(in), optional :: B_in(1:AB_base_in%s%nBase,1:AB_base_in%f%modes)

public subroutine find_pest_angles(nrho, fbase_in, LA_in, tz_dim, tz_pest, thetzeta_out)

on one flux surface, find for a list of in thet_j,zeta_j, the corresponding (thet_j,zeta_j) positions, given Here, new PEST angles are theta=theta+lambda(theta,zeta) zeta=zeta, so a 1D root search in theta is is enough

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nrho

number of surfaces, (second dimension of LA_in and nu_in modes)

type(t_fBase), intent(in) :: fbase_in
real(kind=wp), intent(in) :: LA_in(1:fbase_in%modes,nrho)
integer, intent(in) :: tz_dim
real(kind=wp), intent(in) :: tz_pest(2,tz_dim)
real(kind=wp), intent(out) :: thetzeta_out(2,tz_dim,nrho)

theta,zeta position in original angles, for given pest angles

private subroutine transform_SFL_free(sf)

Arguments

Type IntentOptional Attributes Name
class(t_transform_sfl), intent(inout) :: sf

self