Skip to content

Commit

Permalink
adding analytic_profiles_ACC routines, and radiation to GCeOM_ACC rou…
Browse files Browse the repository at this point in the history
…tine
  • Loading branch information
mbeidler3 committed May 23, 2024
1 parent 9e3354b commit 43e018c
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 18 deletions.
54 changes: 39 additions & 15 deletions src/korc_collisions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,7 @@ function CF_FIO(params,v)
end function CF_FIO

function CF_SD(params,v,ne,Te,P,Y_R,Y_Z)
!$acc routine seq
TYPE(KORC_PARAMS), INTENT(IN) :: params
REAL(rp), INTENT(IN) :: v
REAL(rp), INTENT(IN) :: ne
Expand All @@ -1431,6 +1432,12 @@ function CF_SD(params,v,ne,Te,P,Y_R,Y_Z)
TYPE(PROFILES), INTENT(IN) :: P
REAL(rp), INTENT(IN) :: Y_R,Y_Z

!$acc routine (VTe) seq
!$acc routine (Gammacee) seq
!$acc routine (psi) seq
!$acc routine (h_j) seq
!$acc routine (CLogee) seq

x = v/VTe(Te)
CF_SD = Gammacee(v,ne,Te)*psi(x)/Te

Expand Down Expand Up @@ -1627,6 +1634,7 @@ function CB_ee_SD(v,ne,Te,Zeff)
end function CB_ee_SD

function CB_ei_SD(params,v,ne,Te,Zeff,P,Y_R,Y_Z)
!$acc routine seq
TYPE(KORC_PARAMS), INTENT(IN) :: params
REAL(rp), INTENT(IN) :: v
REAL(rp), INTENT(IN) :: ne
Expand All @@ -1639,6 +1647,12 @@ function CB_ei_SD(params,v,ne,Te,Zeff,P,Y_R,Y_Z)
TYPE(PROFILES), INTENT(IN) :: P
REAL(rp), INTENT(IN) :: Y_R,Y_Z

!$acc routine (VTe) seq
!$acc routine (Gammacee) seq
!$acc routine (CLogei) seq
!$acc routine (CLogee) seq
!$acc routine (g_j) seq

