Skip to content

Commit

Permalink
BEAMS3D: Migrated to the collision operator module.
Browse files Browse the repository at this point in the history
  • Loading branch information
lazersos committed Dec 18, 2024
1 parent f74495d commit d2af0b8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 35 deletions.
4 changes: 4 additions & 0 deletions BEAMS3D/BEAMS3D.dep
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ beams3d_follow.o: \
../../LIBSTELL/$(LOCTYPE)/stel_kinds.o \
../../LIBSTELL/$(LOCTYPE)/safe_open_mod.o \
../../LIBSTELL/$(LOCTYPE)/wall_mod.o \
../../LIBSTELL/$(LOCTYPE)/collision_operators.o \
../../LIBSTELL/$(LOCTYPE)/mpi_inc.o \
beams3d_runtime.o \
beams3d_lines.o \
Expand All @@ -96,6 +97,7 @@ beams3d_follow.o: \
beams3d_follow_gc.o: \
../../LIBSTELL/$(LOCTYPE)/stel_kinds.o \
../../LIBSTELL/$(LOCTYPE)/safe_open_mod.o \
../../LIBSTELL/$(LOCTYPE)/collision_operators.o \
../../LIBSTELL/$(LOCTYPE)/mpi_inc.o \
beams3d_runtime.o \
beams3d_lines.o \
Expand All @@ -107,6 +109,7 @@ beams3d_follow_gc.o: \
beams3d_follow_fo.o: \
../../LIBSTELL/$(LOCTYPE)/stel_kinds.o \
../../LIBSTELL/$(LOCTYPE)/safe_open_mod.o \
../../LIBSTELL/$(LOCTYPE)/collision_operators.o \
../../LIBSTELL/$(LOCTYPE)/mpi_inc.o \
beams3d_runtime.o \
beams3d_lines.o \
Expand Down Expand Up @@ -276,6 +279,7 @@ beams3d_physics_mod.o: \
../../LIBSTELL/$(LOCTYPE)/mpi_params.o \
../../LIBSTELL/$(LOCTYPE)/ezspline.o \
../../LIBSTELL/$(LOCTYPE)/ezspline_obj.o \
../../LIBSTELL/$(LOCTYPE)/collision_operators.o \
beams3d_runtime.o \
beams3d_lines.o \
beams3d_grid.o
Expand Down
13 changes: 4 additions & 9 deletions BEAMS3D/Sources/beams3d_follow.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SUBROUTINE beams3d_follow
USE beams3d_write_par
USE safe_open_mod, ONLY: safe_open
USE wall_mod, ONLY: wall_free, ihit_array, nface
USE collision_operators, ONLY: SET_CRIT_FACTOR, SET_COULOMB_FACTOR
USE mpi_inc
!-----------------------------------------------------------------------
! Local Variables
Expand Down Expand Up @@ -125,11 +126,7 @@ SUBROUTINE beams3d_follow

! Some helpers
fact_vsound = 1.5*sqrt(e_charge/plasma_mass)*therm_factor
fact_crit= SQRT(2.0*e_charge/electron_mass)*(0.75*sqrt_pi*electron_mass*plasma_Zmean/plasma_mass)**(1.0/3.0) ! Wesson pg 226 5.4.9
fact_crit_legacy = SQRT(2*e_charge/plasma_mass)*(0.75*sqrt_pi*sqrt(plasma_mass/electron_mass))**(1.0/3.0)
!fact_crit=fact_crit_pro*(plasma_Zmean/plasma_mass)**(1.0/3.0)
!fact_kick = pi2*2*SQRT(pi*1E-7*plasma_mass)*E_kick*freq_kick !old
!fact_kick = 2*freq_kick*E_kick
CALL SET_CRIT_FACTOR(plasma_Zmean,plasma_mass)

