MODgvec_fBase Module

Module ** fBase **

2D Fourier base in the two angular directions: (poloidal,toroidal) ~ (m,n) ~ (theta,zeta) [0,2pi]x[0,2pi/nfp]

explicit real fourier basis: sin(x_mn) or cos(x_mn) with x_mn=(mtheta - nnfp*zeta) , with mode numbers m and n


Uses

  • module~~modgvec_fbase~~UsesGraph module~modgvec_fbase MODgvec_fBase module~modgvec_globals MODgvec_Globals module~modgvec_fbase->module~modgvec_globals iso_fortran_env iso_fortran_env module~modgvec_globals->iso_fortran_env

Used by

  • module~~modgvec_fbase~~UsedByGraph module~modgvec_fbase MODgvec_fBase module~modgvec_base MODgvec_base module~modgvec_base->module~modgvec_fbase module~modgvec_gvec_to_jorek_vars MODgvec_gvec_to_jorek_Vars module~modgvec_gvec_to_jorek_vars->module~modgvec_fbase module~modgvec_gvec_to_jorek_vars->module~modgvec_base module~modgvec_hmap_axisnb MODgvec_hmap_axisNB module~modgvec_hmap_axisnb->module~modgvec_fbase module~modgvec_sfl_boozer MODgvec_SFL_Boozer module~modgvec_sfl_boozer->module~modgvec_fbase module~modgvec_hmap MODgvec_hmap module~modgvec_sfl_boozer->module~modgvec_hmap module~modgvec_transform_sfl MODgvec_Transform_SFL module~modgvec_transform_sfl->module~modgvec_fbase module~modgvec_transform_sfl->module~modgvec_base module~modgvec_transform_sfl->module~modgvec_sfl_boozer module~modgvec_transform_sfl->module~modgvec_hmap proc~bff_convert_to_modes t_boundaryFromFile%bff_convert_to_modes proc~bff_convert_to_modes->module~modgvec_fbase proc~evaluate_boozer_list_tz_all evaluate_boozer_list_tz_all proc~evaluate_boozer_list_tz_all->module~modgvec_fbase proc~evaluate_boozer_list_tz_all->module~modgvec_sfl_boozer proc~find_boozer_angles find_boozer_angles proc~find_boozer_angles->module~modgvec_fbase proc~find_pest_angles find_pest_angles proc~find_pest_angles->module~modgvec_fbase proc~get_booz_newton get_booz_newton proc~get_booz_newton->module~modgvec_fbase proc~get_boozer_sinterp t_sfl_boozer%Get_Boozer_sinterp proc~get_boozer_sinterp->module~modgvec_fbase proc~get_boozer_sinterp->module~modgvec_base proc~get_pest_newton get_pest_newton proc~get_pest_newton->module~modgvec_fbase proc~gvec_to_jorek_prepare gvec_to_jorek_prepare proc~gvec_to_jorek_prepare->module~modgvec_fbase proc~gvec_to_jorek_prepare->module~modgvec_base proc~gvec_to_jorek_prepare->module~modgvec_gvec_to_jorek_vars module~modgvec_readstate_vars MODgvec_ReadState_Vars proc~gvec_to_jorek_prepare->module~modgvec_readstate_vars proc~hmap_axisnb_init_params hmap_axisNB_init_params proc~hmap_axisnb_init_params->module~modgvec_fbase proc~init_base Init_Base proc~init_base->module~modgvec_fbase proc~init_base->module~modgvec_base proc~init_base->module~modgvec_gvec_to_jorek_vars proc~init_base->module~modgvec_readstate_vars proc~lambda_setup_and_solve Lambda_setup_and_solve proc~lambda_setup_and_solve->module~modgvec_fbase proc~lambda_solve Lambda_solve proc~lambda_solve->module~modgvec_fbase proc~lambda_solve->module~modgvec_base proc~lambda_solve->module~modgvec_hmap proc~readstatefilefromascii ReadStateFileFromASCII proc~readstatefilefromascii->module~modgvec_fbase proc~readstatefilefromascii->module~modgvec_base proc~readstatefilefromascii->module~modgvec_hmap proc~readstatefilefromascii->module~modgvec_readstate_vars proc~sfl_boozer_new sfl_boozer_new proc~sfl_boozer_new->module~modgvec_fbase proc~sfl_boozer_new->module~modgvec_hmap proc~transform_angles_sinterp Transform_Angles_sinterp proc~transform_angles_sinterp->module~modgvec_fbase proc~transform_angles_sinterp->module~modgvec_base proc~transform_sfl_init t_transform_sfl%transform_SFL_init proc~transform_sfl_init->module~modgvec_fbase proc~transform_sfl_init->module~modgvec_base proc~transform_sfl_init->module~modgvec_sfl_boozer 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 module~modgvec_hmap->module~modgvec_hmap_axisnb module~modgvec_mhd3d_vars MODgvec_MHD3D_Vars module~modgvec_mhd3d_vars->module~modgvec_base module~modgvec_mhd3d_vars->module~modgvec_hmap module~modgvec_py_state MODgvec_py_state module~modgvec_py_state->module~modgvec_base module~modgvec_readstate_vars->module~modgvec_base module~modgvec_readstate_vars->module~modgvec_hmap proc~applyprecond ApplyPrecond proc~applyprecond->module~modgvec_base proc~buildtransform_sfl t_transform_sfl%BuildTransform_SFL proc~buildtransform_sfl->module~modgvec_base proc~buildtransform_sfl->module~modgvec_sfl_boozer proc~evaluate_base_list_stz_all evaluate_base_list_stz_all proc~evaluate_base_list_stz_all->module~modgvec_base proc~evaluate_base_list_tz evaluate_base_list_tz proc~evaluate_base_list_tz->module~modgvec_base proc~evaluate_base_list_tz_all evaluate_base_list_tz_all proc~evaluate_base_list_tz_all->module~modgvec_base proc~evaluate_base_select evaluate_base_select proc~evaluate_base_select->module~modgvec_base proc~evaluate_base_tens evaluate_base_tens proc~evaluate_base_tens->module~modgvec_base proc~evaluate_base_tens_all evaluate_base_tens_all proc~evaluate_base_tens_all->module~modgvec_base proc~finalize_gvec_to_jorek finalize_gvec_to_jorek proc~finalize_gvec_to_jorek->module~modgvec_gvec_to_jorek_vars proc~find_pest_angles_2d find_pest_angles_2D proc~find_pest_angles_2d->module~modgvec_transform_sfl proc~find_pest_angles_2d->module~modgvec_mhd3d_vars proc~get_boozer get_boozer proc~get_boozer->module~modgvec_base proc~get_boozer->module~modgvec_sfl_boozer proc~get_boozer->module~modgvec_mhd3d_vars proc~get_cla_gvec_to_jorek get_CLA_gvec_to_jorek proc~get_cla_gvec_to_jorek->module~modgvec_gvec_to_jorek_vars proc~get_field Get_Field proc~get_field->module~modgvec_gvec_to_jorek_vars proc~get_field->module~modgvec_readstate_vars proc~get_integration_points get_integration_points proc~get_integration_points->module~modgvec_base proc~get_integration_points_num get_integration_points_num proc~get_integration_points_num->module~modgvec_base proc~gvec_to_jorek_writetofile_ascii gvec_to_jorek_writeToFile_ASCII proc~gvec_to_jorek_writetofile_ascii->module~modgvec_gvec_to_jorek_vars proc~init_boozer init_boozer proc~init_boozer->module~modgvec_sfl_boozer proc~init_boozer->module~modgvec_mhd3d_vars proc~init_gvec_to_jorek init_gvec_to_jorek proc~init_gvec_to_jorek->module~modgvec_gvec_to_jorek_vars proc~init_gvec_to_jorek->module~modgvec_readstate_vars proc~initmhd3d t_functional_mhd3d%InitMHD3D proc~initmhd3d->module~modgvec_base proc~initmhd3d->module~modgvec_hmap proc~initmhd3d->module~modgvec_mhd3d_vars proc~restartfromstate RestartFromState proc~restartfromstate->module~modgvec_base proc~restartfromstate->module~modgvec_mhd3d_vars proc~restartfromstate->module~modgvec_readstate_vars proc~select_base select_base proc~select_base->module~modgvec_base proc~select_base->module~modgvec_mhd3d_vars proc~select_base_dofs select_base_dofs proc~select_base_dofs->module~modgvec_base proc~select_base_dofs->module~modgvec_mhd3d_vars proc~transform_angles_3d Transform_Angles_3d proc~transform_angles_3d->module~modgvec_base proc~addboundaryperturbation AddBoundaryPerturbation proc~addboundaryperturbation->module~modgvec_mhd3d_vars proc~analyze Analyze proc~analyze->module~modgvec_mhd3d_vars proc~applybc_fstrong ApplyBC_Fstrong proc~applybc_fstrong->module~modgvec_mhd3d_vars proc~buildprecond BuildPrecond proc~buildprecond->module~modgvec_mhd3d_vars proc~eval_prof_r eval_prof_r proc~eval_prof_r->module~modgvec_readstate_vars proc~evalaux EvalAux proc~evalaux->module~modgvec_mhd3d_vars proc~evalenergy EvalEnergy proc~evalenergy->module~modgvec_mhd3d_vars proc~evalforce EvalForce proc~evalforce->module~modgvec_mhd3d_vars proc~evaluate_hmap evaluate_hmap proc~evaluate_hmap->module~modgvec_hmap proc~evaluate_hmap->module~modgvec_mhd3d_vars proc~evaluate_hmap_derivs evaluate_hmap_derivs proc~evaluate_hmap_derivs->module~modgvec_hmap proc~evaluate_hmap_derivs->module~modgvec_mhd3d_vars proc~evaluate_hmap_only evaluate_hmap_only proc~evaluate_hmap_only->module~modgvec_hmap proc~evaluate_hmap_only->module~modgvec_mhd3d_vars proc~evaluate_hmap_only_pw evaluate_hmap_only_pw proc~evaluate_hmap_only_pw->module~modgvec_mhd3d_vars proc~evaluate_hmap_pw evaluate_hmap_pw proc~evaluate_hmap_pw->module~modgvec_mhd3d_vars proc~evaluate_jac_h_derivs evaluate_jac_h_derivs proc~evaluate_jac_h_derivs->module~modgvec_hmap proc~evaluate_jac_h_derivs->module~modgvec_mhd3d_vars proc~evaluate_jac_h_derivs_pw evaluate_jac_h_derivs_pw proc~evaluate_jac_h_derivs_pw->module~modgvec_mhd3d_vars proc~evaluate_metric_derivs evaluate_metric_derivs proc~evaluate_metric_derivs->module~modgvec_hmap proc~evaluate_metric_derivs->module~modgvec_mhd3d_vars proc~evaluate_profile evaluate_profile proc~evaluate_profile->module~modgvec_mhd3d_vars proc~evaluate_rho2_profile evaluate_rho2_profile proc~evaluate_rho2_profile->module~modgvec_mhd3d_vars proc~finalize_readstate Finalize_ReadState proc~finalize_readstate->module~modgvec_readstate_vars proc~finalizemhd3d t_functional_mhd3d%FinalizeMHD3D proc~finalizemhd3d->module~modgvec_mhd3d_vars proc~finalizemhd3d_evalfunc FinalizeMHD3D_EvalFunc proc~finalizemhd3d_evalfunc->module~modgvec_mhd3d_vars proc~init Init proc~init->module~modgvec_mhd3d_vars proc~init_la_from_solution Init_LA_from_Solution proc~init_la_from_solution->module~modgvec_hmap proc~init_la_from_solution->module~modgvec_mhd3d_vars proc~initaverageaxis InitAverageAxis proc~initaverageaxis->module~modgvec_mhd3d_vars proc~initializemhd3d_evalfunc InitializeMHD3D_evalFunc proc~initializemhd3d_evalfunc->module~modgvec_mhd3d_vars proc~initprofilesgp InitProfilesGP proc~initprofilesgp->module~modgvec_mhd3d_vars proc~initsolutionmhd3d t_functional_mhd3d%InitSolutionMHD3D proc~initsolutionmhd3d->module~modgvec_mhd3d_vars proc~initsolution~2 InitSolution proc~initsolution~2->module~modgvec_mhd3d_vars proc~minimize minimize proc~minimize->module~modgvec_mhd3d_vars proc~minimizemhd3d t_functional_mhd3d%MinimizeMHD3D proc~minimizemhd3d->module~modgvec_mhd3d_vars proc~readstate ReadState proc~readstate->module~modgvec_readstate_vars proc~writestatetoascii WriteStateToASCII proc~writestatetoascii->module~modgvec_mhd3d_vars program~gvec_post GVEC_POST program~gvec_post->module~modgvec_readstate_vars

