Subroutine that works as an interface for calling the appropriate subroutines for interpolating or calculating the electric and magnetic fields.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(KORC_PARAMS), | intent(in) | :: | params | Core KORC simulation parameters. |
||
type(PARTICLES), | intent(inout) | :: | prtcls | An instance of PARTICLES containing the variables of a given species. |
||
type(FIELDS), | intent(in) | :: | 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 interp_fields(params,prtcls,F)
!! @note Subroutine that works as an interface for calling the
!! appropriate subroutines for interpolating or calculating the
!! electric and magnetic fields. @endnote
TYPE(KORC_PARAMS), INTENT(IN) :: params
!! Core KORC simulation parameters.
TYPE(PARTICLES), INTENT(INOUT) :: prtcls
!! An instance of PARTICLES containing the variables of a given species.
TYPE(FIELDS), INTENT(IN) :: 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 :: pp
if (.not.params%GC_coords) call cart_to_cyl(prtcls%X,prtcls%Y)
! write(output_unit_write,'("BR: ",E17.10)') prtcls%BR(:,1)
! write(output_unit_write,'("Y: ",E17.10)') prtcls%X(2,1)
! write(output_unit_write,'("Z: ",E17.10)') prtcls%X(3,1)
#ifdef PSPLINE
call check_if_in_fields_domain(F,prtcls%Y, prtcls%flagCon)
call check_if_in_LCFS(F,prtcls%Y, prtcls%initLCFS)
#endif
!write(output_unit_write,*) 'checked domain'
#ifdef FIO
if (TRIM(params%field_model) .eq. 'M3D_C1'.or. &
TRIM(params%field_model) .eq. 'NIMROD') then
if (F%FIO_B .ge. 0) then
!write(6,*) 'interp_fields'
call get_fio_magnetic_fields(prtcls, F, params)
end if
if (F%FIO_E .ge. 0) then
call get_fio_electric_fields(prtcls, F, params)
end if
if (F%FIO_A .ge. 0) then
call get_fio_vector_potential(prtcls, F, params)
end if
do pp=1,sizeof(prtcls%flagCon)
if (prtcls%flagCon(pp)==0.and. &
(.not.(params%restart.OR.params%proceed))) then
write(6,*) 'RE initialized outside of computational domain!!!'
call KORC_ABORT(15)
end if
end do
end if
#endif
#ifdef PSPLINE
if (params%field_model(10:13).eq.'MARS') then
call interp_FOfields_mars(prtcls, F, params)
end if
if (params%field_model(10:14).eq.'AORSA') then
call interp_FOfields_aorsa(prtcls, F, params)
end if
if ((ALLOCATED(F%PSIp).and.F%Bflux).or. &
(F%ReInterp_2x1t.and.(.not.((TRIM(params%field_model).eq.'M3D_C1').or. &
(params%field_model(10:13).eq.'MARS').or. &
(TRIM(params%field_model).eq.'NIMROD'))))) then
! write(output_unit_write,'("3 size of PSI_P: ",I16)') size(prtcls%PSI_P)
! write(output_unit_write,'("B_X: ",E17.10)') prtcls%B(:,1)
! write(output_unit_write,'("B_Z: ",E17.10)') prtcls%B(:,3)
! write(output_unit_write,'("B_Y: ",E17.10)') prtcls%B(:,2)
! write(output_unit_write,'("PSI_P: ",E17.10)') prtcls%PSI_P
call calculate_magnetic_field(params,prtcls%Y,F,prtcls%B,prtcls%E, &
prtcls%PSI_P,prtcls%flagCon)
!write(output_unit_write,*) 'interp PSIp'
! write(output_unit_write,'("interp_fields")')
! write(output_unit_write,'("B_X: ",E17.10)') prtcls%B(:,1)
! write(output_unit_write,'("B_Z: ",E17.10)') prtcls%B(:,3)
! write(output_unit_write,'("B_Y: ",E17.10)') prtcls%B(:,2)
end if
if (ALLOCATED(F%PSIp3D).and.F%Bflux3D) then
! write(output_unit_write,'("3 size of PSI_P: ",I16)') size(prtcls%PSI_P)
! write(output_unit_write,'("B_X: ",E17.10)') prtcls%B(:,1)
! write(output_unit_write,'("B_Z: ",E17.10)') prtcls%B(:,3)
! write(output_unit_write,'("B_Y: ",E17.10)') prtcls%B(:,2)
! write(output_unit_write,'("PSI_P: ",E17.10)') prtcls%PSI_P
call calculate_magnetic_field(params,prtcls%Y,F,prtcls%B,prtcls%E, &
prtcls%PSI_P,prtcls%flagCon)
! write(output_unit_write,'("interp_fields")')
! write(output_unit_write,'("B_X: ",E17.10)') prtcls%B(:,1)
! write(output_unit_write,'("B_Z: ",E17.10)') prtcls%B(:,3)
! write(output_unit_write,'("B_Y: ",E17.10)') prtcls%B(:,2)
end if
if (ALLOCATED(F%B_2D%R).and.F%Bfield) then
call interp_2D_bfields(params,prtcls%Y,prtcls%B,prtcls%flagCon)
end if
if (ALLOCATED(F%B_3D%R).and.F%Bfield) then
call interp_3D_bfields(params,prtcls%Y,prtcls%B,prtcls%flagCon)
end if
! if (ALLOCATED(F%E_2D%R).and.F%Efield) then
! call interp_2D_efields(params,prtcls%Y,prtcls%E,prtcls%flagCon)
! end if
if (ALLOCATED(F%E_3D%R).and.F%Efield.and.(.not.F%ReInterp_2x1t)) then
call interp_3D_efields(params,prtcls%Y,prtcls%E,prtcls%flagCon)
end if
if (ALLOCATED(F%E_3D%R).and.F%Efield.and.F%ReInterp_2x1t) then
call interp_2D_efields(params,prtcls%Y,prtcls%E,prtcls%flagCon)
! write(output_unit_write,*) 'interpolated efield'
end if
if (params%GC_coords.and.ALLOCATED(F%gradB_2D%R).and.F%Bfield) then
call interp_2D_gradBfields(prtcls%Y,prtcls%gradB,prtcls%flagCon)
end if
if (params%GC_coords.and.ALLOCATED(F%gradB_2D%R).and.F%Bfield) then
call interp_2D_curlbfields(prtcls%Y,prtcls%curlb,prtcls%flagCon)
end if
if(params%GC_coords.and.params%orbit_model(3:6)=='grad') then
call gradient_2D_bfields(prtcls%Y,prtcls%BR,prtcls%BPHI, &
prtcls%BZ,prtcls%flagCon)
end if
#endif
end subroutine interp_fields