Skip to content

Commit

Permalink
Check added in profiles_gen
Browse files Browse the repository at this point in the history
  • Loading branch information
jcandy committed Feb 24, 2024
1 parent 7460c38 commit 388e6e7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
16 changes: 9 additions & 7 deletions f2py/expro/expro_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ subroutine expro_compute_derived
integer :: n
integer :: i
integer :: is
integer :: nx
integer :: nx,err

double precision, parameter :: k = 1.6022d-12 ! erg/eV
double precision, parameter :: e = 4.8032d-10 ! statcoul
Expand Down Expand Up @@ -208,7 +208,8 @@ subroutine expro_compute_derived

! r_min = a [m]
r_min = expro_rmin(expro_n_exp)


100 err=0
do i=2,expro_n_exp

! Parameters to be passed to geo library
Expand Down Expand Up @@ -263,9 +264,10 @@ subroutine expro_compute_derived
geo_fourier_in(5:8,0:geo_nfourier_in) = expro_dgeo(:,:,i)
endif

call geo_interp(1,theta,.true.)
call geo_interp(1,theta,.true.)
if (minval(geov_jac_r) <= 0d0) then
print '(a,i3,a,f5.2)','WARNING: (expro_util) J < 0 for i=',i,' in input.gacode: ',minval(geov_jac_r)
err = 1
endif

! V, dV/dr and S (note that S=dV/dr only in a circle)
Expand Down Expand Up @@ -416,9 +418,9 @@ subroutine expro_compute_derived
expro_ni_new(:) = expro_ni_new(:)+expro_z(is)*expro_ni(is,:)
expro_dlnnidr_new(:) = expro_dlnnidr_new(:)+expro_z(is)*expro_ni(is,:)*expro_dlnnidr(is,:)
enddo

! New quasineutral ion 1 profiles:

! density
expro_ni_new(:) = (expro_ne(:)-expro_ni_new(:))/expro_z(1)
! gradient scale length 1/L_ni = -dln(ni)/dr (1/m)
Expand All @@ -428,7 +430,7 @@ subroutine expro_compute_derived
call bound_deriv(expro_sdlnnidr_new(:),expro_ni_new(:)*expro_dlnnidr_new(:),&
expro_rmin,expro_n_exp)
expro_sdlnnidr_new(:) = expro_sdlnnidr_new(:)/expro_ni_new(:)*expro_rhos(:)

if (minval(expro_ni_new(:)) <= 0d0) expro_error = 1

else
Expand Down Expand Up @@ -499,7 +501,7 @@ subroutine expro_compute_derived

! Reset geo variables to standard values to prevent expro from leaving
! geo in a "mysterious" state

geo_rmin_in = 1d0
geo_rmaj_in = 0.5d0
geo_drmaj_in = 3d0
Expand Down
20 changes: 8 additions & 12 deletions f2py/pygacode/profiles_gen/prgen_shapeprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
from .prgen_contour import *
from .prgen_shape import *

if len(sys.argv) > 1:
gfile = sys.argv[1]
mag = sys.argv[2]
narc = int(sys.argv[3])
npsi = int(sys.argv[4])
nharm = int(sys.argv[5])
nfourier = int(sys.argv[6])
plotpng = bool(int(sys.argv[7]))
psinorm = float(sys.argv[8])
else:
print('Usage: python prgen_shapeprofile.py <gfile> <mag> <narc> <npsi> <nfourier>')
sys.exit()
gfile = sys.argv[1]
mag = sys.argv[2]
narc = int(sys.argv[3])
npsi = int(sys.argv[4])
nharm = int(sys.argv[5])
nfourier = int(sys.argv[6])
plotpng = bool(int(sys.argv[7]))
psinorm = float(sys.argv[8])

efit = prgen_geqdsk(gfile)
psi0 = efit['SIMAG']
Expand Down
2 changes: 1 addition & 1 deletion profiles_gen/bin/profiles_gen
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ N_NULL=128
IPCCW=0
BTCCW=0

# OMFIT mapper variables
# Mapper variables
EFIT=0
MAG=auto
NPSI=256
Expand Down
1 change: 1 addition & 0 deletions profiles_gen/src/prgen_write.f90
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ subroutine prgen_write
expro_head_gfile = '# *gfile : '//trim(file_g)
expro_head_cerfile = '# *cerfile : '//trim(file_cer)

call expro_compute_derived
call expro_write('input.gacode')
print '(a)','INFO: (prgen_write) Wrote input.gacode.'
!-------------------------------------------------------------------------------------
Expand Down

0 comments on commit 388e6e7

Please sign in to comment.