Skip to content

Commit

Permalink
More parameters added to JSON writer
Browse files Browse the repository at this point in the history
  • Loading branch information
jcandy committed Sep 4, 2024
1 parent 70ab80d commit beb9270
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions cgyro/bin/cgyro_json
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
#!/usr/bin/env python

import json
import numpy as np
from pygacode.cgyro import data

sim = data.cgyrodata('./')

#--------------------------------------------------------------
# json.cgyro.localdump

d = {}

d['RMIN'] = sim.rmin
d['RMAJ'] = sim.rmaj
d['SHEAR'] = sim.shear
d['Q'] = sim.q
d['SHEAR'] = sim.shear
d['Z'] = sim.z[:].tolist()
d['MASS'] = sim.mass[:].tolist()
d['DENS'] = sim.dens[:].tolist()
d['TEMP'] = sim.temp[:].tolist()
d['DLNNDR'] = sim.dlnndr[:].tolist()
d['DLNTDR'] = sim.dlntdr[:].tolist()
d['MACH'] = sim.mach
d['GAMMA_E'] = sim.gamma_e
d['GAMMA_P'] = sim.gamma_p
d['BETAE_UNIT'] = sim.betae_unit

with open('json.cgyro.localdump','w') as f:
json.dump(d,f,indent=2,sort_keys=True)

#--------------------------------------------------------------
# json.cgyro.imas

lref=sim.rmaj
vthref = np.sqrt(2.0)
bref = sim.b_gs2

d = {}
d['r_minor_norm'] = sim.rmin/lref
Expand All @@ -35,7 +46,21 @@ d['density_norm'] = sim.dens[:].tolist()
d['temperature_norm'] = sim.temp[:].tolist()
d['density_log_gradient_norm'] = (lref*sim.dlnndr[:]).tolist()
d['temperature_log_gradient_norm'] = (lref*sim.dlntdr[:]).tolist()
d['velocity_tor_norm'] =

# Rotation parameters
d['velocity_tor_norm'] = sim.mach/vthref
# -L/v 1/B (r/q Bu) (-dw/dr) = L/v Bu/B (r/q dw/dr) = L/v Bu/B (-GAMMA_E)
d['shearing_rate_norm'] = -(lref/vthref)/bref*sim.gamma_e
# -L^2/v dw/dr = -L/v (L dw/dr) = -L/v (-GAMMA_P)
d['velocity_tor_gradient_norm'] = lref/vthref*sim.gamma_p

d['beta_reference'] = sim.betae_unit/bref**2

d['dgeometric_axis_r_dr_minor'] = sim.shift
d['dgeometric_axis_z_dr_minor'] = sim.dzmag

d['elongation'] = sim.kappa
d['delongation_dr_minor_norm'] = sim.s_kappa*sim.kappa*lref/sim.rmin

with open('json.cgyro.imas','w') as f:
json.dump(d,f,indent=2,sort_keys=True)
Expand Down

0 comments on commit beb9270

Please sign in to comment.