Variables

Type Visibility Attributes Name Initial
character(len=8), public :: sin_cos_map(3) = (/"_sin_   ", "_cos_   ", "_sincos_"/)
logical, private :: test_called = .FALSE.

Interfaces

public interface t_fBase

  • private function fBase_new(mn_max_in, mn_nyq_in, nfp_in, sin_cos_in, exclude_mn_zero_in) result(sf)

    allocate the type fBase

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: mn_max_in(2)

    maximum mode in m and n

    integer, intent(in) :: mn_nyq_in(2)

    number of integration points

    integer, intent(in) :: nfp_in

    number of field periods

    character(len=8), intent(in) :: sin_cos_in

    can be either only sine: " sin" only cosine: " cos" or full: "sin_cos"

    logical, intent(in) :: exclude_mn_zero_in

    =true: exclude m=n=0 mode in the basis (only important if cos is in basis)

    Return Value type(t_fBase)

    self


Derived Types

type, public ::  t_fBase

Components

Type Visibility Attributes Name Initial
integer, public :: mn_max(2)

input parameter: maximum number of fourier modes: m_max=mn_max(1),n_max=mn_max(2)

integer, public :: mn_nyq(2)

number of equidistant integration points (trapezoidal rule) in m and n

integer, public :: mn_IP

=mn_nyq(1)*mn_nyq(2)

integer, public :: nfp

number of field periods (toroidal repetition after 2pi/nfp)

integer, public :: sin_cos

can be either only sine: 1 or only cosine 2 or full: 3

logical, public :: exclude_mn_zero

=true: exclude m=n=0 mode in the basis (only important if cos is in basis)

integer, public :: modes

total(global) number of modes in basis (depends if only sin/cos or sin & cos are used)

integer, public :: modes_str

local range of modes, when distributed over MPI subdomains

integer, public :: modes_end

local range of modes, when distributed over MPI subdomains

integer, public, ALLOCATABLE :: offset_modes(:)

allocated (0:nRanks), gives range on each rank: modes_str:modes_end=offset_modes(myRank)+1:offset_modes(myRank+1)

integer, public, ALLOCATABLE :: whichRank(:)

know the MPI rank for each mode

logical, public :: initialized = .FALSE.

set to true in init, set to false in free

integer, public :: sin_range(2)

sin_range(1)+1:sin_range(2) is range with sine bases

integer, public :: cos_range(2)

sin_range(1)+1:sin_range(2) is range with cosine bases

integer, public :: mn_zero_mode

points to m=0,n=0 mode in mode array (1:mn_modes) (only one can exist for cosine, else =-1)

real(kind=wp), public :: d_thet

integration weight in theta direction: =2pi/mn_nyq(1)

real(kind=wp), public :: d_zeta

integration weight in zeta direction : =nfp(2pi/nfp)/mn_nyq(2)=2pi/mn_nyq(2)

integer, public, ALLOCATABLE :: Xmn(:,:)

mode number (m,n*nfp) for each iMode=1,modes, size(2,modes)

integer, public, ALLOCATABLE :: zero_odd_even(:)

=0 for m=n=0 mode, =1 for m= odd mode, =2 for m=even mode size(modes)

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

(theta,zeta)position of interpolation points theta [0,2pi]x[0,2pi/nfp]size(2,mn_IP)

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

1d theta position of interpolation points theta [0,2pi] size(mn_nyq(1))

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

1d zeta position of interpolation points theta [0,2pi/nfp] size(mn_nyq(2))

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

basis functions, size(1:mn_IP,1:modes)

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

dthet derivative of basis functions, (1:mn_IP,1:modes)

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

dzeta derivative of basis functions, (1:mn_IP,1:modes)

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

1/norm of each basis function, size(1:modes), norm=int_0^2pi int_0^pi (base_mn(thet,zeta))^2 dthet dzeta

integer, public :: mTotal1D

mTotal1D =mn_max(1)+1 for sin or cos base, and mTotal=2*(mn_max(1)+1) for sin&cos base

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