! Handle the Beam defaults
IF (lbeam) THEN
Expand Down Expand Up @@ -158,8 +155,7 @@ SUBROUTINE beams3d_follow
mybeam = Beam(i)
moment = mu_start(i)
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
! Save the IC of the neutral
my_end = t_end(i)
myline = i
Expand Down Expand Up @@ -193,8 +189,7 @@ SUBROUTINE beams3d_follow
myline = i
mytdex = 1
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
! Define neutral trajectory
myv_neut(1) = vr_start(i)*cos(phi_start(i)) - vphi_start(i)*sin(phi_start(i))
myv_neut(2) = vr_start(i)*sin(phi_start(i)) + vphi_start(i)*cos(phi_start(i))
Expand Down
10 changes: 4 additions & 6 deletions BEAMS3D/Sources/beams3d_follow_fo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SUBROUTINE beams3d_follow_fo
USE beams3d_write_par
USE beams3d_physics_mod, ONLY: beams3d_gc2fo, beams3d_calc_dt
USE safe_open_mod, ONLY: safe_open
USE collision_operators, ONLY: SET_COULOMB_FACTOR
USE mpi_inc
!-----------------------------------------------------------------------
! Local Variables
Expand Down Expand Up @@ -149,8 +150,7 @@ SUBROUTINE beams3d_follow_fo
lneut = .false.
! Collision parameters
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
DO ! Must do it this way becasue lbeam changes q(4) values
#if defined(NAG)
CALL D02CJF(t_nag,tf_nag,neqs_nag,q,fpart_eom,tol_nag,relab,out_beams3d_part,D02CJW,w,ier)
Expand Down Expand Up @@ -195,8 +195,7 @@ SUBROUTINE beams3d_follow_fo
lneut = .false.
! Collision parameters
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
! Setup DRKHVG parameters
iopt = 0
DO
Expand Down Expand Up @@ -252,8 +251,7 @@ SUBROUTINE beams3d_follow_fo
lneut = .false.
! Collision parameters
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
! Now handle Coordinate conversion
IF (lbeam .and. mytdex == 3) mytdex = 2 ! BEAM -> FO Run
IF (lboxsim) mytdex = 1
Expand Down
10 changes: 4 additions & 6 deletions BEAMS3D/Sources/beams3d_follow_gc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SUBROUTINE beams3d_follow_gc
USE mpi_params ! MPI
USE beams3d_write_par
USE beams3d_physics_mod, ONLY: beams3d_calc_dt
USE collision_operators, ONLY: SET_COULOMB_FACTOR
USE safe_open_mod, ONLY: safe_open
USE mpi_inc
!-----------------------------------------------------------------------
Expand Down Expand Up @@ -142,8 +143,7 @@ SUBROUTINE beams3d_follow_gc
! Collision parameters
fact_kick = 2*E_kick*mycharge/(mymass*pi2*pi2*freq_kick*freq_kick*SQRT(pi*1E-7*plasma_mass))
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
! Now calc dt
CALL beams3d_calc_dt(1,q(1),q(2),q(3),dt)
tf_nag = t_nag+dt
Expand Down Expand Up @@ -192,8 +192,7 @@ SUBROUTINE beams3d_follow_gc
! Collision parameters
fact_kick = 2*E_kick*mycharge/(mymass*pi2*pi2*freq_kick*freq_kick*SQRT(pi*1E-7*plasma_mass))
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
! Now calc dt
CALL beams3d_calc_dt(1,q(1),q(2),q(3),dt)
tf_nag = t_nag+dt
Expand Down Expand Up @@ -265,8 +264,7 @@ SUBROUTINE beams3d_follow_gc
! Collision parameters
fact_kick = 2*E_kick*mycharge/(mymass*pi2*pi2*freq_kick*freq_kick*SQRT(pi*1E-7*plasma_mass))
fact_pa = plasma_mass/(mymass*plasma_Zmean)
fact_coul = myZ*(mymass+plasma_mass)/(mymass*plasma_mass*6.02214076208E+26)

