From 00628bd2223a2abe5c02ca88806f22c66076e88a Mon Sep 17 00:00:00 2001 From: Jeff Candy Date: Thu, 17 Oct 2024 17:57:39 -0700 Subject: [PATCH] Progress on cgyro_json --- cgyro/bin/cgyro_json | 48 ++++++++++++++++++++++--------- cgyro/bin/input.json | 1 + cgyro/src/cgyro_make_profiles.F90 | 16 +++++------ 3 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 cgyro/bin/input.json diff --git a/cgyro/bin/cgyro_json b/cgyro/bin/cgyro_json index 2dfe845fe..3ee904e33 100755 --- a/cgyro/bin/cgyro_json +++ b/cgyro/bin/cgyro_json @@ -28,27 +28,37 @@ for i in range(sim.n_species): d = {} +with open('/home/candy/GIT/gacode/cgyro/bin/input.json','r') as file: + default = json.load(file) + +# Determine non-default values in input.cgyro +with open('input.cgyro.gen','r') as file: + for line in file: + u = line.split() + key = u[1] + value = u[0] + if key in default.keys(): + if str(value) != str(default[key]): + d[key] = value + # Code-specific parameters +d['N_ENERGY'] = sim.n_energy +d['N_XI'] = sim.n_xi d['N_THETA'] = sim.n_theta -d['N_RADIAL'] = sim.n_theta +d['N_RADIAL'] = sim.n_radial +d['N_TOROIDAL'] = sim.n_n +d['N_FIELD'] = sim.n_field # Physics parameters d['RMIN'] = sim.rmin d['RMAJ'] = sim.rmaj d['Q'] = sim.q -d['SHEAR'] = sim.shear +d['S'] = sim.shear d['MACH'] = sim.mach d['GAMMA_E'] = sim.gamma_e d['GAMMA_P'] = sim.gamma_p d['BETAE_UNIT'] = sim.betae_unit -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['ZMAG'] = sim.zmag d['DZMAG'] = sim.dzmag d['SHIFT'] = sim.shift @@ -60,9 +70,15 @@ d['ZETA'] = sim.zeta d['S_ZETA'] = sim.s_zeta d['SHAPE_SIN'] = sim.shape_sin[:].tolist() - d['SHAPE_COS'] = sim.shape_cos[:].tolist() +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() + # JSON output with open('json.cgyro.localdump','w') as f: json.dump(d,f,indent=2,sort_keys=True) @@ -129,6 +145,10 @@ d['velocity_tor_gradient_norm'] = lref/vthref*sim.gamma_p d['collisionality_norm'] = (lref/vthref)*sim.nu[ielec] # electron beta d['beta_reference'] = sim.betae_unit/bref**2 +# pressure gradient +d['pressure_gradient_norm'] = -lref*sim.beta_star/bref**2 +# Debye length (normalized to lref) +d['debye_length_reference'] = sim.lambda_star*sim.rho_star_norm/lref #----------------------------------------------------------------------- #----------------------------------------------------------------------- @@ -143,14 +163,14 @@ d['delongation_dr_minor_norm'] = sim.s_kappa*sim.kappa*lref/sim.rmin # Shape coefficients (cn,sn) d['shapecoefficients_c'] = sim.shape_cos[:nmax].tolist() d['shapecoefficients_s'] = sim.shape_sin[:nmax].tolist() -d['shapecoefficients_s'][1] = np.arcsin(sim.delta) -d['shapecoefficients_s'][2] = -sim.zeta +#d['shapecoefficients_s'][1] = np.arcsin(sim.delta) +#d['shapecoefficients_s'][2] = -sim.zeta # Derivatives of (cn,sn) d['dc_dr_minor_norm'] = (sim.shape_s_cos[:nmax]*lref/sim.rmin).tolist() d['ds_dr_minor_norm'] = (sim.shape_s_sin[:nmax]*lref/sim.rmin).tolist() -d['ds_dr_minor_norm'][1] = sim.s_delta*lref/sim.rmin/np.cos(np.arcsin(sim.delta)) -d['ds_dr_minor_norm'][2] = -sim.s_zeta*lref/sim.rmin +#d['ds_dr_minor_norm'][1] = sim.s_delta*lref/sim.rmin/np.cos(np.arcsin(sim.delta)) +#d['ds_dr_minor_norm'][2] = -sim.s_zeta*lref/sim.rmin #----------------------------------------------------------------------- with open('json.cgyro.imas','w') as f: diff --git a/cgyro/bin/input.json b/cgyro/bin/input.json new file mode 100644 index 000000000..bd67fd5ff --- /dev/null +++ b/cgyro/bin/input.json @@ -0,0 +1 @@ +{"N_ENERGY":8,"N_XI":16,"N_THETA":24,"N_RADIAL":4,"N_TOROIDAL":1,"N_FIELD":1,"E_MAX":8.0,"ALPHA_POLY":0.0,"E_FIX":2,"DELTA_T_METHOD":0,"DELTA_T":0.01,"ERROR_TOL":6e-5,"MAX_TIME":100.0,"PRINT_STEP":100,"RESTART_STEP":10,"RESTART_PRESERVATION_MODE":3,"MPIIO_STRIPE_FACTOR":0,"MPIIO_SMALL_STRIPE_FACTOR":0,"FREQ_TOL":0.001,"UP_RADIAL":1.0,"UP_THETA":1.0,"UP_ALPHA":0.0,"NUP_RADIAL":3,"NUP_THETA":3,"NUP_ALPHA":3,"N_WAVE":2,"CONSTANT_STREAM_FLAG":1,"EXPLICIT_TRAP_FLAG":0,"KY":0.3,"BOX_SIZE":1,"IPCCW":-1.0,"BTCCW":-1.0,"SILENT_FLAG":0,"PROFILE_MODEL":1,"EQUILIBRIUM_MODEL":2,"COLLISION_MODEL":4,"COLLISION_MOM_RESTORE":1,"COLLISION_ENE_RESTORE":1,"COLLISION_ENE_DIFFUSION":1,"COLLISION_KPERP":1,"COLLISION_FIELD_MODEL":1,"COLLISION_ION_MODEL":0,"COLLISION_PRECISION_MODE":0,"COLLISION_TEST_MODE":0,"COLLISION_FIELD_MAX_L":-2,"COLLISION_TEST_MAX_L":-2,"Z_EFF":1.0,"Z_EFF_METHOD":2,"ZF_TEST_MODE":0,"NONLINEAR_FLAG":0,"AE_FLAG":0,"TEMP_AE":1.0,"DENS_AE":1.0,"MASS_AE":0.0002724486,"DLNTDR_AE":1.0,"DLNNDR_AE":1.0,"LAMBDA_STAR":0.0,"H_PRINT_FLAG":0,"MOMENT_PRINT_FLAG":0,"GFLUX_PRINT_FLAG":0,"FIELD_PRINT_FLAG":0,"AMP0":0.0,"AMP":0.1,"GAMMA_E":0.0,"GAMMA_P":0.0,"MACH":0.0,"ROTATION_MODEL":1,"TOROIDALS_PER_PROC":1,"MPI_RANK_ORDER":2,"VELOCITY_ORDER":1,"HIPREC_FLAG":0,"UDSYMMETRY_FLAG":0,"SHEAR_METHOD":2,"GLOBAL_FLAG":0,"N_GLOBAL":4,"NU_GLOBAL":15.0,"THETA_PLOT":1,"GPU_BIGMEM_FLAG":1,"UPWIND_SINGLE_FLAG":0,"PX0":0.0,"STREAM_TERM":0,"STREAM_FACTOR":1.0,"EXCH_FLAG":0,"RES_WEIGHT_POWER":1.0,"RMIN":0.5,"RMAJ":3.0,"Q":2.0,"S":1.0,"SHIFT":0.0,"KAPPA":1.0,"S_KAPPA":0.0,"DELTA":0.0,"S_DELTA":0.0,"ZETA":0.0,"S_ZETA":0.0,"ZMAG":0.0,"DZMAG":0.0,"SHAPE_SIN3":0.0,"SHAPE_S_SIN3":0.0,"SHAPE_SIN4":0.0,"SHAPE_S_SIN4":0.0,"SHAPE_SIN5":0.0,"SHAPE_S_SIN5":0.0,"SHAPE_SIN6":0.0,"SHAPE_S_SIN6":0.0,"SHAPE_COS0":0.0,"SHAPE_S_COS0":0.0,"SHAPE_COS1":0.0,"SHAPE_S_COS1":0.0,"SHAPE_COS2":0.0,"SHAPE_S_COS2":0.0,"SHAPE_COS3":0.0,"SHAPE_S_COS3":0.0,"SHAPE_COS4":0.0,"SHAPE_S_COS4":0.0,"SHAPE_COS5":0.0,"SHAPE_S_COS5":0.0,"SHAPE_COS6":0.0,"SHAPE_S_COS6":0.0,"BETAE_UNIT":0.0,"N_SPECIES":1,"NU_EE":0.1,"Z":[1,1,1,1,1,1,1,1,1,1,1],"MASS":[1,1,1,1,1,1,1,1,1,1,1],"DENS":[0,0,0,0,0,0,0,0,0,0,0],"TEMP":[1,1,1,1,1,1,1,1,1,1,1],"DLNNDR":[1,1,1,1,1,1,1,1,1,1,1],"DLNTDR":[1,1,1,1,1,1,1,1,1,1,1],"SDLNNDR":[0,0,0,0,0,0,0,0,0,0,0],"SDLNTDR":[0,0,0,0,0,0,0,0,0,0,0],"SBETA":[0,0,0,0,0,0,0,0,0,0,0],"DLNNDR_SCALE":[1,1,1,1,1,1,1,1,1,1,1],"DLNTDR_SCALE":[1,1,1,1,1,1,1,1,1,1,1],"QUASINEUTRAL_FLAG":1,"LAMBDA_STAR_SCALE":0.0,"GAMMA_E_SCALE":1.0,"GAMMA_P_SCALE":1.0,"MACH_SCALE":1.0,"BETA_STAR_SCALE":1.0,"BETAE_UNIT_SCALE":1.0,"NU_EE_SCALE":1.0,"ZF_SCALE":1.0} diff --git a/cgyro/src/cgyro_make_profiles.F90 b/cgyro/src/cgyro_make_profiles.F90 index be4b1497b..011bc2bfe 100644 --- a/cgyro/src/cgyro_make_profiles.F90 +++ b/cgyro/src/cgyro_make_profiles.F90 @@ -188,7 +188,7 @@ subroutine cgyro_make_profiles ! Debye length (from NRL plasma formulary): ! Use input lambda_debye as scaling parameter - lambda_star = 7.43 * sqrt((1e3*temp_norm)/(1e13*dens_norm))/rhos + lambda_star = 7.434*sqrt((1e3*temp_norm)/(1e13*dens_norm))/rhos ! Normalize do is=1,n_species @@ -212,14 +212,14 @@ subroutine cgyro_make_profiles ! Re-scaling lambda_star = lambda_star * lambda_star_scale - gamma_e = gamma_e * gamma_e_scale - gamma_p = gamma_p * gamma_p_scale - mach = mach * mach_scale - betae_unit = betae_unit * betae_unit_scale + gamma_e = gamma_e * gamma_e_scale + gamma_p = gamma_p * gamma_p_scale + mach = mach * mach_scale + betae_unit = betae_unit * betae_unit_scale do is=1,n_species - dlnndr(is) = dlnndr(is) * dlnndr_scale(is) - dlntdr(is) = dlntdr(is) * dlntdr_scale(is) - nu(is) = nu(is) * nu_ee_scale + dlnndr(is) = dlnndr(is) * dlnndr_scale(is) + dlntdr(is) = dlntdr(is) * dlntdr_scale(is) + nu(is) = nu(is) * nu_ee_scale enddo ! Set beta_* consistent with re-scaled beta and gradients and then re-scale