1D basis, size(1:mn_nyq(1),1:2,1:mTotal1D), if sin(m t-n z): sin(m t), -cos(m t) and if cos(m t-n z): cos(m t),sin(m t)

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

derivative of 1D basis, size(1:mn_nyq(1),1:2,1:mTotal1D) if sin(m t-n z): m cos(m t),m sin(m t) and if cos(m t-n z): -m sin(m t),m cos(m t)

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

1D basis functions, size(1:2,-mn_max(2):mn_max(2),1:mn_nyq(2)) for sin/cos(m t-n z): cos(n z),sin(n z)

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

derivative of 1D basis functions, size(1:2,-mn_max(2):mn_max(2),1:mn_nyq(2)) for sin/cos(m t-n z): -n sin(n z),n cos(n z)

Constructor

private function fBase_new (mn_max_in, mn_nyq_in, nfp_in, sin_cos_in, exclude_mn_zero_in)

allocate the type fBase

Finalizations Procedures

final :: fBase_free

Type-Bound Procedures

procedure, public :: init => fBase_init
procedure, public :: copy => fBase_copy
procedure, public :: compare => fBase_compare
procedure, public :: change_base => fBase_change_base
procedure, public :: eval => fBase_eval
procedure, public :: eval_xn => fBase_eval_xn
procedure, public :: evalDOF_x => fBase_evalDOF_x
procedure, public :: evalDOF_xn => fBase_evalDOF_xn
procedure, public :: evalDOF_xn_tens => fBase_evalDOF_xn_tens
procedure, public :: evalDOF_IP => fBase_evalDOF_IP_tens
procedure, public :: projectIPtoDOF => fBase_projectIPtoDOF_tens
procedure, public :: projectxntoDOF => fBase_projectxntoDOF
procedure, public :: initDOF => fBase_initDOF

Functions

private function fBase_new(mn_max_in, mn_nyq_in, nfp_in, sin_cos_in, exclude_mn_zero_in) result(sf)

allocate the type fBase

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: mn_max_in(2)

maximum mode in m and n

integer, intent(in) :: mn_nyq_in(2)

number of integration points

integer, intent(in) :: nfp_in

number of field periods

character(len=8), intent(in) :: sin_cos_in

can be either only sine: " sin" only cosine: " cos" or full: "sin_cos"