CALL SET_COULOMB_FACTOR(mymass,myZ,plasma_mass)
! Now calc dt
CALL beams3d_calc_dt(1,q(1),q(2),q(3),dt)
tf_nag = t_nag+dt
Expand Down
26 changes: 12 additions & 14 deletions BEAMS3D/Sources/beams3d_physics_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ MODULE beams3d_physics_mod
USE EZspline_obj
USE EZspline
USE adas_mod_parallel
USE collision_operators, ONLY: COULOMB_LOG_NRL_COUNTERSTREAM,&
V_CRITICAL, V_CRITICAL_WEILAND, &
TAU_SPITZER
USE mpi_params

!-----------------------------------------------------------------
Expand Down Expand Up @@ -91,12 +94,10 @@ FUNCTION coll_op_nrl19(ne_in,te_in,vbeta_in,Zeff_in) result(slow_par)
DOUBLE PRECISION :: slow_par(3)
DOUBLE PRECISION, INTENT(in) :: ne_in, te_in, vbeta_in, Zeff_in
DOUBLE PRECISION :: ne_cm,coulomb_log
ne_cm = ne_in * 1E-6
coulomb_log = 43 - log(Zeff_in*fact_coul*sqrt(ne_cm/te_in)/(vbeta_in*vbeta_in))
!fact_crit_legacy = SQRT(2*e_charge/plasma_mass)*(0.75*sqrt_pi*sqrt(plasma_mass/electron_mass))**(1.0/3.0)
slow_par(1) = fact_crit_legacy*SQRT(te_in)
slow_par(2) = 3.777183D41*mymass*SQRT(te_in*te_in*te_in)/(ne_in*myZ*myZ*coulomb_log) ! note ne should be in m^-3 here, tau_spit
slow_par(3) =Zeff_in*fact_pa
coulomb_log = COULOMB_LOG_NRL_COUNTERSTREAM(ne_in,te_in,vbeta_in,Zeff_in)
slow_par(1) = V_CRITICAL(te_in)
slow_par(2) = TAU_SPITZER(mymass,ne_in,te_in,myZ,coulomb_log)
slow_par(3) = Zeff_in*fact_pa
END FUNCTION coll_op_nrl19

!-----------------------------------------------------------------
Expand All @@ -123,14 +124,11 @@ FUNCTION coll_op_nrl19_ie(ne_in,te_in,vbeta_in,Zeff_in) result(slow_par)
DOUBLE PRECISION :: slow_par(3)
DOUBLE PRECISION, INTENT(in) :: ne_in, te_in, vbeta_in, Zeff_in
DOUBLE PRECISION :: ne_cm, coulomb_loge, coulomb_logi
ne_cm = ne_in * 1E-6
coulomb_logi = 43 - log(Zeff_in*fact_coul*sqrt(ne_cm/te_in)/(vbeta_in*vbeta_in))
coulomb_loge=log(1.09d11 * te_in/Zeff_in/sqrt(ne_cm))
!WRITE(6,*) coulomb_loge, coulomb_logi
! Callen Ch2 pg41 eq2.135 (fact*Vtherm; Vtherm = SQRT(2*E/mass) so E in J not eV)
slow_par(1) = fact_crit*SQRT(te_in)*(coulomb_logi/coulomb_loge)**(1.0/3.0) !vcrit, the coulomb ratio is from Weiland (2018) eq.11
slow_par(2) = 3.777183D41*mymass*SQRT(te_in*te_in*te_in)/(ne_in*myZ*myZ*coulomb_loge) ! note ne should be in m^-3 here, tau_spit
slow_par(3) =Zeff_in*fact_pa
coulomb_logi = COULOMB_LOG_NRL_COUNTERSTREAM(ne_in,te_in,vbeta_in,Zeff_in)
coulomb_loge = log(1.09d11 * te_in/Zeff_in/sqrt(ne_cm))
slow_par(1) = V_CRITICAL_WEILAND(te_in,coulomb_logi,coulomb_loge)
slow_par(2) = TAU_SPITZER(mymass,ne_in,te_in,myZ,coulomb_loge)
slow_par(3) = Zeff_in*fact_pa
RETURN
END FUNCTION coll_op_nrl19_ie

Expand Down

0 comments on commit d2af0b8

Please sign in to comment.