Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(KORC_PARAMS), | intent(inout) | :: | params | Core KORC simulation parameters. |
||
type(SPECIES), | intent(inout), | DIMENSION(:), ALLOCATABLE | :: | spp | An instance of the derived type SPECIES containing all the parameters and simulation variables of the different species in the simulation. |
|
type(PROFILES), | intent(in) | :: | P | |||
type(FIELDS), | intent(inout) | :: | F |
subroutine adv_GCinterp_psi_top(params,spp,P,F)
TYPE(KORC_PARAMS), INTENT(INOUT) :: params
!! Core KORC simulation parameters.
TYPE(PROFILES), INTENT(IN) :: P
TYPE(FIELDS), INTENT(INOUT) :: F
TYPE(SPECIES), DIMENSION(:), ALLOCATABLE, INTENT(INOUT) :: spp
!! An instance of the derived type SPECIES containing all the parameters
!! and simulation variables of the different species in the simulation.
REAL(rp), DIMENSION(params%pchunk) :: Bmag
REAL(rp),DIMENSION(params%pchunk) :: Y_R,Y_PHI,Y_Z
REAL(rp),DIMENSION(params%pchunk) :: B_R,B_PHI,B_Z
REAL(rp),DIMENSION(params%pchunk) :: E_R,E_PHI,E_Z
REAL(rp),DIMENSION(params%pchunk) :: ne,Te,Zeff
REAL(rp),DIMENSION(params%pchunk) :: V_PLL,V_MU
REAL(rp),DIMENSION(params%pchunk) :: PSIp
REAL(rp),DIMENSION(params%pchunk) :: curlb_R,curlb_PHI,curlb_Z
REAL(rp),DIMENSION(params%pchunk) :: gradB_R,gradB_PHI,gradB_Z
INTEGER(is),DIMENSION(params%pchunk) :: flagCon,flagCol
REAL(rp) :: m_cache,q_cache,B0,EF0,R0,q0,lam,ar
INTEGER :: ii
!! Species iterator.
INTEGER :: pp
!! Particles iterator.
INTEGER :: cc,pchunk,achunk
!! Chunk iterator.
INTEGER(ip) :: tt
INTEGER(ip) :: ttt
!! time iterator.
do ii = 1_idef,params%num_species
pchunk=params%pchunk
q_cache=spp(ii)%q
m_cache=spp(ii)%m
if (.not.params%LargeCollisions) then
!$OMP PARALLEL DO default(none) &
!$OMP& FIRSTPRIVATE(q_cache,m_cache,pchunk) &
!$OMP& SHARED(params,ii,spp,P,F) &
!$OMP& PRIVATE(pp,tt,Bmag,cc,Y_R,Y_PHI,Y_Z,V_PLL,V_MU,B_R,B_PHI,B_Z, &
!$OMP& flagCon,flagCol,E_PHI,PSIp,curlb_R,curlb_PHI,curlb_Z, &
!$OMP& gradB_R,gradB_PHI,gradB_Z,ne,E_R,E_Z)
do pp=1_idef,spp(ii)%ppp,pchunk
! write(output_unit_write,'("pp: ",I16)') pp
!$OMP SIMD
do cc=1_idef,pchunk
Y_R(cc)=spp(ii)%vars%Y(pp-1+cc,1)
Y_PHI(cc)=spp(ii)%vars%Y(pp-1+cc,2)
Y_Z(cc)=spp(ii)%vars%Y(pp-1+cc,3)
V_PLL(cc)=spp(ii)%vars%V(pp-1+cc,1)
V_MU(cc)=spp(ii)%vars%V(pp-1+cc,2)
PSIp(cc)=spp(ii)%vars%PSI_P(pp-1+cc)
flagCon(cc)=spp(ii)%vars%flagCon(pp-1+cc)
flagCol(cc)=spp(ii)%vars%flagCol(pp-1+cc)
end do
!$OMP END SIMD
if (.not.params%FokPlan) then
do tt=1_ip,params%t_skip
call advance_GCinterp_psi_vars(pchunk,spp(ii)%vars,pp,tt, &
params,Y_R,Y_PHI,Y_Z,V_PLL,V_MU,q_cache,m_cache, &
flagCon,flagCol,F,P,B_R,B_PHI,B_Z,E_PHI,PSIp, &
curlb_R,curlb_PHI,curlb_Z,gradB_R,gradB_PHI,gradB_Z,ne)
if (params%collisions) then
call include_CoulombCollisions_GC_p(tt,params, &
Y_R,Y_PHI,Y_Z,V_PLL,V_MU,m_cache,flagCon,flagCol, &
F,P,E_PHI,ne,PSIp)
end if
end do !timestep iterator
!$OMP SIMD
do cc=1_idef,pchunk
spp(ii)%vars%Y(pp-1+cc,1)=Y_R(cc)
spp(ii)%vars%Y(pp-1+cc,2)=Y_PHI(cc)
spp(ii)%vars%Y(pp-1+cc,3)=Y_Z(cc)
spp(ii)%vars%V(pp-1+cc,1)=V_PLL(cc)
spp(ii)%vars%V(pp-1+cc,2)=V_MU(cc)
spp(ii)%vars%flagCon(pp-1+cc)=flagCon(cc)
spp(ii)%vars%flagCol(pp-1+cc)=flagCol(cc)
spp(ii)%vars%B(pp-1+cc,1) = B_R(cc)
spp(ii)%vars%B(pp-1+cc,2) = B_PHI(cc)
spp(ii)%vars%B(pp-1+cc,3) = B_Z(cc)
spp(ii)%vars%gradB(pp-1+cc,1) = gradB_R(cc)
spp(ii)%vars%gradB(pp-1+cc,2) = gradB_PHI(cc)
spp(ii)%vars%gradB(pp-1+cc,3) = gradB_Z(cc)
spp(ii)%vars%curlb(pp-1+cc,1) = curlb_R(cc)
spp(ii)%vars%curlb(pp-1+cc,2) = curlb_PHI(cc)
spp(ii)%vars%curlb(pp-1+cc,3) = curlb_Z(cc)
spp(ii)%vars%E(pp-1+cc,2) = E_PHI(cc)
spp(ii)%vars%PSI_P(pp-1+cc) = PSIp(cc)
spp(ii)%vars%ne(pp-1+cc) = ne(cc)
end do
!$OMP END SIMD
else if (params%FokPlan.and.params%collisions) then
call advance_FPinterp_vars(params,Y_R,Y_PHI, &
Y_Z,V_PLL,V_MU,m_cache,flagCon,flagCol,F,P,E_PHI,ne,PSIp)
!$OMP SIMD
do cc=1_idef,pchunk
spp(ii)%vars%V(pp-1+cc,1)=V_PLL(cc)
spp(ii)%vars%V(pp-1+cc,2)=V_MU(cc)
spp(ii)%vars%flagCol(pp-1+cc)=flagCol(cc)
spp(ii)%vars%E(pp-1+cc,2) = E_PHI(cc)
spp(ii)%vars%ne(pp-1+cc) = ne(cc)
end do
!$OMP END SIMD
else
do tt=1_ip,params%t_skip
call calculate_GCfields_p(pchunk,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)
end do
!$OMP SIMD
do cc=1_idef,pchunk
spp(ii)%vars%B(pp-1+cc,1) = B_R(cc)
spp(ii)%vars%B(pp-1+cc,2) = B_PHI(cc)
spp(ii)%vars%B(pp-1+cc,3) = B_Z(cc)
spp(ii)%vars%E(pp-1+cc,2) = E_PHI(cc)
spp(ii)%vars%PSI_P(pp-1+cc) = PSIp(cc)
end do
!$OMP END SIMD
end if
!$OMP SIMD
do cc=1_idef,pchunk
B_R(cc)=spp(ii)%vars%B(pp-1+cc,1)
B_PHI(cc)=spp(ii)%vars%B(pp-1+cc,2)
B_Z(cc)=spp(ii)%vars%B(pp-1+cc,3)
Bmag(cc)=sqrt(B_R(cc)*B_R(cc)+B_PHI(cc)*B_PHI(cc)+ &
B_Z(cc)*B_Z(cc))
spp(ii)%vars%g(pp-1+cc)=sqrt(1+V_PLL(cc)**2+ &
2*V_MU(cc)*Bmag(cc))
spp(ii)%vars%eta(pp-1+cc) = atan2(sqrt(2*m_cache*Bmag(cc)* &
spp(ii)%vars%V(pp-1+cc,2)),spp(ii)%vars%V(pp-1+cc,1))* &
180.0_rp/C_PI
end do
!$OMP END SIMD
end do !particle chunk iterator
!$OMP END PARALLEL DO
else
do tt=1_ip,params%coll_per_dump
!$OMP PARALLEL DO default(none) &
!$OMP& FIRSTPRIVATE(q_cache,m_cache,pchunk,achunk) &
!$OMP& SHARED(params,ii,spp,P,F) &
!$OMP& PRIVATE(pp,tt,Bmag,cc,Y_R,Y_PHI,Y_Z,V_PLL,V_MU,B_R,B_PHI,B_Z, &
!$OMP& flagCon,flagCol,E_PHI,PSIp,curlb_R,curlb_PHI,curlb_Z, &
!$OMP& gradB_R,gradB_PHI,gradB_Z,ne,E_R,E_Z,Te)
do pp=1_idef,spp(ii)%pRE,pchunk
if ((spp(ii)%pRE-pp).lt.pchunk) then
achunk=spp(ii)%pRE-pp+1
else
achunk=pchunk
end if
!$OMP SIMD
do cc=1_idef,achunk
Y_R(cc)=spp(ii)%vars%Y(pp-1+cc,1)
Y_PHI(cc)=spp(ii)%vars%Y(pp-1+cc,2)
Y_Z(cc)=spp(ii)%vars%Y(pp-1+cc,3)
V_PLL(cc)=spp(ii)%vars%V(pp-1+cc,1)
V_MU(cc)=spp(ii)%vars%V(pp-1+cc,2)
PSIp(cc)=spp(ii)%vars%PSI_P(pp-1+cc)
flagCon(cc)=spp(ii)%vars%flagCon(pp-1+cc)
flagCol(cc)=spp(ii)%vars%flagCol(pp-1+cc)
end do
!$OMP END SIMD
!write(6,*) ''
!write(6,*) 'pp',pp
do ttt=1_ip,params%orbits_per_coll
call advance_GCinterp_psi_vars(achunk,spp(ii)%vars,pp,tt, &
params,Y_R,Y_PHI,Y_Z,V_PLL,V_MU,q_cache,m_cache, &
flagCon,flagCol, &
F,P,B_R,B_PHI,B_Z,E_PHI,PSIp,curlb_R,curlb_PHI, &
curlb_Z,gradB_R,gradB_PHI,gradB_Z,ne)
end do
call include_CoulombCollisionsLA_GC_p(spp(ii),achunk, &
tt,params,Y_R,Y_PHI,Y_Z,V_PLL,V_MU,m_cache, &
flagCon,flagCol,F,P,E_PHI,ne,Te,PSIp)
!$OMP SIMD
do cc=1_idef,achunk
spp(ii)%vars%Y(pp-1+cc,1)=Y_R(cc)
spp(ii)%vars%Y(pp-1+cc,2)=Y_PHI(cc)
spp(ii)%vars%Y(pp-1+cc,3)=Y_Z(cc)
spp(ii)%vars%V(pp-1+cc,1)=V_PLL(cc)
spp(ii)%vars%V(pp-1+cc,2)=V_MU(cc)
spp(ii)%vars%flagCon(pp-1+cc)=flagCon(cc)
spp(ii)%vars%flagCol(pp-1+cc)=flagCol(cc)
spp(ii)%vars%B(pp-1+cc,1) = B_R(cc)
spp(ii)%vars%B(pp-1+cc,2) = B_PHI(cc)
spp(ii)%vars%B(pp-1+cc,3) = B_Z(cc)
spp(ii)%vars%gradB(pp-1+cc,1) = gradB_R(cc)
spp(ii)%vars%gradB(pp-1+cc,2) = gradB_PHI(cc)
spp(ii)%vars%gradB(pp-1+cc,3) = gradB_Z(cc)
spp(ii)%vars%curlb(pp-1+cc,1) = curlb_R(cc)
spp(ii)%vars%curlb(pp-1+cc,2) = curlb_PHI(cc)
spp(ii)%vars%curlb(pp-1+cc,3) = curlb_Z(cc)
spp(ii)%vars%E(pp-1+cc,2) = E_PHI(cc)
spp(ii)%vars%PSI_P(pp-1+cc) = PSIp(cc)
spp(ii)%vars%ne(pp-1+cc) = ne(cc)
spp(ii)%vars%Te(pp-1+cc) = Te(cc)
end do
!$OMP END SIMD
!$OMP SIMD
do cc=1_idef,achunk
B_R(cc)=spp(ii)%vars%B(pp-1+cc,1)
B_PHI(cc)=spp(ii)%vars%B(pp-1+cc,2)
B_Z(cc)=spp(ii)%vars%B(pp-1+cc,3)
Bmag(cc)=sqrt(B_R(cc)*B_R(cc)+B_PHI(cc)*B_PHI(cc)+ &
B_Z(cc)*B_Z(cc))
spp(ii)%vars%g(pp-1+cc)=sqrt(1+V_PLL(cc)**2+ &
2*V_MU(cc)*Bmag(cc))
spp(ii)%vars%eta(pp-1+cc) = atan2(sqrt(2*m_cache*Bmag(cc)* &
spp(ii)%vars%V(pp-1+cc,2)),spp(ii)%vars%V(pp-1+cc,1))* &
180.0_rp/C_PI
end do
!$OMP END SIMD
end do !particle chunk iterator
!$OMP END PARALLEL DO
end do
end if
end do !species iterator
end subroutine adv_GCinterp_psi_top