Subroutine that initializes fields interpolants.
This subroutine initializes either 2-D or 3-D PSPLINE interpolants using the data of fields in the KORC-dervied-type variable F.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(KORC_PARAMS), | intent(in) | :: | params | Core KORC simulation parameters. |
||
type(FIELDS), | intent(inout) | :: | F | An instance of KORC's derived type FIELDS containing all the information about the fields used in the simulation. See korc_types and korc_fields. |
subroutine initialize_fields_interpolant(params,F)
!! @note Subroutine that initializes fields interpolants. @endnote
!! This subroutine initializes either 2-D or 3-D PSPLINE interpolants
!! using the data of fields in the KORC-dervied-type variable F.
TYPE(KORC_PARAMS), INTENT(IN) :: params
!! Core KORC simulation parameters.
TYPE(FIELDS), INTENT(INOUT) :: F
!! An instance of KORC's derived type FIELDS containing all the information
!! about the fields used in the simulation.
!! See [[korc_types]] and [[korc_fields]].
integer :: ii,jj
if (((params%field_model(1:8) .EQ. 'EXTERNAL').or. &
(params%field_eval.eq.'interp')).and. &
(.not.TRIM(params%field_model).eq.'M3D_C1'.and. &
.not.TRIM(params%field_model).eq.'NIMROD')) then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("* * * * INITIALIZING FIELDS INTERPOLANT * * * *")')
end if
! * * * * * * * * MAGNETIC FIELD * * * * * * * * !
if (F%Bflux.or.F%ReInterp_2x1t.or. &
((params%orbit_model(1:2).eq.'FO').and.F%axisymmetric_fields)) then
write(output_unit_write,*) '2D poloidal flux function'
if(F%ReInterp_2x1t) then
if (.not.(EZspline_allocated(bfield_2d%A))) then
bfield_2d%NR = F%dims(1)
bfield_2d%NZ = F%dims(3)
! Initializing poloidal flux interpolant
call EZspline_init(bfield_2d%A,bfield_2d%NR,bfield_2d%NZ, &
bfield_2d%BCSR,bfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
bfield_2d%A%x1 = F%X%R
bfield_2d%A%x2 = F%X%Z
end if
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(bfield_2d%A, F%PSIp3D(:,F%ind_2x1t,:), &
ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(output_unit_write,'("bfield_2d%A: ",E17.10)') bfield_2d%A%fspl(1,:,:)
if (.not.ALLOCATED(fields_domain%FLAG2D)) &
ALLOCATE(fields_domain%FLAG2D(bfield_2d%NR,bfield_2d%NZ))
fields_domain%FLAG2D = F%FLAG3D(:,F%ind_2x1t,:)
if (.not.ALLOCATED(fields_domain%LCFS2D)) &
ALLOCATE(fields_domain%LCFS2D(bfield_2d%NR,bfield_2d%NZ))
fields_domain%LCFS2D = F%LCFS3D(:,F%ind_2x1t,:)
fields_domain%DR = ABS(F%X%R(2) - F%X%R(1))
fields_domain%DZ = ABS(F%X%Z(2) - F%X%Z(1))
F%Bflux3D = .FALSE.
else
if (EZspline_allocated(bfield_2d%A)) &
call Ezspline_free(bfield_2d%A, ezerr)
bfield_2d%NR = F%dims(1)
bfield_2d%NZ = F%dims(3)
! Initializing poloidal flux interpolant
call EZspline_init(bfield_2d%A,bfield_2d%NR,bfield_2d%NZ, &
bfield_2d%BCSR,bfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
bfield_2d%A%x1 = F%X%R
bfield_2d%A%x2 = F%X%Z
#if DBG_CHECK
!write(6,*) 'R',F%X%R
!write(6,*) 'Z',F%X%Z
#endif
call EZspline_setup(bfield_2d%A, F%PSIp, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(output_unit_write,'("bfield_2d%A: ",E17.10)') bfield_2d%A%fspl(1,:,:)
if (.not.ALLOCATED(fields_domain%FLAG2D)) &
ALLOCATE(fields_domain%FLAG2D(bfield_2d%NR,bfield_2d%NZ))
fields_domain%FLAG2D = F%FLAG2D
if (.not.ALLOCATED(fields_domain%LCFS2D)) &
ALLOCATE(fields_domain%LCFS2D(bfield_2d%NR,bfield_2d%NZ))
fields_domain%LCFS2D = F%LCFS2D
fields_domain%DR = ABS(F%X%R(2) - F%X%R(1))
fields_domain%DZ = ABS(F%X%Z(2) - F%X%Z(1))
endif
end if
if(F%B1field) then
if (params%field_model(10:13).eq.'MARS') then
write(output_unit_write,*) '2D n=1 MARS magnetic fields'
b1Refield_2d%NR = F%dims(1)
b1Refield_2d%NZ = F%dims(3)
! Initializing BR1Re interpolant
call EZspline_init(b1Refield_2d%R,b1Refield_2d%NR, &
b1Refield_2d%NZ,b1Refield_2d%BCSR,b1Refield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Refield_2d%R%x1 = F%X%R
b1Refield_2d%R%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Refield_2d%R, F%B1Re_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%B1Re_2D%R(:,200))
!write(6,*) 'B1Re_2D%R',F%B1Re_2D%R(:,200)*params%cpp%Bo
! Initializing BPHI1Re interpolant
call EZspline_init(b1Refield_2d%PHI,b1Refield_2d%NR, &
b1Refield_2d%NZ,b1Refield_2d%BCSR,b1Refield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Refield_2d%PHI%x1 = F%X%R
b1Refield_2d%PHI%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Refield_2d%PHI, F%B1Re_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing BZ1_Re interpolant
call EZspline_init(b1Refield_2d%Z,b1Refield_2d%NR, &
b1Refield_2d%NZ,b1Refield_2d%BCSR,b1Refield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Refield_2d%Z%x1 = F%X%R
b1Refield_2d%Z%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Refield_2d%Z, F%B1Re_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
b1Imfield_2d%NR = F%dims(1)
b1Imfield_2d%NZ = F%dims(3)
! Initializing BR1RIm interpolant
call EZspline_init(b1Imfield_2d%R,b1Imfield_2d%NR, &
b1Imfield_2d%NZ,b1Imfield_2d%BCSR,b1Imfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Imfield_2d%R%x1 = F%X%R
b1Imfield_2d%R%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Imfield_2d%R, F%B1Im_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing BPHI1Im interpolant
call EZspline_init(b1Imfield_2d%PHI,b1Imfield_2d%NR, &
b1Imfield_2d%NZ,b1Imfield_2d%BCSR,b1Imfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Imfield_2d%PHI%x1 = F%X%R
b1Imfield_2d%PHI%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Imfield_2d%PHI, F%B1Im_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing BZ1_Im interpolant
call EZspline_init(b1Imfield_2d%Z,b1Imfield_2d%NR, &
b1Imfield_2d%NZ,b1Imfield_2d%BCSR,b1Imfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Imfield_2d%Z%x1 = F%X%R
b1Imfield_2d%Z%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Imfield_2d%Z, F%B1Im_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
else if (params%field_model(10:14).eq.'AORSA') then
write(output_unit_write,*) '2D AORSA magnetic fields'
flush(output_unit_write)
b1Refield_2dx%NR = F%dims(1)
b1Refield_2dx%NZ = F%dims(3)
! Initializing BX1Re interpolant
call EZspline_init(b1Refield_2dx%X,b1Refield_2dx%NR, &
b1Refield_2dx%NZ,b1Refield_2dx%BCSR,b1Refield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Refield_2dx%X%x1 = F%X%R
b1Refield_2dx%X%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Refield_2dx%X, F%B1Re_2DX%X, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%B1Re_2D%R(:,200))
!write(6,*) 'B1Re_2DX%X',F%B1Re_2DX%X(:,200)*params%cpp%Bo
! Initializing BY1Re interpolant
call EZspline_init(b1Refield_2dx%Y,b1Refield_2dx%NR, &
b1Refield_2dx%NZ,b1Refield_2dx%BCSR,b1Refield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Refield_2dx%Y%x1 = F%X%R
b1Refield_2dx%Y%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Refield_2dx%Y, F%B1Re_2DX%Y, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%B1Re_2D%R(:,200))
!write(6,*) 'B1Re_2D%R',F%B1Re_2D%R(:,200)*params%cpp%Bo
! Initializing BZ1Re interpolant
call EZspline_init(b1Refield_2dx%Z,b1Refield_2dx%NR, &
b1Refield_2dx%NZ,b1Refield_2dx%BCSR,b1Refield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Refield_2dx%Z%x1 = F%X%R
b1Refield_2dx%Z%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Refield_2dx%Z, F%B1Re_2DX%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%B1Re_2D%R(:,200))
!write(6,*) 'B1Re_2D%R',F%B1Re_2D%R(:,200)*params%cpp%Bo
b1Imfield_2dx%NR = F%dims(1)
b1Imfield_2dx%NZ = F%dims(3)
! Initializing BX1Im interpolant
call EZspline_init(b1Imfield_2dx%X,b1Imfield_2dx%NR, &
b1Imfield_2dx%NZ,b1Imfield_2dx%BCSR,b1Imfield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Imfield_2dx%X%x1 = F%X%R
b1Imfield_2dx%X%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Imfield_2dx%X, F%B1Im_2DX%X, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%B1Im_2D%R(:,200))
!write(6,*) 'B1Im_2D%R',F%B1Im_2D%R(:,200)*params%cpp%Bo
! Initializing BY1Im interpolant
call EZspline_init(b1Imfield_2dx%Y,b1Imfield_2dx%NR, &
b1Imfield_2dx%NZ,b1Imfield_2dx%BCSR,b1Imfield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Imfield_2dx%Y%x1 = F%X%R
b1Imfield_2dx%Y%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Imfield_2dx%Y, F%B1Im_2DX%Y, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%B1Im_2D%R(:,200))
!write(6,*) 'B1Im_2D%R',F%B1Im_2D%R(:,200)*params%cpp%Bo
! Initializing BZ1Im interpolant
call EZspline_init(b1Imfield_2dx%Z,b1Imfield_2dx%NR, &
b1Imfield_2dx%NZ,b1Imfield_2dx%BCSR,b1Imfield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
b1Imfield_2dx%Z%x1 = F%X%R
b1Imfield_2dx%Z%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(b1Imfield_2dx%Z, F%B1Im_2DX%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%B1Im_2D%R(:,200))
!write(6,*) 'B1Im_2D%R',F%B1Im_2D%R(:,200)*params%cpp%Bo
endif
end if
if (F%Bflux3D) then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("3D psi potential")')
end if
if(F%Dim2x1t) then
write(output_unit_write,*) '2X1T poloidal flux function'
bfield_2X1T%NR = F%dims(1)
bfield_2X1T%NT = F%dims(2)
bfield_2X1T%NZ = F%dims(3)
call EZspline_init(bfield_2X1T%A, bfield_2X1T%NR, bfield_2X1T%NT, &
bfield_2X1T%NZ,&
bfield_2X1T%BCSR, bfield_2X1T%BCST, bfield_2X1T%BCSZ, ezerr)
call EZspline_error(ezerr)
bfield_2X1T%A%x1 = F%X%R
bfield_2X1T%A%x2 = F%X%PHI
bfield_2X1T%A%x3 = F%X%Z
!write(output_unit_write,*) F%X%PHI
call EZspline_setup(bfield_2X1T%A, F%PSIp3D, ezerr, .TRUE.)
call EZspline_error(ezerr)
if (.not.ALLOCATED(fields_domain%FLAG3D)) &
ALLOCATE(fields_domain%FLAG3D(bfield_2X1T%NR,bfield_2X1T%NT, &
bfield_2X1T%NZ))
fields_domain%FLAG3D = F%FLAG3D
fields_domain%DR = ABS(F%X%R(2) - F%X%R(1))
fields_domain%DT = ABS(F%X%PHI(2) - F%X%PHI(1))
fields_domain%DZ = ABS(F%X%Z(2) - F%X%Z(1))
fields_domain%To = F%X%PHI(1)
else
write(output_unit_write,*) '3D poloidal flux function'
bfield_3d%NR = F%dims(1)
bfield_3d%NPHI = F%dims(2)
bfield_3d%NZ = F%dims(3)
! Initializing R component of interpolant
call EZspline_init(bfield_3d%A, bfield_3d%NR, bfield_3d%NPHI, &
bfield_3d%NZ,&
bfield_3d%BCSR, bfield_3d%BCSPHI, bfield_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
bfield_3d%A%x1 = F%X%R
! bfield_3d%R%x2 = F%X%PHI
bfield_3d%A%x3 = F%X%Z
call EZspline_setup(bfield_3d%A, F%PSIp3D, ezerr, .TRUE.)
call EZspline_error(ezerr)
end if
end if
if (F%Bfield) then
if (F%axisymmetric_fields) then
write(output_unit_write,*) '2D magnetic field'
bfield_2d%NR = F%dims(1)
bfield_2d%NZ = F%dims(3)
! Initializing R component
call EZspline_init(bfield_2d%R,bfield_2d%NR,bfield_2d%NZ, &
bfield_2d%BCSR,bfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
bfield_2d%R%x1 = F%X%R
bfield_2d%R%x2 = F%X%Z
call EZspline_setup(bfield_2d%R, F%B_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing PHI component
call EZspline_init(bfield_2d%PHI,bfield_2d%NR,bfield_2d%NZ, &
bfield_2d%BCSR,bfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
bfield_2d%PHI%x1 = F%X%R
bfield_2d%PHI%x2 = F%X%Z
call EZspline_setup(bfield_2d%PHI, F%B_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing Z component
call EZspline_init(bfield_2d%Z,bfield_2d%NR,bfield_2d%NZ, &
bfield_2d%BCSR,bfield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
bfield_2d%Z%x1 = F%X%R
bfield_2d%Z%x2 = F%X%Z
call EZspline_setup(bfield_2d%Z, F%B_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
! do ii=1_idef,bfield_2d%PHI%n1
! do jj=1_idef,bfield_2d%PHI%n2
! write(output_unit_write,'("BPHI_spline1 at R ",E17.10,", Z ",E17.10,": ",E17.10)') &
! bfield_2d%PHI%x1(ii)*params%cpp%length, &
! bfield_2d%PHI%x2(jj)*params%cpp%length, &
! bfield_2d%PHI%fspl(1,ii,jj)*params%cpp%Bo
! end do
! end do
if (params%orbit_model.eq.'GCpre') then
write(output_unit_write,*) '2D precalculated auxiliary fields'
gradB_2d%NR = F%dims(1)
gradB_2d%NZ = F%dims(3)
! Initializing GRADBR component
call EZspline_init(gradB_2d%R,gradB_2d%NR,gradB_2d%NZ, &
gradB_2d%BCSR,gradB_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
gradB_2d%R%x1 = F%X%R
gradB_2d%R%x2 = F%X%Z
call EZspline_setup(gradB_2d%R, F%gradB_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing GRADBPHI component
call EZspline_init(gradB_2d%PHI,gradB_2d%NR,gradB_2d%NZ, &
gradB_2d%BCSR,gradB_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
gradB_2d%PHI%x1 = F%X%R
gradB_2d%PHI%x2 = F%X%Z
call EZspline_setup(gradB_2d%PHI, F%gradB_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing GRADBZ component
call EZspline_init(gradB_2d%Z,gradB_2d%NR,gradB_2d%NZ, &
gradB_2d%BCSR,gradB_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
gradB_2d%Z%x1 = F%X%R
gradB_2d%Z%x2 = F%X%Z
call EZspline_setup(gradB_2d%Z, F%gradB_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
curlb_2d%NR = F%dims(1)
curlb_2d%NZ = F%dims(3)
! Initializing CURLBR component
call EZspline_init(curlb_2d%R,curlb_2d%NR,curlb_2d%NZ, &
curlb_2d%BCSR,curlb_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
curlb_2d%R%x1 = F%X%R
curlb_2d%R%x2 = F%X%Z
call EZspline_setup(curlb_2d%R, F%curlb_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing CURLBPHI component
call EZspline_init(curlb_2d%PHI,curlb_2d%NR,curlb_2d%NZ, &
curlb_2d%BCSR,curlb_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
curlb_2d%PHI%x1 = F%X%R
curlb_2d%PHI%x2 = F%X%Z
call EZspline_setup(curlb_2d%PHI, F%curlb_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing CURLBZ component
call EZspline_init(curlb_2d%Z,curlb_2d%NR,curlb_2d%NZ, &
curlb_2d%BCSR,curlb_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
curlb_2d%Z%x1 = F%X%R
curlb_2d%Z%x2 = F%X%Z
call EZspline_setup(curlb_2d%Z, F%curlb_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
end if
if (.not.ALLOCATED(fields_domain%FLAG2D)) &
ALLOCATE(fields_domain%FLAG2D(bfield_2d%NR,bfield_2d%NZ))
fields_domain%FLAG2D = F%FLAG2D
if (.not.ALLOCATED(fields_domain%LCFS2D)) &
ALLOCATE(fields_domain%LCFS2D(bfield_2d%NR,bfield_2d%NZ))
fields_domain%LCFS2D = F%LCFS2D
fields_domain%DR = ABS(F%X%R(2) - F%X%R(1))
fields_domain%DZ = ABS(F%X%Z(2) - F%X%Z(1))
else
write(output_unit_write,*) '3D magnetic field'
bfield_3d%NR = F%dims(1)
bfield_3d%NPHI = F%dims(2)
bfield_3d%NZ = F%dims(3)
! Initializing R component of interpolant
call EZspline_init(bfield_3d%R, bfield_3d%NR, bfield_3d%NPHI, &
bfield_3d%NZ,&
bfield_3d%BCSR, bfield_3d%BCSPHI, bfield_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
bfield_3d%R%x1 = F%X%R
bfield_3d%R%x2 = F%X%PHI
bfield_3d%R%x3 = F%X%Z
call EZspline_setup(bfield_3d%R, F%B_3D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,'("bfield_3d%R: ",E17.10)') bfield_3d%R%fspl(1,:,:,:)
!do ii=1_idef,bfield_3d%R%n1
! do jj=1_idef,bfield_3d%R%n3
! write(6,'("BR_spline1 at R ",E17.10,", Z ",E17.10,": ",E17.10)') &
! bfield_3d%R%x1(ii)*params%cpp%length, &
! bfield_3d%R%x3(jj)*params%cpp%length, &
! bfield_3d%R%fspl(1,ii,1,jj)*params%cpp%Bo
! end do
!end do
! Initializing PHI component of interpolant
call EZspline_init(bfield_3d%PHI, bfield_3d%NR, bfield_3d%NPHI, &
bfield_3d%NZ,&
bfield_3d%BCSR, bfield_3d%BCSPHI, bfield_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
bfield_3d%PHI%x1 = F%X%R
bfield_3d%PHI%x2 = F%X%PHI
bfield_3d%PHI%x3 = F%X%Z
call EZspline_setup(bfield_3d%PHI, F%B_3D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(output_unit_write,*) bfield_3d%PHI%x2
! Initializing Z component of interpolant
call EZspline_init(bfield_3d%Z, bfield_3d%NR, bfield_3d%NPHI, &
bfield_3d%NZ,&
bfield_3d%BCSR, bfield_3d%BCSPHI, bfield_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
bfield_3d%Z%x1 = F%X%R
bfield_3d%Z%x2 = F%X%PHI
bfield_3d%Z%x3 = F%X%Z
call EZspline_setup(bfield_3d%Z, F%B_3D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
if (params%orbit_model.eq.'GCpre') then
write(output_unit_write,*) '3D precalculated auxiliary fields'
gradB_3d%NR = F%dims(1)
gradB_3d%NPHI = F%dims(2)
gradB_3d%NZ = F%dims(3)
! Initializing GRADBR component
call EZspline_init(gradB_3d%R,gradB_3d%NR,gradB_3d%NPHI,&
gradB_3d%NZ,gradB_3d%BCSR,gradB_3d%BCSPHI, &
gradB_3d%BCSZ,ezerr)
call EZspline_error(ezerr)
gradB_3d%R%x1 = F%X%R
!gradB_3d%R%x2 = F%X%PHI
gradB_3d%R%x3 = F%X%Z
call EZspline_setup(gradB_3d%R, F%gradB_3D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing GRADBPHI component
call EZspline_init(gradB_3d%PHI,gradB_3d%NR,gradB_3d%NPHI,&
gradB_3d%NZ,gradB_3d%BCSR,gradB_3d%BCSPHI, &
gradB_3d%BCSZ,ezerr)
call EZspline_error(ezerr)
gradB_3d%PHI%x1 = F%X%R
!gradB_3d%PHI%x2 = F%X%PHI
gradB_3d%PHI%x3 = F%X%Z
call EZspline_setup(gradB_3d%PHI, F%gradB_3D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing GRADBZ component
call EZspline_init(gradB_3d%Z,gradB_3d%NR,gradB_3d%NPHI,&
gradB_3d%NZ,gradB_3d%BCSR,gradB_3d%BCSPHI, &
gradB_3d%BCSZ,ezerr)
call EZspline_error(ezerr)
gradB_3d%Z%x1 = F%X%R
!gradB_3d%Z%x2 = F%X%PHI
gradB_3d%Z%x3 = F%X%Z
call EZspline_setup(gradB_3d%Z, F%gradB_3D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
curlb_3d%NR = F%dims(1)
curlb_3d%NPHI = F%dims(2)
curlb_3d%NZ = F%dims(3)
! Initializing CURLBR component
call EZspline_init(curlb_3d%R,curlb_3d%NR,curlb_3d%NPHI,&
curlb_3d%NZ,curlb_3d%BCSR,curlb_3d%BCSPHI, &
curlb_3d%BCSZ,ezerr)
call EZspline_error(ezerr)
curlb_3d%R%x1 = F%X%R
!curlb_3d%R%x2 = F%X%PHI
curlb_3d%R%x3 = F%X%Z
call EZspline_setup(curlb_3d%R, F%curlb_3D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing CURLBPHI component
call EZspline_init(curlb_3d%PHI,curlb_3d%NR,curlb_3d%NPHI,&
curlb_3d%NZ,curlb_3d%BCSR,curlb_3d%BCSPHI, &
curlb_3d%BCSZ,ezerr)
call EZspline_error(ezerr)
curlb_3d%PHI%x1 = F%X%R
!curlb_3d%PHI%x2 = F%X%PHI
curlb_3d%PHI%x3 = F%X%Z
call EZspline_setup(curlb_3d%PHI, F%curlb_3D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing CURLBZ component
call EZspline_init(curlb_3d%Z,curlb_3d%NR,curlb_3d%NPHI,&
curlb_3d%NZ,curlb_3d%BCSR,curlb_3d%BCSPHI, &
curlb_3d%BCSZ,ezerr)
call EZspline_error(ezerr)
curlb_3d%Z%x1 = F%X%R
!curlb_3d%Z%x2 = F%X%PHI
curlb_3d%Z%x3 = F%X%Z
call EZspline_setup(curlb_3d%Z, F%curlb_3D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
end if
ALLOCATE(fields_domain%FLAG3D(bfield_3d%NR,bfield_3d%NPHI, &
bfield_3d%NZ))
fields_domain%FLAG3D = F%FLAG3D
fields_domain%DR = ABS(F%X%R(2) - F%X%R(1))
fields_domain%DPHI = 2.0_rp*C_PI/bfield_3d%NPHI
fields_domain%DZ = ABS(F%X%Z(2) - F%X%Z(1))
end if
end if
if (F%dBfield) then
if (F%axisymmetric_fields) then
write(output_unit_write,*) '2D precalculated gradient fields'
! dBdR
dbdR_2d%NR = F%dims(1)
dbdR_2d%NZ = F%dims(3)
! Initializing R component
call EZspline_init(dbdR_2d%R,dbdR_2d%NR,dbdR_2d%NZ, &
dbdR_2d%BCSR,dbdR_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdR_2d%R%x1 = F%X%R
dbdR_2d%R%x2 = F%X%Z
call EZspline_setup(dbdR_2d%R, F%dBdR_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing PHI component
call EZspline_init(dbdR_2d%PHI,dbdR_2d%NR,dbdR_2d%NZ, &
dbdR_2d%BCSR,dbdR_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdR_2d%PHI%x1 = F%X%R
dbdR_2d%PHI%x2 = F%X%Z
call EZspline_setup(dbdR_2d%PHI, F%dBdR_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing Z component
call EZspline_init(dbdR_2d%Z,dbdR_2d%NR,dbdR_2d%NZ, &
dbdR_2d%BCSR,dbdR_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdR_2d%Z%x1 = F%X%R
dbdR_2d%Z%x2 = F%X%Z
call EZspline_setup(dbdR_2d%Z, F%dBdR_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
!dBdPHI
dbdPHI_2d%NR = F%dims(1)
dbdPHI_2d%NZ = F%dims(3)
! Initializing R component
call EZspline_init(dbdPHI_2d%R,dbdPHI_2d%NR,dbdPHI_2d%NZ, &
dbdPHI_2d%BCSR,dbdPHI_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdPHI_2d%R%x1 = F%X%R
dbdPHI_2d%R%x2 = F%X%Z
call EZspline_setup(dbdPHI_2d%R, F%dBdPHI_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing PHI component
call EZspline_init(dbdPHI_2d%PHI,dbdPHI_2d%NR,dbdPHI_2d%NZ, &
dbdPHI_2d%BCSR,dbdPHI_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdPHI_2d%PHI%x1 = F%X%R
dbdPHI_2d%PHI%x2 = F%X%Z
call EZspline_setup(dbdPHI_2d%PHI, F%dBdPHI_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing Z component
call EZspline_init(dbdPHI_2d%Z,dbdPHI_2d%NR,dbdPHI_2d%NZ, &
dbdPHI_2d%BCSR,dbdPHI_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdPHI_2d%Z%x1 = F%X%R
dbdPHI_2d%Z%x2 = F%X%Z
call EZspline_setup(dbdPHI_2d%Z, F%dBdPHI_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
!dBdZ
dbdZ_2d%NR = F%dims(1)
dbdZ_2d%NZ = F%dims(3)
! Initializing R component
call EZspline_init(dbdZ_2d%R,dbdZ_2d%NR,dbdZ_2d%NZ, &
dbdZ_2d%BCSR,dbdZ_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdZ_2d%R%x1 = F%X%R
dbdZ_2d%R%x2 = F%X%Z
call EZspline_setup(dbdZ_2d%R, F%dBdZ_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing PHI component
call EZspline_init(dbdZ_2d%PHI,dbdZ_2d%NR,dbdZ_2d%NZ, &
dbdZ_2d%BCSR,dbdZ_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdZ_2d%PHI%x1 = F%X%R
dbdZ_2d%PHI%x2 = F%X%Z
call EZspline_setup(dbdZ_2d%PHI, F%dBdZ_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing Z component
call EZspline_init(dbdZ_2d%Z,dbdZ_2d%NR,dbdZ_2d%NZ, &
dbdZ_2d%BCSR,dbdZ_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
dbdZ_2d%Z%x1 = F%X%R
dbdZ_2d%Z%x2 = F%X%Z
call EZspline_setup(dbdZ_2d%Z, F%dBdZ_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
else
write(output_unit_write,*) '3D precalculated gradient fields'
! dBdR
dbdR_3d%NR = F%dims(1)
dbdR_3d%NPHI = F%dims(2)
dbdR_3d%NZ = F%dims(3)
! Initializing R component of interpolant
call EZspline_init(dbdR_3d%R, dbdR_3d%NR, dbdR_3d%NPHI, &
dbdR_3d%NZ,&
dbdR_3d%BCSR, dbdR_3d%BCSPHI, dbdR_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdR_3d%R%x1 = F%X%R
! dbdR_3d%R%x2 = F%X%PHI
dbdR_3d%R%x3 = F%X%Z
call EZspline_setup(dbdR_3d%R, F%dBdR_3D%R, ezerr)
call EZspline_error(ezerr)
! Initializing PHI component of interpolant
call EZspline_init(dbdR_3d%PHI, dbdR_3d%NR, dbdR_3d%NPHI, &
dbdR_3d%NZ,&
dbdR_3d%BCSR, dbdR_3d%BCSPHI, dbdR_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdR_3d%PHI%x1 = F%X%R
! dbdR_3d%PHI%x2 = F%X%PHI
dbdR_3d%PHI%x3 = F%X%Z
call EZspline_setup(dbdR_3d%PHI, F%dBdR_3D%PHI, ezerr)
call EZspline_error(ezerr)
!write(output_unit_write,*) dbdR_3d%PHI%x2
! Initializing Z component of interpolant
call EZspline_init(dbdR_3d%Z, dbdR_3d%NR, dbdR_3d%NPHI, &
dbdR_3d%NZ,&
dbdR_3d%BCSR, dbdR_3d%BCSPHI, dbdR_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdR_3d%Z%x1 = F%X%R
! dbdR_3d%Z%x2 = F%X%PHI
dbdR_3d%Z%x3 = F%X%Z
call EZspline_setup(dbdR_3d%Z, F%dBdR_3D%Z, ezerr)
call EZspline_error(ezerr)
!dBdPHI
dbdPHI_3d%NR = F%dims(1)
dbdPHI_3d%NPHI = F%dims(2)
dbdPHI_3d%NZ = F%dims(3)
! Initializing R component of interpolant
call EZspline_init(dbdPHI_3d%R, dbdPHI_3d%NR, dbdPHI_3d%NPHI, &
dbdPHI_3d%NZ,&
dbdPHI_3d%BCSR, dbdPHI_3d%BCSPHI, dbdPHI_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdPHI_3d%R%x1 = F%X%R
! dbdPHI_3d%R%x2 = F%X%PHI
dbdPHI_3d%R%x3 = F%X%Z
call EZspline_setup(dbdPHI_3d%R, F%dBdPHI_3D%R, ezerr)
call EZspline_error(ezerr)
! Initializing PHI component of interpolant
call EZspline_init(dbdPHI_3d%PHI, dbdPHI_3d%NR, dbdPHI_3d%NPHI, &
dbdPHI_3d%NZ,&
dbdPHI_3d%BCSR, dbdPHI_3d%BCSPHI, dbdPHI_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdPHI_3d%PHI%x1 = F%X%R
! dbdPHI_3d%PHI%x2 = F%X%PHI
dbdPHI_3d%PHI%x3 = F%X%Z
call EZspline_setup(dbdPHI_3d%PHI, F%dBdPHI_3D%PHI, ezerr)
call EZspline_error(ezerr)
!write(output_unit_write,*) dbdPHI_3d%PHI%x2
! Initializing Z component of interpolant
call EZspline_init(dbdPHI_3d%Z, dbdPHI_3d%NR, dbdPHI_3d%NPHI, &
dbdPHI_3d%NZ,&
dbdPHI_3d%BCSR, dbdPHI_3d%BCSPHI, dbdPHI_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdPHI_3d%Z%x1 = F%X%R
! dbdPHI_3d%Z%x2 = F%X%PHI
dbdPHI_3d%Z%x3 = F%X%Z
call EZspline_setup(dbdPHI_3d%Z, F%dBdPHI_3D%Z, ezerr)
call EZspline_error(ezerr)
!dBdZ
dbdZ_3d%NR = F%dims(1)
dbdZ_3d%NPHI = F%dims(2)
dbdZ_3d%NZ = F%dims(3)
! Initializing R component of interpolant
call EZspline_init(dbdZ_3d%R, dbdZ_3d%NR, dbdZ_3d%NPHI, &
dbdZ_3d%NZ,&
dbdZ_3d%BCSR, dbdZ_3d%BCSPHI, dbdZ_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdZ_3d%R%x1 = F%X%R
! dbdZ_3d%R%x2 = F%X%PHI
dbdZ_3d%R%x3 = F%X%Z
call EZspline_setup(dbdZ_3d%R, F%dBdZ_3D%R, ezerr)
call EZspline_error(ezerr)
! Initializing PHI component of interpolant
call EZspline_init(dbdZ_3d%PHI, dbdZ_3d%NR, dbdZ_3d%NPHI, &
dbdZ_3d%NZ,&
dbdZ_3d%BCSR, dbdZ_3d%BCSPHI, dbdZ_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdZ_3d%PHI%x1 = F%X%R
! dbdZ_3d%PHI%x2 = F%X%PHI
dbdZ_3d%PHI%x3 = F%X%Z
call EZspline_setup(dbdZ_3d%PHI, F%dBdZ_3D%PHI, ezerr)
call EZspline_error(ezerr)
!write(output_unit_write,*) dbdZ_3d%PHI%x2
! Initializing Z component of interpolant
call EZspline_init(dbdZ_3d%Z, dbdZ_3d%NR, dbdZ_3d%NPHI, &
dbdZ_3d%NZ,&
dbdZ_3d%BCSR, dbdZ_3d%BCSPHI, dbdZ_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
dbdZ_3d%Z%x1 = F%X%R
! dbdZ_3d%Z%x2 = F%X%PHI
dbdZ_3d%Z%x3 = F%X%Z
call EZspline_setup(dbdZ_3d%Z, F%dBdZ_3D%Z, ezerr)
call EZspline_error(ezerr)
end if
end if
fields_domain%Ro = F%X%R(1)
fields_domain%Zo = F%X%Z(1)
! * * * * * * * * ELECTRIC FIELD * * * * * * * * !
if (F%Efield.AND.(params%field_eval.eq.'interp')) then
if (F%axisymmetric_fields) then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,*) '2D electric fields'
endif
if(F%ReInterp_2x1t) then
if (.not.(EZspline_allocated(efield_2d%PHI))) then
efield_2d%NR = F%dims(1)
efield_2d%NZ = F%dims(3)
! Initializing R component
call EZspline_init(efield_2d%R,efield_2d%NR,efield_2d%NZ, &
efield_2d%BCSR,efield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
efield_2d%R%x1 = F%X%R
efield_2d%R%x2 = F%X%Z
! Initializing PHI component
call EZspline_init(efield_2d%PHI,efield_2d%NR,efield_2d%NZ, &
efield_2d%BCSR,efield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
efield_2d%PHI%x1 = F%X%R
efield_2d%PHI%x2 = F%X%Z
! Initializing Z component
call EZspline_init(efield_2d%Z,efield_2d%NR,efield_2d%NZ, &
efield_2d%BCSR,efield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
efield_2d%Z%x1 = F%X%R
efield_2d%Z%x2 = F%X%Z
end if
call EZspline_setup(efield_2d%R, F%E_3D%R(:,F%ind_2x1t,:), &
ezerr, .TRUE.)
call EZspline_error(ezerr)
call EZspline_setup(efield_2d%PHI, F%E_3D%PHI(:,F%ind_2x1t,:), &
ezerr, .TRUE.)
call EZspline_error(ezerr)
call EZspline_setup(efield_2d%Z, F%E_3D%Z(:,F%ind_2x1t,:), &
ezerr, .TRUE.)
call EZspline_error(ezerr)
! write(output_unit_write,'("efield_2d%PHI: ",E17.10)') efield_2d%PHI%fspl(1,:,:)
else
efield_2d%NR = F%dims(1)
efield_2d%NZ = F%dims(3)
! Initializing R component
call EZspline_init(efield_2d%R,efield_2d%NR,efield_2d%NZ, &
efield_2d%BCSR,efield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
efield_2d%R%x1 = F%X%R
efield_2d%R%x2 = F%X%Z
call EZspline_setup(efield_2d%R, F%E_2D%R, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing PHI component
call EZspline_init(efield_2d%PHI,efield_2d%NR,efield_2d%NZ, &
efield_2d%BCSR,efield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
efield_2d%PHI%x1 = F%X%R
efield_2d%PHI%x2 = F%X%Z
call EZspline_setup(efield_2d%PHI, F%E_2D%PHI, ezerr, .TRUE.)
call EZspline_error(ezerr)
! Initializing Z component
call EZspline_init(efield_2d%Z,efield_2d%NR,efield_2d%NZ, &
efield_2d%BCSR,efield_2d%BCSZ,ezerr)
call EZspline_error(ezerr)
efield_2d%Z%x1 = F%X%R
efield_2d%Z%x2 = F%X%Z
call EZspline_setup(efield_2d%Z, F%E_2D%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
end if
else
write(output_unit_write,*) '3D electric fields'
efield_3d%NR = F%dims(1)
efield_3d%NPHI = F%dims(2)
efield_3d%NZ = F%dims(3)
! Initializing R component of interpolant
call EZspline_init(efield_3d%R, efield_3d%NR, efield_3d%NPHI, efield_3d%NZ,&
efield_3d%BCSR, efield_3d%BCSPHI, efield_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
efield_3d%R%x1 = F%X%R
! efield_3d%R%x2 = F%X%PHI
efield_3d%R%x3 = F%X%Z
call EZspline_setup(efield_3d%R, F%E_3D%R, ezerr)
call EZspline_error(ezerr)
! Initializing PHI component of interpolant
call EZspline_init(efield_3d%PHI, efield_3d%NR, efield_3d%NPHI, &
efield_3d%NZ,efield_3d%BCSR, efield_3d%BCSPHI, efield_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
efield_3d%PHI%x1 = F%X%R
! efield_3d%PHI%x2 = F%X%PHI
efield_3d%PHI%x3 = F%X%Z
call EZspline_setup(efield_3d%PHI, F%E_3D%PHI, ezerr)
call EZspline_error(ezerr)
! Initializing Z component of interpolant
call EZspline_init(efield_3d%Z, efield_3d%NR, efield_3d%NPHI, efield_3d%NZ,&
efield_3d%BCSR, efield_3d%BCSPHI, efield_3d%BCSZ, ezerr)
call EZspline_error(ezerr)
efield_3d%Z%x1 = F%X%R
! efield_3d%Z%x2 = F%X%PHI
efield_3d%Z%x3 = F%X%Z
call EZspline_setup(efield_3d%Z, F%E_3D%Z, ezerr)
call EZspline_error(ezerr)
end if
end if
if(F%E1field) then
write(output_unit_write,*) '2D AORSA electric fields'
flush(output_unit_write)
e1Refield_2dx%NR = F%dims(1)
e1Refield_2dx%NZ = F%dims(3)
! Initializing BX1Re interpolant
call EZspline_init(e1Refield_2dx%X,e1Refield_2dx%NR, &
e1Refield_2dx%NZ,e1Refield_2dx%BCSR,e1Refield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
e1Refield_2dx%X%x1 = F%X%R
e1Refield_2dx%X%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(e1Refield_2dx%X, F%E1Re_2DX%X, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%E1Re_2D%R(:,200))
!write(6,*) 'E1Re_2D%R',F%E1Re_2D%R(:,200)*params%cpp%Bo
! Initializing BY1Re interpolant
call EZspline_init(e1Refield_2dx%Y,e1Refield_2dx%NR, &
e1Refield_2dx%NZ,e1Refield_2dx%BCSR,e1Refield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
e1Refield_2dx%Y%x1 = F%X%R
e1Refield_2dx%Y%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(e1Refield_2dx%Y, F%E1Re_2DX%Y, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%E1Re_2D%R(:,200))
!write(6,*) 'E1Re_2D%R',F%E1Re_2D%R(:,200)*params%cpp%Bo
! Initializing BZ1Re interpolant
call EZspline_init(e1Refield_2dx%Z,e1Refield_2dx%NR, &
e1Refield_2dx%NZ,e1Refield_2dx%BCSR,e1Refield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
e1Refield_2dx%Z%x1 = F%X%R
e1Refield_2dx%Z%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(e1Refield_2dx%Z, F%E1Re_2DX%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%E1Re_2D%R(:,200))
!write(6,*) 'E1Re_2D%R',F%E1Re_2D%R(:,200)*params%cpp%Bo
e1Imfield_2dx%NR = F%dims(1)
e1Imfield_2dx%NZ = F%dims(3)
! Initializing BX1Im interpolant
call EZspline_init(e1Imfield_2dx%X,e1Imfield_2dx%NR, &
e1Imfield_2dx%NZ,e1Imfield_2dx%BCSR,e1Imfield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
e1Imfield_2dx%X%x1 = F%X%R
e1Imfield_2dx%X%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(e1Imfield_2dx%X, F%E1Im_2DX%X, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%E1Im_2D%R(:,200))
!write(6,*) 'E1Im_2D%R',F%E1Im_2D%R(:,200)*params%cpp%Bo
! Initializing BY1Im interpolant
call EZspline_init(e1Imfield_2dx%Y,e1Imfield_2dx%NR, &
e1Imfield_2dx%NZ,e1Imfield_2dx%BCSR,e1Imfield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
e1Imfield_2dx%Y%x1 = F%X%R
e1Imfield_2dx%Y%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(e1Imfield_2dx%Y, F%E1Im_2DX%Y, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%E1Im_2D%R(:,200))
!write(6,*) 'E1Im_2D%R',F%E1Im_2D%R(:,200)*params%cpp%Bo
! Initializing BZ1Im interpolant
call EZspline_init(e1Imfield_2dx%Z,e1Imfield_2dx%NR, &
e1Imfield_2dx%NZ,e1Imfield_2dx%BCSR,e1Imfield_2dx%BCSZ,ezerr)
call EZspline_error(ezerr)
e1Imfield_2dx%Z%x1 = F%X%R
e1Imfield_2dx%Z%x2 = F%X%Z
!write(output_unit_write,'("R",E17.10)') F%X%R
!write(output_unit_write,'("Z",E17.10)') F%X%Z
call EZspline_setup(e1Imfield_2dx%Z, F%E1Im_2DX%Z, ezerr, .TRUE.)
call EZspline_error(ezerr)
!write(6,*) 'size',size(F%E1Im_2D%R(:,200))
!write(6,*) 'E1Im_2D%R',F%E1Im_2D%R(:,200)*params%cpp%Bo
end if
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("* * * * * * INTERPOLANT INITIALIZED * * * * * *",/)')
end if
else if (params%field_model(1:10) .EQ. 'ANALYTICAL') then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("* * * * USING ANALYTICAL MAGNETIC FIELD * * * *",/)')
end if
else if (params%field_model .EQ. 'UNIFORM') then
if (params%mpi_params%rank .EQ. 0) then
write(output_unit_write,'("* * * * USING UNIFORM MAGNETIC FIELD * * * *",/)')
end if
end if
end subroutine initialize_fields_interpolant