x = v/VTe(Te)
CB_ei_SD = (0.5_rp*Gammacee(v,ne,Te)/v)* &
(Zeff*CLogei(v,ne,Te)/CLogee(v,ne,Te))
Expand Down Expand Up @@ -2622,8 +2636,9 @@ subroutine include_CoulombCollisions_GC_p(tt,params,Y_R,Y_PHI,Y_Z, &

end subroutine include_CoulombCollisions_GC_p

subroutine include_CoulombCollisions_GC_p_ACC(pp,tt,params,Y_R,Y_PHI,Y_Z, &
Ppll,Pmu,me,flagCon,flagCol,F,P,E_PHI,ne,Te,Zeff,nimp,PSIp)
subroutine include_CoulombCollisions_GC_p_ACC(pp,tt,params, &
Y_R,Y_PHI,Y_Z,Ppll,Pmu,me,flagCon,flagCol,F,P,E_PHI, &
ne,Te,Zeff,nimp,PSIp)
!$acc routine seq
TYPE(PROFILES), INTENT(IN) :: P
TYPE(FIELDS), INTENT(IN) :: F
Expand Down Expand Up @@ -2663,36 +2678,45 @@ subroutine include_CoulombCollisions_GC_p_ACC(pp,tt,params,Y_R,Y_PHI,Y_Z, &
REAL(rp) :: E_PHI_tmp

!$acc routine (calculate_GCfieldswE_p_ACC) seq
!$acc routine (analytical_profiles_p_ACC) seq
!$acc routine (interp_Hcollision_p_ACC) seq
!$acc routine (CA_SD) seq
!$acc routine (dCA_SD) seq
!$acc routine (CF_SD_FIO) seq
!$acc routine (CF_SD) seq
!$acc routine (CB_ee_SD) seq
!$acc routine (CB_ei_SD_FIO) seq
!$acc routine (CB_ei_SD) seq
!$acc routine (get_random_U) seq

if (MODULO(params%it+tt,cparams_ss%subcycling_iterations) .EQ. 0_ip) then
dt = REAL(cparams_ss%subcycling_iterations,rp)*params%dt
time=params%init_time+(params%it-1+tt)*params%dt

#ifdef PSPLINE
call calculate_GCfieldswE_p_ACC(F,Y_R,Y_PHI,Y_Z, &
B_R,B_PHI,B_Z,E_R,E_PHI,E_Z,curlb_R,curlb_PHI,curlb_Z, &
gradB_R,gradB_PHI,gradB_Z,flagCon,PSIp)
#endif

call calculate_GCfieldswE_p_ACC(F,Y_R,Y_PHI,Y_Z,B_R,B_PHI,B_Z, &
E_R,E_PHI,E_Z,curlb_R,curlb_PHI,curlb_Z, &
gradB_R,gradB_PHI,gradB_Z,flagCon,PSIp)

call interp_Hcollision_p_ACC(params,Y_R,Y_PHI,Y_Z,ne,Te,Zeff, &
nAr0,nAr1,nAr2,nAr3,nAr4,nD,nD1,flagCon)
if (params%profile_model(1:10).eq.'ANALYTICAL') then
call analytical_profiles_p_ACC(time,params,Y_R,Y_Z, &
P,F,ne,Te,Zeff,PSIp)
#ifdef PSPLINE
else if (params%profile_model(10:10).eq.'H') then
call interp_Hcollision_p_ACC(params,Y_R,Y_PHI,Y_Z,ne,Te,Zeff, &
nAr0,nAr1,nAr2,nAr3,nAr4,nD,nD1,flagCon)

nimp(1)=nAr0
nimp(2)=nAr1
nimp(3)=nAr2
nimp(4)=nAr3
nimp(5)=nAr4
nimp(6)=nD
nimp(7)=nD1
nimp(1)=nAr0
nimp(2)=nAr1
nimp(3)=nAr2
nimp(4)=nAr3
nimp(5)=nAr4
nimp(6)=nD
nimp(7)=nD1

#endif PSPLINE
endif


E_PHI_tmp=E_PHI
Expand Down
4 changes: 2 additions & 2 deletions src/korc_interp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3942,8 +3942,8 @@ subroutine interp_Hcollision_p(params,pchunk,Y_R,Y_PHI,Y_Z,ne,Te,Zeff, &

end subroutine interp_Hcollision_p

subroutine interp_Hcollision_p_ACC(params,Y_R,Y_PHI,Y_Z,ne,Te,Zeff, &
nAr0,nAr1,nAr2,nAr3,nAr4,nD,nD1,flag_cache)
subroutine interp_Hcollision_p_ACC(params,Y_R,Y_PHI,Y_Z, &
ne,Te,Zeff,nAr0,nAr1,nAr2,nAr3,nAr4,nD,nD1,flag_cache)
!$acc routine seq
TYPE(KORC_PARAMS), INTENT(IN) :: params
REAL(rp),INTENT(IN) :: Y_R,Y_PHI,Y_Z
Expand Down
54 changes: 54 additions & 0 deletions src/korc_ppusher.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8682,8 +8682,14 @@ subroutine GCEoM1_p_ACC(pp,tt,P,F,params,RHS_R,RHS_PHI,RHS_Z,RHS_PLL,RHS_MU, &
INTEGER(ip),INTENT(IN) :: tt
INTEGER,INTENT(IN) :: pp
INTEGER(is),INTENT(OUT) :: flag_cache
INTEGER(is) :: flagCon
REAL(rp) :: time,re_cache,alpha_cache
INTEGER :: thread_num
REAL(rp) :: Zeff,Te,ne,nAr0,nAr1,nAr2,nAr3,nAr4,nD,nD1

ne=-1._rp
Te=-1._rp
Zeff=-1._rp

Bmag = SQRT(B_R*B_R+B_PHI*B_PHI+B_Z*B_Z)

Expand Down Expand Up @@ -8736,6 +8742,54 @@ subroutine GCEoM1_p_ACC(pp,tt,P,F,params,RHS_R,RHS_PHI,RHS_Z,RHS_PLL,RHS_MU, &
bdotBst
RHS_MU=0._rp

if (params%radiation.and.(params%GC_rad_model.eq.'SDE')) then

! write(output_unit_write,*) 'RHS_PLL',RHS_PLL(1)

re_cache=C_RE/params%cpp%length
alpha_cache=C_a

if (.not.params%LargeCollisions) then
time=params%init_time+(params%it-1+tt)*params%dt
else
time=params%init_time+params%it*params%dt+ &
tt*params%coll_per_dump_dt
end if

if (params%profile_model(1:10).eq.'ANALYTICAL') then
call analytical_profiles_p_ACC(time,params,Y_R,Y_Z, &
P,F,ne,Te,Zeff,PSIp)
#ifdef PSPLINE
else if (params%profile_model(10:10).eq.'H') then
call interp_Hcollision_p_ACC(params,Y_R,Y_PHI,Y_Z, &
ne,Te,Zeff,nAr0,nAr1,nAr2,nAr3,nAr4,nD,nD1, &
flagCon)
#endif
endif

!write(6,*) 'Y: ',Y_R,Y_PHI,Y_Z
!write(6,*) 'Profs: ',ne,Te,Zeff

tau_R=6*C_PI*E0/(Bmag*Bmag)

SR_PLL=V_PLL*(1._rp-xi*xi)/tau_R* &
(1._rp/gamgc-gamgc)
SR_MU=-2._rp*V_MU/tau_R* &
(gamgc*(1-xi*xi)+xi*xi/gamgc)

!Normalizations done here
BREM_P=-4._rp*re_cache**2*ne* &
Zeff*(Zeff+1._rp)*alpha_cache* &
(gamgc-1._rp)*(log(2._rp*gamgc)-1._rp/3._rp)
BREM_PLL=xi*BREM_P
BREM_MU=(1._rp-xi*xi)*V_PLL/ &
(Bmag*xi)*BREM_P

RHS_PLL=RHS_PLL+SR_PLL+BREM_PLL
RHS_MU=SR_MU+BREM_MU

end if

end subroutine GCEoM1_p_ACC

#ifdef FIO
Expand Down
Loading

0 comments on commit 43e018c

Please sign in to comment.