logical, intent(in) :: exclude_mn_zero_in

=true: exclude m=n=0 mode in the basis (only important if cos is in basis)

Return Value type(t_fBase)

self

private function fBase_eval(sf, deriv, x) result(base_x)

evaluate all modes at specific given point in theta and zeta

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: x(2)

theta,zeta point position

Return Value real(kind=wp), (sf%modes)

private function fBase_eval_xn(sf, deriv, np, xn) result(base_xn)

evaluate all modes at a list of given points in theta and zeta

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

integer, intent(in) :: np

number of points in xn

real(kind=wp), intent(in) :: xn(2,1:np)

theta,zeta point positions

Return Value real(kind=wp), (1:np,sf%modes)

private function fBase_eval1d_thet(sf, deriv, nthet, thet) result(base1d_thet)

evaluate special 1D base in theta direction (cos(mt_i),sin(mt_i)) or its derivative(s) on a given set of points for tensor-product evaluation of 2D sin and cos base: sin(mthet-nzeta) = sin(mthet)cos(nzeta)-cos(mthet)sin(nzeta) == dot_product( (sin(mthet),-cos(mthet)) , (cos(nzeta),sin(nzeta))) cos(mthet-nzeta) = cos(mthet)cos(nzeta)+sin(mthet)sin(nzeta) == dot_product( (cos(mthet), sin(mthet)) , (cos(nzeta),sin(nzeta))) so for the 1D base, mTotal1d depends on using sin/cos/sin+cos base.

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: deriv

=0: base, =1: dthet , =2: dthet^2

integer, intent(in) :: nthet

number of points in theta

real(kind=wp), intent(in) :: thet(1:nthet)

theta 1D point positions

Return Value real(kind=wp), (1:nthet,1:2,1:sf%mTotal1D)

private function fBase_eval1d_zeta(sf, deriv, nzeta, zeta) result(base1d_zeta)

evaluate special 1D base in zeta direction (cos(mt_i),sin(mt_i)) or its derivative(s) on a given set of points for tensor-product evaluation of 2D sin and cos base: sin(mthet-nzeta) = sin(mthet)cos(nzeta)-cos(mthet)sin(nzeta) == dot_product( (sin(mthet),-cos(mthet)) , (cos(nzeta),sin(nzeta))) cos(mthet-nzeta) = cos(mthet)cos(nzeta)+sin(mthet)sin(nzeta) == dot_product( (cos(mthet), sin(mthet)) , (cos(nzeta),sin(nzeta))) so for the 1D base, nTotal1d is always 2*n_max+1

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: deriv

=0: base, =1: dzeta , =2: dzeta^2

integer, intent(in) :: nzeta

number of points in zeta

real(kind=wp), intent(in) :: zeta(1:nzeta)

zeta 1D point positions

Return Value real(kind=wp), (1:2,-sf%mn_max(2):sf%mn_max(2),1:nzeta)

private function fBase_evalDOF_x(sf, x, deriv, DOFs) result(y)

evaluate all modes at a given interpolation point

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

real(kind=wp), intent(in) :: x(2)

input coordinate theta,zeta in [0,2pi]^2

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: DOFs(:)

array of all modes

Return Value real(kind=wp)

private function fBase_evalDOF_xn(sf, np, xn, deriv, DOFs) result(y)

evaluate all modes at a list of interpolation points

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: np

number of points to be evaluated

real(kind=wp), intent(in) :: xn(2,1:np)

input coordinate theta,zeta in [0,2pi]^2

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: DOFs(:)

array of all modes

Return Value real(kind=wp), (1:np)

private function fBase_evalDOF_xn_tens(sf, nthet, nzeta, thet, zeta, deriv, DOFs) result(y)

