MODgvec_MHD3D_evalFunc Module

Module MHD3D Evalfunc

Evaluate the MHD3D functional and its derivative


Uses

  • module~~modgvec_mhd3d_evalfunc~~UsesGraph module~modgvec_mhd3d_evalfunc MODgvec_MHD3D_evalFunc module~modgvec_globals MODgvec_Globals module~modgvec_mhd3d_evalfunc->module~modgvec_globals module~sll_m_spline_matrix sll_m_spline_matrix module~modgvec_mhd3d_evalfunc->module~sll_m_spline_matrix module~sll_m_spline_matrix_banded sll_m_spline_matrix_banded module~modgvec_mhd3d_evalfunc->module~sll_m_spline_matrix_banded iso_fortran_env iso_fortran_env module~modgvec_globals->iso_fortran_env 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_working_precision sll_m_working_precision module~sll_m_spline_matrix->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_mhd3d_evalfunc~~UsedByGraph module~modgvec_mhd3d_evalfunc MODgvec_MHD3D_evalFunc proc~finalizemhd3d t_functional_mhd3d%FinalizeMHD3D proc~finalizemhd3d->module~modgvec_mhd3d_evalfunc proc~initmhd3d t_functional_mhd3d%InitMHD3D proc~initmhd3d->module~modgvec_mhd3d_evalfunc proc~initsolutionmhd3d t_functional_mhd3d%InitSolutionMHD3D proc~initsolutionmhd3d->module~modgvec_mhd3d_evalfunc proc~minimizemhd3d_descent MinimizeMHD3D_descent proc~minimizemhd3d_descent->module~modgvec_mhd3d_evalfunc proc~writestatetoascii WriteStateToASCII proc~writestatetoascii->module~modgvec_mhd3d_evalfunc program~gvec_post GVEC_POST program~gvec_post->module~modgvec_mhd3d_evalfunc

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private, ALLOCATABLE :: pres_GP(:)

mass profile

real(kind=wp), private, ALLOCATABLE :: chiPrime_GP(:)

s derivative of poloidal flux

real(kind=wp), private, ALLOCATABLE :: phiPrime_GP(:)

s derivative of toroidal flux

real(kind=wp), private, ALLOCATABLE :: phiPrime2_GP(:)

s derivative of toroidal flux : |Phi'(s)|^2

real(kind=wp), private, ALLOCATABLE :: X1_IP_GP(:,:)

evaluation of X1

real(kind=wp), private, ALLOCATABLE :: X2_IP_GP(:,:)

evaluation of X2

real(kind=wp), private, ALLOCATABLE :: J_h(:,:)

Jacobian of the mapping h (X1,X2,zeta) -->(x,y,z)

real(kind=wp), private, ALLOCATABLE :: J_p(:,:)

Jacobian of poloidal mapping: dX1_dsdX2_dtheta - dX2_dsdX1_theta

real(kind=wp), private, ALLOCATABLE :: sJ_h(:,:)

1/J_h

real(kind=wp), private, ALLOCATABLE :: sJ_p(:,:)

1/J_p

real(kind=wp), private, ALLOCATABLE :: detJ(:,:)

global Jacobian: detJ=sqrt(det g)=J_h*J_p )

real(kind=wp), private, ALLOCATABLE :: sdetJ(:,:)

1/detJ

real(kind=wp), private, ALLOCATABLE :: dX1_ds(:,:)

radial derivative of X1

real(kind=wp), private, ALLOCATABLE :: dX2_ds(:,:)

radial derivative of X2

real(kind=wp), private, ALLOCATABLE :: dX1_dthet(:,:)

theta derivative of X1

real(kind=wp), private, ALLOCATABLE :: dX2_dthet(:,:)

theta derivative of X2

real(kind=wp), private, ALLOCATABLE :: dLA_dthet(:,:)

theta derivative of lambda

real(kind=wp), private, ALLOCATABLE :: dX1_dzeta(:,:)

zeta derivative of X1

real(kind=wp), private, ALLOCATABLE :: dX2_dzeta(:,:)

zeta derivative of X2

