Skip to content
Snippets Groups Projects
Commit fafbd278 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann
Browse files

Small loop optimizations

parent bba838dd
No related branches found
No related tags found
No related merge requests found
......@@ -123,12 +123,7 @@ SUBROUTINE moments_eq_rhs
kr = krarray(ikr) ! Poloidal wavevector
kz = kzarray(ikz) ! Toroidal wavevector
kperp2 = kr**2 + kz**2 ! perpendicular wavevector
IF ( DK ) THEN ! Drift kinetic model
be_2 = 0._dp
ELSE
be_2 = kperp2 * sigmae2_taue_o2 ! Bessel argument
ENDIF
be_2 = kperp2 * sigmae2_taue_o2 ! Kernel argument
!! Compute moments and mixing terms
! term propto N_e^{p,j}
......@@ -235,6 +230,7 @@ SUBROUTINE moments_eq_rhs
-imagu * kpar*(TNapp1j + TNapm1j + xphijpar*kernelj*phi(ikr,ikz)) &
- mu*kperp2**2 * moments_e(ip,ij,ikr,ikz,updatetlevel) &
+ TColl
! Adding non linearity
IF ( NON_LIN .OR. (A0KH .NE. 0) ) THEN
moments_rhs_e(ip,ij,ikr,ikz,updatetlevel) = &
......@@ -325,12 +321,7 @@ SUBROUTINE moments_eq_rhs
kr = krarray(ikr) ! Poloidal wavevector
kz = kzarray(ikz) ! Toroidal wavevector
kperp2 = kr**2 + kz**2 ! perpendicular wavevector
IF ( DK ) THEN ! Drift kinetic model
bi_2 = 0._dp
ELSE
bi_2 = kperp2 * sigmai2_taui_o2 ! Bessel argument
ENDIF
bi_2 = kperp2 * sigmai2_taui_o2 ! Kernel argument
!! Compute moments and mixing terms
! term propto N_i^{p,j}
......@@ -437,6 +428,7 @@ SUBROUTINE moments_eq_rhs
-imagu * kpar*(TNapp1j + TNapm1j + xphijpar*kernelj*phi(ikr,ikz)) &
- mu*kperp2**2 * moments_i(ip,ij,ikr,ikz,updatetlevel) &
+ TColl
! Adding non linearity
IF ( NON_LIN .OR. (A0KH .NE. 0) ) THEN
moments_rhs_i(ip,ij,ikr,ikz,updatetlevel) = &
......
......@@ -43,6 +43,7 @@ SUBROUTINE poisson
! Initialization for n = 0 (ine = 1)
Kne = exp(-be_2)
sum_kernel_mom_e = Kne*moments_e(1, 1, ikr, ikz, updatetlevel)
sum_kernel2_e = Kne**2
! loop over n only if the max polynomial degree is 1 or more
if (jmaxe .GT. 0) then
DO ine=2,jmaxe+1 ! ine = n+1
......@@ -50,27 +51,16 @@ SUBROUTINE poisson
! We update iteratively the kernel functions (to spare factorial computations)
Kne = Kne * be_2/ine_dp
sum_kernel_mom_e = sum_kernel_mom_e + Kne * moments_e(1, ine, ikr, ikz, updatetlevel)
END DO
endif
! Initialization for n = 0 (ine = 1)
Kne = exp(-be_2)
sum_kernel2_e = Kne**2
! loop over n only without caring of jmax since no moment dependency
! DO ine=2,10
if (jmaxe .GT. 0) then
DO ine=2,jmaxe+1 ! ine = n+1
ine_dp = REAL(ine-1,dp) ! Real index (0 to jmax)
Kne = Kne * be_2/ine_dp ! update kernel_n
sum_kernel2_e = sum_kernel2_e + Kne**2 ! ... sum recursively ...
sum_kernel2_e = sum_kernel2_e + Kne**2 ! ... sum recursively ...
END DO
ENDIF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!! Ions sum(Kernel * Ni0n) (skm) and sum(Kernel**2) (sk2)
!! Sum(kernel * Moments_0n)
! Initialization for n = 0 (ini = 1)
Kni = exp(-bi_2)
sum_kernel_mom_i = Kni*moments_i(1, 1, ikr, ikz, updatetlevel)
sum_kernel2_i = Kni**2
! loop over n only if the max polynomial degree is 1 or more
if (jmaxi .GT. 0) then
DO ini=2,jmaxi+1
......@@ -78,21 +68,9 @@ SUBROUTINE poisson
! We update iteratively to spare factorial computations
Kni = Kni * bi_2/ini_dp
sum_kernel_mom_i = sum_kernel_mom_i + Kni * moments_i(1, ini, ikr, ikz, updatetlevel)
END DO
endif
! Initialization for n = 0 (ini = 1)
Kni = exp(-bi_2)
sum_kernel2_i = Kni**2
! loop over n only without caring of jmax since no moment dependency
if (jmaxi .GT. 0) then
DO ini=2,jmaxi+1
ini_dp = REAL(ini-1,dp) ! Real index (0 to jmax)
Kni = Kni * bi_2/ini_dp ! update kernel_n
sum_kernel2_i = sum_kernel2_i + Kni**2 ! ... sum recursively ...
sum_kernel2_i = sum_kernel2_i + Kni**2 ! ... sum recursively ...
END DO
ENDIF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!! Assembling the poisson equation !!!!!!!!!!!!!!!!!!!!!!!!!!
alphaD = kperp2 * lambdaD**2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment