Skip to content

Commit

Permalink
Merge pull request #239 from PrincetonUniversity/feature/pySTEL
Browse files Browse the repository at this point in the history
Feature/py stel
  • Loading branch information
lazersos authored Jun 4, 2024
2 parents b3f032c + 4542ea5 commit d94626d
Show file tree
Hide file tree
Showing 82 changed files with 7,779 additions and 3,840 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
*~
*#

*.o
*.mod
*.a
*.so
*.zip
*.egg-info
.DS*
*.dSYM
._*
Expand Down Expand Up @@ -69,3 +69,9 @@ PB3D

.vscode/
LIBSTELL/.makefile.swp
pySTEL/build
pySTEL/dist

*.sublime-project
*.sublime-workspace
fort.*
16 changes: 3 additions & 13 deletions BEAMS3D/BEAMS3D.dep
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ beams3d_beam_density.o: \
../../LIBSTELL/$(LOCTYPE)/mpi_params.o

beams3d_interface_mod.o: \
beams3d_input_mod.o \
../../LIBSTELL/$(LOCTYPE)/beams3d_input_mod.o \
beams3d_runtime.o \
beams3d_grid.o \
beams3d_lines.o \
Expand All @@ -20,7 +20,7 @@ beams3d_interface_mod.o: \

beams3d_imas_module.o: \
beams3d_interface_mod.o \
beams3d_input_mod.o
../../LIBSTELL/$(LOCTYPE)/beams3d_input_mod.o


beams3d_fix_poloidal.o: \
Expand Down Expand Up @@ -143,7 +143,7 @@ beams3d_init.o: \
../../LIBSTELL/$(LOCTYPE)/adas_mod_parallel.o \
beams3d_runtime.o \
beams3d_grid.o \
beams3d_input_mod.o \
../../LIBSTELL/$(LOCTYPE)/beams3d_input_mod.o \
beams3d_lines.o\
fidasim_input_mod.o \

Expand Down Expand Up @@ -260,16 +260,6 @@ beams3d_init_continuegrid.o: \
beams3d_grid.o


beams3d_input_mod.o: \
../../LIBSTELL/$(LOCTYPE)/stel_kinds.o \
../../LIBSTELL/$(LOCTYPE)/safe_open_mod.o \
../../LIBSTELL/$(LOCTYPE)/mpi_params.o \
../../LIBSTELL/$(LOCTYPE)/mpi_inc.o \
beams3d_runtime.o \
beams3d_lines.o \
beams3d_grid.o


beams3d_lines.o: \
../../LIBSTELL/$(LOCTYPE)/stel_kinds.o

Expand Down
1 change: 0 additions & 1 deletion BEAMS3D/ObjectList
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ beams3d_grid.o \
backspace_out.o \
beams3d_follow_gc.o \
gauss_rand.o \
beams3d_input_mod.o \
beams3d_init_beams.o \
fgc_rkh68.o \
fgc_lsode.o
26 changes: 17 additions & 9 deletions BEAMS3D/Sources/beams3d_grid.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ MODULE beams3d_grid
USE stel_kinds, ONLY: rprec
USE EZspline_obj
USE EZspline
USE beams3d_globals, ONLY: nr, nphi, nz, rmin, rmax, zmin, zmax, &
phimin, phimax, vc_adapt_tol, nte, &
nne, nti,nzeff, npot, plasma_mass, &
plasma_Zmean, therm_factor, &
B_kick_min, B_kick_max, freq_kick, &
E_kick, rho_fullorbit, rmin_fida, &
rmax_fida, zmin_fida, zmax_fida, &
phimin_fida, phimax_fida, nr_fida, &
nphi_fida, nz_fida, nenergy_fida, &
npitch_fida, &
t_fida, dexionT, dexionD,dexionHe3, &
s_max,s_max_te, s_max_ne,s_max_zeff,&
s_max_ti, s_max_pot

!-----------------------------------------------------------------------
! Module Variables
Expand Down Expand Up @@ -40,7 +53,6 @@ MODULE beams3d_grid
! plasma_Zmean [Z] = sum(n*Z*Z*mi/mj)/sum(n*Z) sum over j ion species (mi: plasma mass)
!-----------------------------------------------------------------------
IMPLICIT NONE
INTEGER :: nr, nphi, nz, nte, nne, nti, nzeff, npot, dexionT, dexionD, dexionHe3
INTEGER :: win_raxis, win_phiaxis, win_zaxis, win_B_R, win_B_PHI, win_B_Z,&
win_MODB, win_TE, win_NE, win_TI, win_ZEFF_ARR,&
win_S_ARR, win_U_ARR,win_X_ARR,win_Y_ARR, win_POT_ARR, win_BR4D, win_BPHI4D, &
Expand All @@ -49,16 +61,12 @@ MODULE beams3d_grid
win_wall_load, win_wall_shine, win_hr, win_hp, win_hz, &
win_hri, win_hpi, win_hzi, win_NI5D, win_NI, &
win_raxis_fida, win_phiaxis_fida, win_zaxis_fida, win_energy_fida, win_pitch_fida, &
win_beam_density, win_NEUTRONS, win_E_NEUTRONS, &
nr_fida, nphi_fida, nz_fida, nenergy_fida, npitch_fida
REAL(rprec) :: rmin, rmax, zmin, zmax, phimin, phimax, tmin, tmax, delta_t, &
vc_adapt_tol, psiedge_eq, phiedge_eq, plasma_Zmean, plasma_mass, &
reff_eq, therm_factor, B_kick_min, B_kick_max, &
E_kick, freq_kick, t_fida, rho_fullorbit, rho_help,&
s_max,s_max_te, s_max_ne,s_max_zeff,s_max_ti, s_max_pot
win_beam_density, win_NEUTRONS, win_E_NEUTRONS
REAL(rprec) :: emin_fida, pimin_fida
REAL(rprec) :: tmin, tmax, delta_t, psiedge_eq, phiedge_eq, &
reff_eq, rho_help
REAL(rprec), POINTER :: raxis(:), zaxis(:), phiaxis(:)
REAL(rprec), POINTER :: req_axis(:), zeq_axis(:), E_NEUTRONS(:)
REAL :: rmin_fida, rmax_fida, zmin_fida, zmax_fida, phimin_fida, phimax_fida, emin_fida, pimin_fida
REAL(rprec), POINTER :: raxis_fida(:), zaxis_fida(:), phiaxis_fida(:), energy_fida(:), pitch_fida(:)
REAL(rprec), POINTER :: wall_load(:,:), wall_shine(:,:)
REAL(rprec), POINTER :: B_R(:,:,:),B_PHI(:,:,:), B_Z(:,:,:), MODB(:,:,:),&
Expand Down
11 changes: 7 additions & 4 deletions BEAMS3D/Sources/beams3d_lines.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ MODULE beams3d_lines
! Libraries
!-----------------------------------------------------------------------
USE stel_kinds, ONLY: rprec
USE beams3d_globals, ONLY: nparticles, ns_prof1, ns_prof2, &
ns_prof3, ns_prof4, ns_prof5, partvmax

!-----------------------------------------------------------------------
! Module Variables
Expand All @@ -22,15 +24,16 @@ MODULE beams3d_lines
!-----------------------------------------------------------------------
IMPLICIT NONE
LOGICAL :: ltherm
INTEGER :: ns_prof1, ns_prof2, ns_prof3, ns_prof4, ns_prof5, nsh_prof4
INTEGER :: nparticles, nsteps, myline, mybeam, mytdex, myend, mystart_save, myend_save
INTEGER :: nsh_prof4
INTEGER :: nsteps, myline, mybeam, mytdex, myend, mystart_save, myend_save
INTEGER :: win_epower, win_ipower, win_ndot, win_dense, win_jprof, win_dist5d, win_dist5d_fida
REAL(rprec) :: xlast,ylast,zlast ! for storing position
REAL(rprec) :: moment, mycharge, myZ, mymass, myv_neut(3), my_end, &
myqm, rand_prob, cum_prob, tau, next_t, &
partvmax, fact_crit, fact_pa, fact_vsound, fact_kick, &
fact_crit, fact_pa, fact_vsound, fact_kick, &
fact_coul, fact_crit_pro, &
partpmax, h2_prof, h3_prof, h4_prof, h5_prof, r_h, z_h, p_h, e_h, pi_h, E_by_v
partpmax, h2_prof, h3_prof, h4_prof, h5_prof, r_h, &
z_h, p_h, e_h, pi_h, E_by_v
LOGICAL, ALLOCATABLE :: neut_lines(:,:)
INTEGER, ALLOCATABLE :: end_state(:)
REAL(rprec), ALLOCATABLE :: shine_through(:), shine_port(:), GFactor(:), t_last(:)
Expand Down
73 changes: 38 additions & 35 deletions BEAMS3D/Sources/beams3d_runtime.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,35 @@
! v4.07 01/11/24 - Added ability to specifiy weights in the input
!-----------------------------------------------------------------------
MODULE beams3d_runtime
!-----------------------------------------------------------------------
!-------------------------------------------------------------------
! Libraries
!-----------------------------------------------------------------------
!-------------------------------------------------------------------
USE stel_kinds, ONLY: rprec
USE mpi_params
USE EZspline
USE beams3d_globals, ONLY: r_start_in, z_start_in, phi_start_in, &
vll_start_in, mu_start_in, vr_start_in, &
vphi_start_in, vz_start_in, t_end_in, &
mass_in, charge_in, Zatom_in, weight_in, &
NE_AUX_S, TE_AUX_S, NI_AUX_S, TI_AUX_S, &
NE_AUX_F, TE_AUX_F, NI_AUX_F, TI_AUX_F, &
ZEFF_AUX_S, POT_AUX_S, ZEFF_AUX_F, &
POT_AUX_F, NI_AUX_M, NI_AUX_Z, &
Adist_beams, Asize_beams, DIV_BEAMS, &
DEX_BEAMS, R_BEAMS, Z_BEAMS, PHI_BEAMS, &
E_BEAMS, MASS_BEAMS, CHARGE_BEAMS, &
ZATOM_BEAMS, P_BEAMS, nparticles_start, &
npoinc, follow_tol, int_type, ne_scale, &
te_scale, ti_scale, zeff_scale, &
fusion_scale, lendt_m, te_col_min, &
duplicate_factor, ldebug, lbeam, &
MAXBEAMS, lbeam, MAXBEAMS, nbeams, &
pi2, NION, &
MAXPROFLEN, MAXPARTICLES, lverb, &
lbbnbi, lcollision, lfusion, &
lrestart_particles, lfusion_alpha, &
lfusion_He3, lfusion_proton, &
lfusion_tritium, lkick, lgcsim, id_string
!-----------------------------------------------------------------------
! Module Variables
! lverb Logical to control screen output
Expand Down Expand Up @@ -123,46 +146,26 @@ MODULE beams3d_runtime
INTEGER, PARAMETER :: MPI_BCAST_ERR = 83
INTEGER, PARAMETER :: MPI_FINE_ERR = 89

INTEGER, PARAMETER :: MAXPARTICLES = 2**18
INTEGER, PARAMETER :: MAXBEAMS = 32
INTEGER, PARAMETER :: MAXPROFLEN = 512
INTEGER, PARAMETER :: NION = 4

DOUBLE PRECISION, PARAMETER :: one = 1.0D0 ! 1.0

LOGICAL :: lverb, lvmec, lpies, lspec, lcoil, lmgrid, &
lvessel, lvac, lcontinue_grid, lrestart_particles, lneut, &
lbeam, lhitonly, lread_input, lplasma_only, lraw,&
ldepo, lbeam_simple, ldebug, lcollision, lw7x, lsuzuki, &
lascot, lascot4, lbbnbi, lfidasim, lfidasim_cyl, lsplit, lvessel_beam, lascotfl, lrandomize, &
lfusion, lfusion_alpha, leqdsk, lhint, lkick, lgcsim, &
lboxsim, limas, lfieldlines, lfusion_tritium, lfusion_proton, lfusion_He3, lbeamdensity
INTEGER :: nextcur, npoinc, nbeams, nparticles_start, nprocs_beams, &
ndt, ndt_max, duplicate_factor
INTEGER, DIMENSION(MAXBEAMS) :: Dex_beams
LOGICAL :: lvmec, lpies, lspec, lcoil, lmgrid, &
lvessel, lvac, lcontinue_grid, lneut, &
lhitonly, lread_input, lplasma_only, lraw, &
ldepo, lbeam_simple, lw7x, lsuzuki, &
lascot, lascot4, lfidasim, lfidasim_cyl, lsplit, &
lvessel_beam, lascotfl, lrandomize, leqdsk, lhint, &
lboxsim, limas, lfieldlines, lbeamdensity
INTEGER :: nextcur, nprocs_beams, ndt, ndt_max
INTEGER, ALLOCATABLE :: beam(:)
REAL(rprec) :: dt, follow_tol, pi, pi2, invpi2, mu0, to3, dt_save, &
ne_scale, te_scale, ti_scale, zeff_scale, fusion_scale, &
lendt_m, te_col_min, rminor_norm
REAL(rprec), DIMENSION(MAXBEAMS) :: Adist_beams, Asize_beams, Div_beams, E_beams, mass_beams, &
charge_beams, Zatom_beams, P_beams
REAL(rprec), DIMENSION(MAXBEAMS, 2) :: r_beams, z_beams, phi_beams
REAL(rprec), DIMENSION(MAXPROFLEN) :: TE_AUX_S, TE_AUX_F, NE_AUX_S, NE_AUX_F, TI_AUX_S, TI_AUX_F,&
POT_AUX_S, POT_AUX_F, ZEFF_AUX_S, ZEFF_AUX_F
REAL(rprec), DIMENSION(MAXPROFLEN) :: NI_AUX_S
REAL(rprec), DIMENSION(NION,MAXPROFLEN) :: NI_AUX_F
INTEGER, DIMENSION(NION) :: NI_AUX_Z
REAL(rprec), DIMENSION(NION) :: NI_AUX_M
REAL(rprec), DIMENSION(MAXPARTICLES) :: r_start_in, phi_start_in, z_start_in, vll_start_in, &
& mu_start_in, charge_in, Zatom_in, mass_in, t_end_in, &
vr_start_in, vphi_start_in, vz_start_in, weight_in
REAL(rprec) :: dt, pi, invpi2, mu0, to3, dt_save, rminor_norm
LOGICAL, ALLOCATABLE :: lgc2fo_start(:)
REAL(rprec), ALLOCATABLE :: R_start(:), phi_start(:), Z_start(:), vll_start(:), mu_start(:), &
& mass(:), charge(:), Zatom(:), t_end(:), weight(:), vr_start(:), vphi_start(:), vz_start(:)
REAL(rprec), ALLOCATABLE :: extcur(:)
CHARACTER(LEN=10) :: qid_str_saved ! For ASCOT5
CHARACTER(256) :: id_string, mgrid_string, coil_string, &
vessel_string, int_type, restart_string, continue_grid_string, bbnbi_string, eqdsk_string
CHARACTER(256) :: mgrid_string, coil_string, &
vessel_string, restart_string, &
continue_grid_string, bbnbi_string, &
eqdsk_string

REAL(rprec), PARAMETER :: BEAMS3D_VERSION = 4.07 ! this is the full orbit test version

Expand Down
32 changes: 10 additions & 22 deletions BENCHMARKS/BEAMS3D_TEST/input.ORBITS_slow
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,20 @@ RBC( 0, 1) = 1.0000000000e+00 ZBS( 0, 1) = 1.0000000000e+00
INT_TYPE = 'LSODE'
FOLLOW_TOL = 1.00000000000000E-08
VC_ADAPT_TOL = 1.00E-03
R_START_IN = 40*10.5
Z_START_IN = 40*0.0
PHI_START_IN = 40*0.0
CHARGE_IN = 40*1.60217733E-19
MASS_IN = 40*1.6726231E-27
MASS_IN = 40*3.3434954106E-27
ZATOM_IN = 40*1.0
T_END_IN = 40*1.0E-3
NPOINC = 1000
NE_AUX_S = 0.0 0.2 0.4 0.6 0.8 1.0
NE_AUX_F = 1.2E20 1.0E20 0.8E20 0.6E20 0.4E20 0.2E20
TE_AUX_S = 0.0 0.2 0.4 0.6 0.8 1.0
TE_AUX_F = 1.0E04 0.8E04 0.6E04 0.4E04 0.2E04 0.0E04
TI_AUX_S = 0.0 0.2 0.4 0.6 0.8 1.0
TI_AUX_F = 1.0E04 0.8E04 0.6E04 0.4E04 0.2E04 0.0E04
VLL_START_IN = 4.3767277259E+04 8.7521428600E+04 1.3124934778E+05 1.7493796783E+05 2.1857428054E+05 2.6214535568E+05
3.0563836005E+05 3.4904057609E+05 3.9233942017E+05 4.3552246036E+05 4.7857743375E+05 5.2149226315E+05
5.6425507318E+05 6.0685420574E+05 6.4927823469E+05 6.9151597983E+05 7.3355652011E+05 7.7538920600E+05
8.1700367103E+05 8.5838984243E+05 8.9953795097E+05 9.4043853987E+05 9.8108247275E+05 1.0214609408E+06
1.0615654689E+06 1.1013879211E+06 1.1409205047E+06 1.1801557741E+06 1.2190866335E+06 1.2577063383E+06
1.2960084967E+06 1.3339870693E+06 1.3716363692E+06 1.4089510599E+06 1.4459261541E+06 1.4825570104E+06
1.5188393303E+06 1.5547691543E+06 1.5903428569E+06 1.6255571421E+06
MU_START_IN = 3.2040342566E-15 3.2030734306E-15 3.2014733340E-15 3.1992358826E-15 3.1963637506E-15 3.1928603627E-15
3.1887298836E-15 3.1839772059E-15 3.1786079357E-15 3.1726283762E-15 3.1660455093E-15 3.1588669756E-15
3.1511010522E-15 3.1427566301E-15 3.1338431883E-15 3.1243707683E-15 3.1143499465E-15 3.1037918055E-15
3.0927079046E-15 3.0811102500E-15 3.0690112633E-15 3.0564237505E-15 3.0433608700E-15 3.0298361006E-15
3.0158632094E-15 3.0014562196E-15 2.9866293783E-15 2.9713971254E-15 2.9557740614E-15 2.9397749174E-15
2.9234145242E-15 2.9067077830E-15 2.8896696366E-15 2.8723150412E-15 2.8546589399E-15 2.8367162358E-15
2.8185017680E-15 2.8000302866E-15 2.7813164309E-15 2.7623747069E-15
NE_AUX_S = 0.0 0.2 0.4 0.6 0.8 1.0
NE_AUX_F = 1.2E19 1.2E19 1.2E19 1.2E19 1.2E19 1.2E19
TE_AUX_S = 0.0 0.2 0.4 0.6 0.8 1.0
TE_AUX_F = 1.0E03 1.0E03 1.0E03 1.0E03 1.0E03 1.0E03
TI_AUX_S = 0.0 0.2 0.4 0.6 0.8 1.0
TI_AUX_F = 1.0E02 1.0E02 1.0E02 1.0E02 1.0E02 1.0E02
R_START_IN = 1.0200000000E+01 1.0215384615E+01 1.0230769231E+01 1.0246153846E+01 1.0261538462E+01 1.0276923077E+01 1.0292307692E+01 1.0307692308E+01 1.0323076923E+01 1.0338461538E+01 1.0353846154E+01 1.0369230769E+01 1.0384615385E+01 1.0400000000E+01 1.0415384615E+01 1.0430769231E+01 1.0446153846E+01 1.0461538462E+01 1.0476923077E+01 1.0492307692E+01 1.0507692308E+01 1.0523076923E+01 1.0538461538E+01 1.0553846154E+01 1.0569230769E+01 1.0584615385E+01 1.0600000000E+01 1.0615384615E+01 1.0630769231E+01 1.0646153846E+01 1.0661538462E+01 1.0676923077E+01 1.0692307692E+01 1.0707692308E+01 1.0723076923E+01 1.0738461538E+01 1.0753846154E+01 1.0769230769E+01 1.0784615385E+01 1.0800000000E+01
VLL_START_IN = 2.9409892275E+05 3.5702255112E+05 4.1040958524E+05 4.5761004502E+05 5.0037773626E+05 5.3976736155E+05 5.7647179483E+05 6.1097516798E+05 6.4363155728E+05 6.7470920194E+05 7.0441708726E+05 7.3292179560E+05 7.6035865492E+05 7.8683937990E+05 8.1245746683E+05 8.3729210020E+05 8.6141104398E+05 8.8487282269E+05 9.0772839439E+05 9.3002245330E+05 9.7541577801E+05 1.1647286686E+06 1.3273092340E+06 1.4720416890E+06 1.6037654646E+06 1.7254624299E+06 1.8391241199E+06 1.9461588989E+06 2.0476062588E+06 2.1442593879E+06 2.2367398717E+06 2.3255455672E+06 2.4110825611E+06 2.4936872394E+06 2.5736419680E+06 2.6511865100E+06 2.7265265160E+06 2.7998399550E+06 2.8712820664E+06 2.9409892275E+06
MU_START_IN = 3.1896056946E-18 4.7081133792E-18 6.2315977198E-18 7.7601060613E-18 9.2936866557E-18 1.0832387855E-17 1.2376258535E-17 1.3925348047E-17 1.5479706129E-17 1.7039381490E-17 1.8604425960E-17 2.0174891379E-17 2.1750824724E-17 2.3332282145E-17 2.4919310716E-17 2.6511966656E-17 2.8110298441E-17 2.9714358526E-17 3.1324201032E-17 3.2939878046E-17 3.6298197246E-17 5.1847620675E-17 6.7452916238E-17 8.3114598332E-17 9.8833182498E-17 1.1460919764E-16 1.3044312906E-16 1.4633550987E-16 1.6228686521E-16 1.7829770574E-16 1.9436854291E-16 2.1049989802E-16 2.2669231404E-16 2.4294627705E-16 2.5926231508E-16 2.7564097855E-16 2.9208279343E-16 3.0858830244E-16 3.2515807667E-16 3.4179263442E-16
/
Loading

0 comments on commit d94626d

Please sign in to comment.