real(kind=wp), private, ALLOCATABLE :: dLA_dzeta(:,:)

zeta derivative of lambda

real(kind=wp), private, ALLOCATABLE :: b_thet(:,:)

b_thet=(iota-dlamba_dzeta,1+dlambda_dtheta), normalized contravariant magnetic field

real(kind=wp), private, ALLOCATABLE :: b_zeta(:,:)

b_zeta=1+dlambda_dtheta, normalized contravariant magnetic field

real(kind=wp), private, ALLOCATABLE :: sJ_bcov_thet(:,:)

covariant normalized magnetic field, scaled with 1/J:

real(kind=wp), private, ALLOCATABLE :: sJ_bcov_zeta(:,:)

sJ_bcov_alpha=1/detJ (g_{alpha,theta} b_theta + g_{alpha,zeta) b_zeta)

real(kind=wp), private, ALLOCATABLE :: bbcov_sJ(:,:)

(b^alphag_{alpha,beta}b^beta)/(detJ)

real(kind=wp), private, ALLOCATABLE :: g_tt(:,:)

metric tensor g_(theta,theta)

real(kind=wp), private, ALLOCATABLE :: g_tz(:,:)

metric tensor g_(theta,zeta )=g_(zeta,theta)

real(kind=wp), private, ALLOCATABLE :: g_zz(:,:)

metric tensor g_(zeta ,zeta )

real(kind=wp), private, ALLOCATABLE :: g_t1(:,:)

metric tensor dq^i_dthet G^i1 (sum over i=1,2,3)

real(kind=wp), private, ALLOCATABLE :: g_t2(:,:)

metric tensor dq^i_dthet G^i2

real(kind=wp), private, ALLOCATABLE :: g_z1(:,:)

metric tensor dq^i_dzeta G^i1

real(kind=wp), private, ALLOCATABLE :: g_z2(:,:)

metric tensor dq^i_dzeta G^i2

real(kind=wp), private, ALLOCATABLE :: Jh_dq1(:,:)

hmap dJh/dq1

real(kind=wp), private, ALLOCATABLE :: Jh_dq2(:,:)

hmap dJh/dq2

real(kind=wp), private, ALLOCATABLE :: gtt_dq1(:,:)

hmap dg_{thet,theta}/dq1

real(kind=wp), private, ALLOCATABLE :: gtz_dq1(:,:)

hmap dg_{theta,zeta}/dq1

real(kind=wp), private, ALLOCATABLE :: gzz_dq1(:,:)

hmap dg_{zeta,zeta}/dq1

real(kind=wp), private, ALLOCATABLE :: gtt_dq2(:,:)

hmap dg_{thet,theta}/dq2

real(kind=wp), private, ALLOCATABLE :: gtz_dq2(:,:)

hmap dg_{theta,zeta}/dq2

real(kind=wp), private, ALLOCATABLE :: gzz_dq2(:,:)

hmap dg_{zeta,zeta}/dq2

real(kind=wp), private, ALLOCATABLE :: Gh11(:,:)

hmap G_{11}

real(kind=wp), private, ALLOCATABLE :: Gh22(:,:)

hmap G_{22}

