interp_FOfields_mars_p Subroutine

public subroutine interp_FOfields_mars_p(params, pchunk, F, Y_R, Y_PHI, Y_Z, B_X, B_Y, B_Z, PSIp, flag_cache)

Arguments

Type IntentOptional AttributesName
type(KORC_PARAMS), intent(in) :: params
integer, intent(in) :: pchunk
type(FIELDS), intent(in) :: F
real(kind=rp), intent(in), DIMENSION(pchunk):: Y_R
real(kind=rp), intent(in), DIMENSION(pchunk):: Y_PHI
real(kind=rp), intent(in), DIMENSION(pchunk):: Y_Z
real(kind=rp), intent(out), DIMENSION(pchunk):: B_X
real(kind=rp), intent(out), DIMENSION(pchunk):: B_Y
real(kind=rp), intent(out), DIMENSION(pchunk):: B_Z
real(kind=rp), intent(out), DIMENSION(pchunk):: PSIp
integer(kind=is), intent(inout), DIMENSION(pchunk):: flag_cache

Calls

proc~~interp_fofields_mars_p~~CallsGraph proc~interp_fofields_mars_p interp_FOfields_mars_p ezspline_interp ezspline_interp proc~interp_fofields_mars_p->ezspline_interp proc~check_if_in_fields_domain_p check_if_in_fields_domain_p proc~interp_fofields_mars_p->proc~check_if_in_fields_domain_p ezspline_error ezspline_error proc~interp_fofields_mars_p->ezspline_error

Called by

proc~~interp_fofields_mars_p~~CalledByGraph proc~interp_fofields_mars_p interp_FOfields_mars_p proc~fo_init FO_init proc~fo_init->proc~interp_fofields_mars_p proc~adv_fointerp_mars_top adv_FOinterp_mars_top proc~adv_fointerp_mars_top->proc~interp_fofields_mars_p program~main main program~main->proc~fo_init program~main->proc~adv_fointerp_mars_top

Contents


Source Code

subroutine interp_FOfields_mars_p(params,pchunk,F,Y_R,Y_PHI,Y_Z,B_X,B_Y,B_Z, &
     PSIp,flag_cache)
  TYPE(KORC_PARAMS), INTENT(IN)                              :: params
  INTEGER, INTENT(IN)  :: pchunk
  TYPE(FIELDS), INTENT(IN)                               :: F
  REAL(rp),DIMENSION(pchunk),INTENT(IN)   :: Y_R,Y_PHI,Y_Z
  REAL(rp),DIMENSION(pchunk),INTENT(OUT)   :: B_X,B_Y,B_Z
  REAL(rp),DIMENSION(pchunk)   :: B_R,B_PHI
  REAL(rp),DIMENSION(pchunk)   :: B0_R,B0_PHI,B0_Z
  REAL(rp),DIMENSION(pchunk)   :: B1_R,B1_PHI,B1_Z
  REAL(rp),DIMENSION(pchunk)   :: B1Re_R,B1Re_PHI,B1Re_Z
  REAL(rp),DIMENSION(pchunk)   :: B1Im_R,B1Im_PHI,B1Im_Z
  REAL(rp),DIMENSION(pchunk),INTENT(OUT)   :: PSIp
  REAL(rp),DIMENSION(pchunk)   :: cP,sP
  REAL(rp), DIMENSION(pchunk,3)  :: A
  !  INTEGER(ip) :: ezerr
  INTEGER                                      :: cc
  !! Particle chunk iterator.
  INTEGER(is),DIMENSION(pchunk),INTENT(INOUT)   :: flag_cache
  REAL(rp) :: psip_conv
  REAL(rp) :: amp

  psip_conv=F%psip_conv
  amp=F%AMP
  
  call check_if_in_fields_domain_p(pchunk,F,Y_R,Y_PHI,Y_Z,flag_cache)

  call EZspline_interp(bfield_2d%A,b1Refield_2d%R,b1Refield_2d%PHI, &
       b1Refield_2d%Z,b1Imfield_2d%R,b1Imfield_2d%PHI,b1Imfield_2d%Z, &
       pchunk,Y_R,Y_Z,A,B1Re_R,B1Re_PHI,B1Re_Z,B1Im_R,B1Im_PHI,B1Im_Z,ezerr)
  call EZspline_error(ezerr)

  !$OMP SIMD
  do cc=1_idef,pchunk
     PSIp(cc)=A(cc,1)

     B0_R(cc) = psip_conv*A(cc,3)/Y_R(cc)
     B0_PHI(cc) = -F%Bo*F%Ro/Y_R(cc)
     B0_Z(cc) = -psip_conv*A(cc,2)/Y_R(cc)

     cP(cc)=cos(Y_PHI(cc))
     sP(cc)=sin(Y_PHI(cc))
     
     B1_R(cc) = amp*(B1Re_R(cc)*cP(cc)-B1Im_R(cc)*sP(cc))
     B1_PHI(cc) = amp*(B1Re_PHI(cc)*cP(cc)-B1Im_PHI(cc)*sP(cc))
     B1_Z(cc) = amp*(B1Re_Z(cc)*cP(cc)-B1Im_Z(cc)*sP(cc))

     B_R(cc) = B0_R(cc)+B1_R(cc)
     B_PHI(cc) = B0_PHI(cc)+B1_PHI(cc)
     B_Z(cc) = B0_Z(cc)+B1_Z(cc)
     
     B_X(cc) = B_R(cc)*cP(cc) - B_PHI(cc)*sP(cc)
     B_Y(cc) = B_R(cc)*sP(cc) + B_PHI(cc)*cP(cc)

  end do
  !$OMP END SIMD

  !write(6,*) '(R,PHI,Z)',Y_R*params%cpp%length,Y_PHI*params%cpp%length, &
  !     Y_Z*params%cpp%length
  !write(6,*) 'psi',PSIp*params%cpp%Bo*params%cpp%length**2
  !write(6,*) 'dpsidR',A(:,2)*params%cpp%Bo*params%cpp%length
  !write(6,*) 'dpsidZ',A(:,3)*params%cpp%Bo*params%cpp%length
  !write(6,*) 'B0',B0_R*params%cpp%Bo,B0_PHI*params%cpp%Bo,B0_Z*params%cpp%Bo
  !write(6,*) 'AMP',amp
  !write(6,*) 'B1Re',B1Re_R*params%cpp%Bo,B1Re_PHI*params%cpp%Bo,B1Re_Z*params%cpp%Bo
  !write(6,*) 'B1Im',B1Im_R*params%cpp%Bo,B1Im_PHI*params%cpp%Bo,B1Im_Z*params%cpp%Bo
  !write(6,*) 'B1',B1_R*params%cpp%Bo,B1_PHI*params%cpp%Bo,B1_Z*params%cpp%Bo
  !write(6,*) 'B',B_X*params%cpp%Bo,B_Y*params%cpp%Bo,B_Z*params%cpp%Bo
  
  
end subroutine interp_FOfields_mars_p