Subroutine that initializes plasma profiles interpolants.
This subroutine initializes either 2-D or 3-D PSPLINE interpolants using the data of plasma profiles in the KORC-dervied-type variable P.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(KORC_PARAMS), | intent(in) | :: | params | Core KORC simulation parameters. |
||
type(PROFILES), | intent(inout) | :: | P | An instance of KORC's derived type PROFILES containing all the information about the plasma profiles used in the simulation. See korc_types and korc_profiles. |
subroutine initialize_profiles_interpolant(params,P)
!! @note Subroutine that initializes plasma profiles interpolants. @endnote
!! This subroutine initializes either 2-D or 3-D PSPLINE interpolants
!! using the data of plasma profiles in the KORC-dervied-type variable P.
TYPE(KORC_PARAMS), INTENT(IN) :: params
!! Core KORC simulation parameters.
TYPE(PROFILES), INTENT(INOUT) :: P
!! An instance of KORC's derived type PROFILES containing
!! all the information about the plasma profiles used in the simulation.
!! See [[korc_types]] and [[korc_profiles]].
if (params%collisions) then
if (params%profile_model(1:8) .EQ. 'EXTERNAL') then
if (params%mpi_params%rank .EQ. 0) then
write(6,'("* * * * INITIALIZING PROFILES INTERPOLANT * * * *")')
end if
if (P%axisymmetric) then
profiles_2d%NR = P%dims(1)
profiles_2d%NZ = P%dims(3)
! write(6,'("NR",I15)') profiles_2d%NR
! write(6,'("NZ",I15)') profiles_2d%NR
! Initializing ne
! call EZspline_init(profiles_2d%ne,profiles_2d%NR, &
!profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_init(profiles_2d%ne,profiles_2d%NR,profiles_2d%NZ, &
profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%ne%x1 = P%X%R
profiles_2d%ne%x2 = P%X%Z
call EZspline_setup(profiles_2d%ne, P%ne_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing Te
! call EZspline_init(profiles_2d%Te,profiles_2d%NR, &
!profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_init(profiles_2d%Te,profiles_2d%NR,profiles_2d%NZ, &
profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%Te%x1 = P%X%R
profiles_2d%Te%x2 = P%X%Z
! write(6,'("Te_interp_R",E17.10)') profiles_2d%Te%x1
! write(6,'("Te_interp_Z",E17.10)') profiles_2d%Te%x2
! write(6,'("Te",E17.10)') P%Te_2D(10,:)
call EZspline_setup(profiles_2d%Te, P%Te_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing Zeff
! call EZspline_init(profiles_2d%Zeff, &
!profiles_2d%NR,profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_init(profiles_2d%Zeff,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%Zeff%x1 = P%X%R
profiles_2d%Zeff%x2 = P%X%Z
call EZspline_setup(profiles_2d%Zeff, P%Zeff_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
ALLOCATE(profiles_domain%FLAG2D(profiles_2d%NR,profiles_2d%NZ))
profiles_domain%FLAG2D = P%FLAG2D
profiles_domain%DR = ABS(P%X%R(2) - P%X%R(1))
profiles_domain%DZ = ABS(P%X%Z(2) - P%X%Z(1))
else
profiles_3d%NR = P%dims(1)
profiles_3d%NPHI = P%dims(2)
profiles_3d%NZ = P%dims(3)
! Initializing ne
call EZspline_init(profiles_3d%ne, profiles_3d%NR, &
profiles_3d%NPHI, profiles_3d%NZ,&
profiles_3d%BCSR, profiles_3d%BCSPHI, profiles_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
profiles_3d%ne%x1 = P%X%R
! profiles_3d%ne%x2 = P%X%PHI
profiles_3d%ne%x3 = P%X%Z
call EZspline_setup(profiles_3d%ne, P%ne_3D, ezerr)
call EZspline_error(ezerr)
! Initializing Te
call EZspline_init(profiles_3d%Te, profiles_3d%NR, &
profiles_3d%NPHI, profiles_3d%NZ,&
profiles_3d%BCSR, profiles_3d%BCSPHI, profiles_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
profiles_3d%Te%x1 = P%X%R
! profiles_3d%Te%x2 = P%X%PHI
profiles_3d%Te%x3 = P%X%Z
call EZspline_setup(profiles_3d%Te, P%Te_3D, ezerr)
call EZspline_error(ezerr)
! Initializing Zeff
call EZspline_init(profiles_3d%Zeff, profiles_3d%NR, &
profiles_3d%NPHI, profiles_3d%NZ,&
profiles_3d%BCSR, profiles_3d%BCSPHI, profiles_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
profiles_3d%Zeff%x1 = P%X%R
! profiles_3d%Zeff%x2 = P%X%PHI
profiles_3d%Zeff%x3 = P%X%Z
call EZspline_setup(profiles_3d%Zeff, P%Zeff_3D, ezerr)
call EZspline_error(ezerr)
ALLOCATE(profiles_domain%FLAG3D(profiles_3d%NR,profiles_3d%NPHI, &
profiles_3d%NZ))
profiles_domain%FLAG3D = P%FLAG3D
profiles_domain%DR = ABS(P%X%R(2) - P%X%R(1))
profiles_domain%DPHI = 2.0_rp*C_PI/profiles_3d%NPHI
profiles_domain%DZ = ABS(P%X%Z(2) - P%X%Z(1))
end if
profiles_domain%Ro = P%X%R(1)
profiles_domain%Zo = P%X%Z(1)
if (params%mpi_params%rank .EQ. 0) then
write(6,'("* * * * * * INTERPOLANT INITIALIZED * * * * * *",/)')
end if
else if (params%profile_model(1:10) .EQ. 'ANALYTICAL') then
if (params%mpi_params%rank .EQ. 0) then
write(6,'("* * * * USING ANALYTICAL PROFILES * * * *",/)')
end if
else if (params%profile_model .EQ. 'UNIFORM') then
if (params%mpi_params%rank .EQ. 0) then
write(6,'("* * * * UNIFORM PLASMA: NO PROFILES USED * * * *",/)')
end if
end if
end if
end subroutine initialize_profiles_interpolant