integer, private :: nGP
integer, private :: nGP_str
integer, private :: nGP_end
integer, private :: mn_IP
real(kind=wp), private :: dthet_dzeta
real(kind=wp), private, ALLOCATABLE :: w_GP(:)
integer, private :: nElems
integer, private :: nElems_str
integer, private :: nElems_end
integer, private :: degGP
real(kind=wp), private, ALLOCATABLE :: s_GP(:)
real(kind=wp), private, ALLOCATABLE :: zeta_IP(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX1_tt(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX1_tz(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX1_zz(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX1(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX1_ss(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX2_tt(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX2_tz(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX2_zz(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX2(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DX2_ss(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DLA_tt(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DLA_tz(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: DLA_zz(:)
real(kind=wp), private, CONTIGUOUS, POINTER :: D_buf(:,:)

2d array container for all 1d array abpove (is the one allocated)

class(sll_c_spline_matrix), private, ALLOCATABLE :: precond_X1(:)

container for preconditioner matrices

class(sll_c_spline_matrix), private, ALLOCATABLE :: precond_X2(:)

container for preconditioner matrices

class(sll_c_spline_matrix), private, ALLOCATABLE :: precond_LA(:)

container for preconditioner matrices


Functions

public function EvalEnergy(Uin, callEvalAux, JacCheck) result(W_MHD3D)

Evaluate 3D MHD energy NOTE: set callEvalaux >0 if not called before for the same Uin !!

Arguments

Type IntentOptional Attributes Name
class(t_sol_var_MHD3D), intent(in) :: Uin

input solution

logical, intent(in) :: callEvalAux

set True if evalAux was not called on Uin

integer, intent(inout) :: JacCheck

if 1 on input: abort if detJ<0. if 2 on input, no abort, unchanged if detJ>0 ,return -1 if detJ<=0

Return Value real(kind=wp)

total integral of MHD3D energy W_MHD3D= int ( p/(gamma-1) + 1/(2mu_0) |B|^2) detJ ds dtheta dzeta


Subroutines

public subroutine InitializeMHD3D_evalFunc()

Initialize Module

Arguments

None

public subroutine InitProfilesGP()

Initialise Profiles at GP!!!

Arguments

None

public subroutine EvalAux(Uin, JacCheck)

Evaluate auxiliary variables at input state, writes onto module variables!!!

Arguments

Type IntentOptional Attributes Name
class(t_sol_var_MHD3D), intent(in) :: Uin

input solution

integer, intent(inout) :: JacCheck

if 1 on input: abort if detJ<0. if 2 on input, no abort, unchanged if detJ>0 ,return -1 if detJ<=0

public subroutine EvalTotals(Uin, vol, surfAvg)

Evaluate total volume and average surface

Arguments

Type IntentOptional Attributes Name
class(t_sol_var_MHD3D), intent(in) :: Uin

input solution

real(kind=wp), intent(out) :: vol

total integral of the volume

real(kind=wp), intent(out) :: surfAvg

average polodial surface

public subroutine EvalForce(Uin, callEvalAux, JacCheck, F_MHD3D, noBC)

Evaluate the variation of the Energy = Force... F_j=-(D_U W(U))_j = -DW(u_h)*testfunc_j NOTE: set callEvalaux TRUE if not called before for the same Uin !!

Read more…

Arguments

Type IntentOptional Attributes Name
class(t_sol_var_MHD3D), intent(in) :: Uin

input solution

logical, intent(in) :: callEvalAux

set True if evalAux was not called on Uin

integer, intent(inout) :: JacCheck

if 1 on input: abort if detJ<0. if 2 on input, no abort, unchanged if detJ>0 ,return -1 if detJ<=0

class(t_sol_var_MHD3D), intent(inout) :: F_MHD3D

variation of the energy projected onto the basis functions of Uin

logical, intent(in), optional :: noBC

private subroutine ApplyBC_Fstrong(whichVar, F_MHD3D)

Applies strong boundary condition to force DOF

Arguments

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

=1: X1, =2: X2, =3: LA

class(t_sol_var_MHD3D), intent(inout) :: F_MHD3D

variation of the energy projected onto the basis functions of Uin

private subroutine BuildPrecond()

Build preconditioner matrices for X1,X2,LA and factorize, for all modes the matrix is only radially dependent, and has the form K_ij = int(s,0,1) d/ds sbase_i(s) (s) d/ds sbase_j(s) + sbase_i(s) ((s) + |Phi'(s)|^2 (-m^2 (s) - n^2 (s) ) ) sbase_j(s) where < > denote an average over the angular coordinates

Read more…

Arguments

None

private subroutine ApplyPrecond(nBase, precond, F_inout)

Apply preconditioner matrix for single mode of one variable

Arguments

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

length of inout vector

type(sll_t_spline_matrix_banded), intent(in) :: precond

preconditioner matrix (factorized!)

real(kind=wp), intent(inout) :: F_inout(1:nBase)

apply preconditioner on this force vector

public subroutine FinalizeMHD3D_EvalFunc()

Finalize Module

Arguments

None