evaluate all modes on a tensor-produc grid (t_i,z_j), making use of the tensor product in the fourier series: y_ij = DOFs_mn * SIN(mt_i - nz_j ) => SIN(mt_i) DOFs_mn COS(nz_j) -COS(mt_i) DOFs_mn SIN(nz_j) y_ij = DOFs_mn * COS(mt_i - nz_j ) => COS(mt_i) DOFs_mn COS(nz_j) +SIN(mt_i) DOFs_mn SIN(nz_j) => a1_im DOFs_mn b1_nj + a2_im DOFs_mn b2_nj can be written as 2 SPECIAL MATMAT operations: c(i,1,n)=a1(i,m) DOFs(m,n) , c(i,2,n) = a2(i,m) DOFs(m,n) => c(i,d,n) = DOT_PROD(a(i,d,1:mmax),DOFs(1:mmax,n)) y(i,j) = c(i,1,n) b1(n,j) + c(i,2,n) b2(n,j) = DOT_PROD(c(i,1:2,1:nmax),b(1:2,1:nmax,j) the 1D ordering in y does not neead a reshape, y(i,j) => y(1:mn_IP), 1D array data can be kept, as it is passed (with its start adress) to DGEMM.

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: nthet

number of points in theta

integer, intent(in) :: nzeta

number of points in zeta

real(kind=wp), intent(in) :: thet(1:nthet)

theta positions

real(kind=wp), intent(in) :: zeta(1:nzeta)

zeta positions

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: DOFs(:)

array of all modes

Return Value real(kind=wp), (1:nthet*nzeta)

DOFS evaluated on tensor-product grid,

private function fBase_evalDOF_IP(sf, deriv, DOFs) result(y_IP)

evaluate all modes at all interpolation points

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: DOFs(:)

array of all modes

Return Value real(kind=wp), (sf%mn_IP)

private function fBase_evalDOF_IP_tens(sf, deriv, DOFs) result(y_IP)

evaluate all modes at all interpolation points, making use of the tensor product: y_ij = DOFs_mn * SIN(mt_i - nz_j ) => SIN(mt_i) DOFs_mn COS(nz_j) -COS(mt_i) DOFs_mn SIN(nz_j) y_ij = DOFs_mn * COS(mt_i - nz_j ) => COS(mt_i) DOFs_mn COS(nz_j) +SIN(mt_i) DOFs_mn SIN(nz_j) => a1_im DOFs_mn b1_nj + a2_im DOFs_mn b2_nj can be written as 2 SPECIAL MATMAT operations: c(i,1,n)=a1(i,m) DOFs(m,n) , c(i,2,n) = a2(i,m) DOFs(m,n) => c(i,d,n) = DOT_PROD(a(i,d,1:mmax),DOFs(1:mmax,n)) y(i,j) = c(i,1,n) b1(n,j) + c(i,2,n) b2(n,j) = DOT_PROD(c(i,1:2,1:nmax),b(1:2,1:nmax,j) the 1D ordering in y does not neead a reshape, y(i,j) => y(1:mn_IP), 1D array data can be kept, as it is passed (with its start adress) to DGEMM.

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: DOFs(:)

array of all modes (sf%modes)

Return Value real(kind=wp), (sf%mn_IP)

private function fBase_initDOF(sf, g_IP, thet_zeta_start) result(DOFs)

take values interpolated at sf%s_IP positions and project onto fourier basis by integration

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

real(kind=wp), intent(in) :: g_IP(:)

interpolation values at theta_IP zeta_IP positions

real(kind=wp), intent(in), optional :: thet_zeta_start(2)

Return Value real(kind=wp), (1:sf%modes)

projection to fourier base


Subroutines

private subroutine fBase_init(sf, mn_max_in, mn_nyq_in, nfp_in, sin_cos_in, exclude_mn_zero_in)

initialize the type fBase maximum mode numbers, number of integration points, type of basis (sin/cos or sin and cos)

Read more…

Arguments

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

self

integer, intent(in) :: mn_max_in(2)

maximum mode in m and n

integer, intent(in) :: mn_nyq_in(2)

number of integration points

integer, intent(in) :: nfp_in

number of field periods

character(len=8), intent(in) :: sin_cos_in

can be either only sine: " sin" only cosine: " cos" or full: "sin_cos"

logical, intent(in) :: exclude_mn_zero_in

=true: exclude m=n=0 mode in the basis (only important if cos is in basis)

private subroutine fBase_alloc(sf)

allocate all variables in fBase

Arguments

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

self

public subroutine fBase_free(sf)

finalize the type fBase

Arguments

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

self

private subroutine fBase_copy(sf, tocopy)

copy the type fBase

Arguments

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

self

class(t_fBase), intent(in) :: tocopy

private subroutine fBase_compare(sf, tocompare, is_same, cond_out)

compare sf with the input type fBase

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

type(t_fBase), intent(in) :: tocompare
logical, intent(out), optional :: is_same
logical, intent(out), optional :: cond_out(:)

private subroutine fBase_change_base(sf, old_fBase, iterDim, old_data, sf_data)

change data from oldBase to self. Forier modes are directly copied so, if new mode space is smaller, its like a Fourier cut-off. if new modes do not match old ones, they are set to zero. Note that a change of nfp is not possible· as well as a change from sine to cosine

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

class(t_fBase), intent(in) :: old_fBase

base of old_data

integer, intent(in) :: iterDim

iterate on first or second dimension or old_data/sf_data

real(kind=wp), intent(in) :: old_data(:,:)
real(kind=wp), intent(out) :: sf_data(:,:)

private subroutine fBase_projectIPtoDOF(sf, add, factor, deriv, y_IP, DOFs)

project from interpolation points to all modes DOFs = addDOFs+ fac MATMUL(base_IP_DOF,y_IP)

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

logical, intent(in) :: add

=F initialize DOFs , =T add to DOFs

real(kind=wp), intent(in) :: factor

scale result by factor, before adding to DOFs (should be =1.0_wp if not needed)

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: y_IP(:)
real(kind=wp), intent(inout) :: DOFs(1:sf%modes)

array of all modes

private subroutine fBase_projectxntoDOF(sf, add, factor, deriv, np, xn, yn, DOFs)

project from any 2D set of interpolation points, at tensor-product of (theta,zeta) positions given by "xn", to all modes DOFs = addDOFs+ fac MATMUL(base_xn,yn)

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

logical, intent(in) :: add

=F initialize DOFs , =T add to DOFs

real(kind=wp), intent(in) :: factor

scale result by factor, before adding to DOFs (should be =1.0_wp if not needed)

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

integer, intent(in) :: np

total number of 2D interpolation points

real(kind=wp), intent(in) :: xn(2,1:np)

(theta=1,zeta=2) position of tensor-product interpolation points, [0,2pi]x[0,2pi/nfp],size(2,mn_IP)

real(kind=wp), intent(in) :: yn(1:np)

value at interpolation points

real(kind=wp), intent(inout) :: DOFs(1:sf%modes)

array of all modes

private subroutine fBase_projectIPtoDOF_tens(sf, add, factor, deriv, y_IP, DOFs)

inverse of fBase_evalDOF_IP_tens

Arguments

Type IntentOptional Attributes Name
class(t_fBase), intent(in) :: sf

self

logical, intent(in) :: add

=F initialize DOFs , =T add to DOFs

real(kind=wp), intent(in) :: factor

scale result by factor, before adding to DOFs (should be =1.0_wp if not needed)

integer, intent(in) :: deriv

=0: base, =2: dthet , =3: dzeta

real(kind=wp), intent(in) :: y_IP(:)

point values (at sf%x_IP if x_IP_in not given)

real(kind=wp), intent(inout) :: DOFs(1:sf%modes)

array of all modes

private subroutine fBase_test(sf)

test fBase variable

Arguments

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

self