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]].
!#ifdef FIO
! P%FIO_ne = -1
! P%FIO_te = -1
! P%FIO_zeff = -1
!#endif
if (params%collisions.or.params%radiation) then
if (params%profile_model(1:8) .EQ. 'EXTERNAL') then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("* * * * INITIALIZING PROFILES INTERPOLANT * * * *")')
end if
if (P%axisymmetric) then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,*) '2D ne, Te, Zeff'
flush(output_unit_write)
end if
profiles_2d%NR = P%dims(1)
profiles_2d%NZ = P%dims(3)
! write(output_unit_write,'("NR",I15)') profiles_2d%NR
! write(output_unit_write,'("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_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_error(ezerr)
profiles_2d%Te%x1 = P%X%R
profiles_2d%Te%x2 = P%X%Z
! write(output_unit_write,'("Te_interp_R",E17.10)') profiles_2d%Te%x1
! write(output_unit_write,'("Te_interp_Z",E17.10)') profiles_2d%Te%x2
! write(output_unit_write,'("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_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)
if (params%profile_model(10:10) .EQ. 'H') then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,*) '2D Hollmann impurities'
flush(output_unit_write)
end if
! Initializing RHON
call EZspline_init(profiles_2d%RHON,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%RHON%x1 = P%X%R
profiles_2d%RHON%x2 = P%X%Z
call EZspline_setup(profiles_2d%RHON, P%RHON, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(output_unit_write,'("profiles_2d%RHON: ",E17.10)') profiles_2d%RHON%fspl(1,:,:)
! Initializing nRE
call EZspline_init(profiles_2d%nRE,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%nRE%x1 = P%X%R
profiles_2d%nRE%x2 = P%X%Z
call EZspline_setup(profiles_2d%nRE, P%nRE_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing nAr0
call EZspline_init(profiles_2d%nAr0,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%nAr0%x1 = P%X%R
profiles_2d%nAr0%x2 = P%X%Z
call EZspline_setup(profiles_2d%nAr0, P%nAr0_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing nAr1
call EZspline_init(profiles_2d%nAr1,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%nAr1%x1 = P%X%R
profiles_2d%nAr1%x2 = P%X%Z
call EZspline_setup(profiles_2d%nAr1, P%nAr1_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing nAr2
call EZspline_init(profiles_2d%nAr2,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%nAr2%x1 = P%X%R
profiles_2d%nAr2%x2 = P%X%Z
call EZspline_setup(profiles_2d%nAr2, P%nAr2_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing nAr3
call EZspline_init(profiles_2d%nAr3,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%nAr3%x1 = P%X%R
profiles_2d%nAr3%x2 = P%X%Z
call EZspline_setup(profiles_2d%nAr3, P%nAr3_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing nD
call EZspline_init(profiles_2d%nD,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%nD%x1 = P%X%R
profiles_2d%nD%x2 = P%X%Z
call EZspline_setup(profiles_2d%nD, P%nD_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing nD1
call EZspline_init(profiles_2d%nD1,profiles_2d%NR, &
profiles_2d%NZ,profiles_2d%BCSR,profiles_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
profiles_2d%nD1%x1 = P%X%R
profiles_2d%nD1%x2 = P%X%Z
call EZspline_setup(profiles_2d%nD1, P%nD1_2D, ezerr, .TRUE.)
call EZspline_error(ezerr)
end if
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
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,*) '3D ne, Te, Zeff'
end if
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(output_unit_write,'("* * * * * * INTERPOLANT INITIALIZED * * * * * *",/)')
end if
else if (params%profile_model(1:10) .EQ. 'ANALYTICAL') then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("* * * * USING ANALYTICAL PROFILES * * * *",/)')
end if
else if (params%profile_model .EQ. 'UNIFORM') then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("* * * * UNIFORM PLASMA: NO PROFILES USED * * * *",/)')
end if
end if
end if
end subroutine initialize_profiles_interpolant