Skip to content
Snippets Groups Projects
Commit 87cbdec0 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann :seedling:
Browse files

update ExB NL factor each RK step?

parent de9e4f23
No related branches found
No related tags found
No related merge requests found
...@@ -92,10 +92,7 @@ CONTAINS ...@@ -92,10 +92,7 @@ CONTAINS
INTEGER, INTENT(IN) :: step_number INTEGER, INTENT(IN) :: step_number
! local var ! local var
INTEGER :: iky INTEGER :: iky
REAL(xp):: tnext
! tnext = time + c_E(step_number)*dt
tnext = time + 0._xp*dt
! do nothing if no ExB ! do nothing if no ExB
IF(ExB) THEN IF(ExB) THEN
! Update new shear value ! Update new shear value
...@@ -125,7 +122,7 @@ CONTAINS ...@@ -125,7 +122,7 @@ CONTAINS
CALL evaluate_magn_curv CALL evaluate_magn_curv
! update the ExB nonlinear factor... ! update the ExB nonlinear factor...
IF(LINEARITY .EQ. 'nonlinear') & IF(LINEARITY .EQ. 'nonlinear') &
CALL update_nonlinear_ExB_factors CALL update_nonlinear_ExB_factors(step_number)
ENDIF ENDIF
END SUBROUTINE Update_ExB_shear_flow END SUBROUTINE Update_ExB_shear_flow
...@@ -201,14 +198,18 @@ CONTAINS ...@@ -201,14 +198,18 @@ CONTAINS
END SUBROUTINE Array_shift_ExB_shear_flow END SUBROUTINE Array_shift_ExB_shear_flow
SUBROUTINE Update_nonlinear_ExB_factors SUBROUTINE Update_nonlinear_ExB_factors(step_number)
USE grid, ONLY: local_nky, local_nky_offset, xarray, Nx, Ny, local_nx, deltakx,& USE grid, ONLY: local_nky, local_nky_offset, xarray, Nx, Ny, local_nx, deltakx,&
local_nx_offset, ikyarray, inv_ikyarray, deltaky, update_grids local_nx_offset, ikyarray, inv_ikyarray, deltaky, update_grids
USE basic, ONLY: time, dt USE basic, ONLY: time, dt
USE time_integration, ONLY: c_E
IMPLICIT NONE IMPLICIT NONE
INTEGER, INTENT(IN) :: step_number
INTEGER :: iky, ix INTEGER :: iky, ix
REAL(xp):: dt_ExB, J_xp, inv_J, xval, tnext REAL(xp):: dt_ExB, J_xp, inv_J, xval, tnow
tnext = time + dt
tnow = time + c_E(step_number)*dt
DO iky = 1,local_nky ! WARNING: Local indices ky loop DO iky = 1,local_nky ! WARNING: Local indices ky loop
! for readability ! for readability
! J_xp = ikyarray(iky+local_nky_offset) ! J_xp = ikyarray(iky+local_nky_offset)
...@@ -220,12 +221,12 @@ CONTAINS ...@@ -220,12 +221,12 @@ CONTAINS
inv_J = 0._xp inv_J = 0._xp
ENDIF ENDIF
! compute dt factor ! compute dt factor
dt_ExB = (tnext - t0*inv_J*ANINT(J_xp*tnext*inv_t0,xp)) dt_ExB = (tnow - t0*inv_J*ANINT(J_xp*tnow*inv_t0,xp))
DO ix = 1,Nx DO ix = 1,Nx
xval = 2._xp*pi/deltakx*REAL(ix-1,xp)/REAL(Nx,xp)!xarray(ix) xval = 2._xp*pi/deltakx*REAL(ix-1,xp)/REAL(Nx,xp)!xarray(ix)
! assemble the ExB nonlin factor ! assemble the ExB nonlin factor
! ExB_NL_factor(ix,iky) = EXP(-imagu*x*gamma_E*J_xp*deltaky*dt_ExB) ExB_NL_factor(ix,iky) = EXP(-imagu*xval*gamma_E*J_xp*deltaky*dt_ExB)
ExB_NL_factor(ix,iky) = EXP(-imagu*sky_ExB(iky)*xval) ! ExB_NL_factor(ix,iky) = EXP(-imagu*sky_ExB(iky)*xval)
! ExB_NL_factor(ix,iky) = EXP(-imagu*sky_ExB_full(iky+local_nky_offset)*xval) ! ExB_NL_factor(ix,iky) = EXP(-imagu*sky_ExB_full(iky+local_nky_offset)*xval)
ENDDO ENDDO
ENDDO ENDDO
...@@ -239,14 +240,17 @@ CONTAINS ...@@ -239,14 +240,17 @@ CONTAINS
inv_J = 0._xp inv_J = 0._xp
ENDIF ENDIF
! compute dt factor ! compute dt factor
dt_ExB = (tnext - t0*inv_J*ANINT(J_xp*tnext*inv_t0,xp)) dt_ExB = (tnow - t0*inv_J*ANINT(J_xp*tnow*inv_t0,xp))
DO ix = 1,local_nx DO ix = 1,local_nx
xval = 2._xp*pi/deltakx*REAL(ix-1,xp)/REAL(Nx,xp)!xarray(ix+local_nx_offset) xval = 2._xp*pi/deltakx*REAL(ix-1,xp)/REAL(Nx,xp)!xarray(ix+local_nx_offset)
! assemble the inverse ExB nonlin factor ! assemble the inverse ExB nonlin factor
! inv_ExB_NL_factor(iky,ix) = EXP(imagu*x*gamma_E*J_xp*deltaky*dt_ExB) inv_ExB_NL_factor(iky,ix) = EXP(imagu*gamma_E*J_xp*deltaky*dt_ExB*xval)
inv_ExB_NL_factor(iky,ix) = EXP(imagu*sky_ExB_full(iky)*xval) ! inv_ExB_NL_factor(iky,ix) = EXP(imagu*sky_ExB_full(iky)*xval)
ENDDO ENDDO
ENDDO ENDDO
! Cancel the additional point
inv_ExB_NL_factor(Ny/2+1,:) = 0._xp
inv_ExB_NL_factor(Ny/2+2,:) = 0._xp
END SUBROUTINE Update_nonlinear_ExB_factors END SUBROUTINE Update_nonlinear_ExB_factors
END MODULE ExB_shear_flow END MODULE ExB_shear_flow
\ No newline at end of file
...@@ -12,12 +12,22 @@ SUBROUTINE stepon ...@@ -12,12 +12,22 @@ SUBROUTINE stepon
#ifdef TEST_SVD #ifdef TEST_SVD
USE CLA, ONLY: test_svd,filter_sv_moments_ky_pj USE CLA, ONLY: test_svd,filter_sv_moments_ky_pj
#endif #endif
USE ExB_shear_flow, ONLY: Update_ExB_shear_flow
IMPLICIT NONE IMPLICIT NONE
INTEGER :: num_step, ierr INTEGER :: num_step, ierr
LOGICAL :: mlend LOGICAL :: mlend
SUBSTEPS:DO num_step=1,ntimelevel ! eg RK4 compute successively k1, k2, k3, k4 SUBSTEPS:DO num_step=1,ntimelevel ! eg RK4 compute successively k1, k2, k3, k4
!----- TEST !-----
! Update the ExB shear flow for the next step
! This call includes :
! - the ExB shear value (s(ky)) update for the next time step
! - the kx grid update
! - the ExB NL correction factor update (exp(+/- ixkySdts))
! - (optional) the kernel, poisson op. and ampere op update
CALL Update_ExB_shear_flow(num_step)
!-----END TEST !-----
!----- BEFORE: All fields+ghosts are updated for step = n !----- BEFORE: All fields+ghosts are updated for step = n
! Compute right hand side from current fields ! Compute right hand side from current fields
! N_rhs(N_n, nadia_n, phi_n, S_n, Tcoll_n) ! N_rhs(N_n, nadia_n, phi_n, S_n, Tcoll_n)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment