@@ -34,18 +34,17 @@ mass_arr::Array{Float64, 1} = 10.0 .^ vcat( range(start=log10(0.5), stop=log10(
3434# enter the least-important parameters first
3535grid:: OrderedDict = OrderedDict {String,Array{Float64,1}} ((
3636
37+ " frac_core" => range (start= 0.2 , stop= 0.7 , step= 0.1 ),
38+ " frac_atm" => range (start= 0.00 , stop= 0.15 , step= 0.03 ),
39+ " mass_tot" => mass_arr, # M_earth
40+
3741 # metallicities here are by MASS fraction relative to hydrogen (converted to mole below)
38- " metal_C" => 10 .^ range (start= - 1.0 , stop= 3.0 , step= 2.0 ),
3942 # "metal_S" => 10 .^ range(start=-1.0, stop=3.0, step=2.0),
4043 # "metal_O" => 10 .^ range(start=-1.0, stop=3.0, step=2.0),
41-
42- " frac_core" => range (start= 0.2 , stop= 0.7 , step= 0.1 ),
43- " frac_atm" => range (start= 0.00 , stop= 0.15 , step= 0.03 ),
44+ " metal_C" => 10 .^ range (start= - 1.0 , stop= 3.0 , step= 2.0 ),
4445
4546 # "Teff" => range(start=2500, stop=6000, step=700.0),
4647 " instellation" => 10 .^ range (start= log10 (1.0 ), stop= log10 (2500.0 ), length= 5 ), # S_earth
47-
48- " mass_tot" => mass_arr, # M_earth
4948))
5049
5150# Variables to record
@@ -56,17 +55,16 @@ output_keys = ["succ", "flux_loss",
5655
5756# Grid management options
5857save_netcdfs = false # NetCDF file for each case
59- save_plots = false # plots for each case
60- save_ncdf_tp = true # a single NetCDF containing all T(p) solutions
58+ save_plots = true # plots for each case
6159
6260# Runtime options
63- AGNI. solver. ls_increase= 1.02
64- modwrite:: Int = 1 # frequency to write CSV file
65- modplot:: Int = 2 # Plot during runtime (debug)
61+ AGNI. solver. ls_increase= 1.1
62+ modwrite:: Int = 2 # frequency to write CSV file
63+ modplot:: Int = 0 # Plot during runtime (debug)
6664frac_min:: Float64 = 0.001 # 0.001 -> 1170 bar for Earth
6765frac_max:: Float64 = 1.0
6866transspec_p:: Float64 = 2e3 # Pa
69- fc_floor:: Float64 = 500 .0 # K
67+ fc_floor:: Float64 = 300 .0 # K
7068
7169# =============================================================================
7270# Parse keys and flatten grid
@@ -84,6 +82,18 @@ mkdir(output_dir)
8482# Backup config to output dir
8583cp (joinpath (ROOT_DIR,cfg_base), joinpath (output_dir," base_config.toml" ))
8684
85+ # IO directory
86+ # IO_DIR::String = "/tmp/"
87+ # if haskey(ENV,"TMPDIR")
88+ # IO_DIR = abspath(ENV["TMPDIR"])
89+ # end
90+ # IO_DIR = joinpath(IO_DIR,"agni_grid") * "/"
91+ IO_DIR = output_dir
92+ @info " IO folder: $IO_DIR "
93+
94+ mkdir (joinpath (output_dir," nc" ))
95+ mkdir (joinpath (output_dir," pl" ))
96+
8797# Results path
8898result_table_path:: String = joinpath (output_dir," result_table.csv" )
8999result_emits_path:: String = joinpath (output_dir," result_emits.csv" )
@@ -340,6 +350,7 @@ atmosphere.setup!(atmos, ROOT_DIR, output_dir,
340350 p_top,
341351 mf_dict, " " ;
342352
353+ IO_DIR= IO_DIR,
343354 condensates= condensates,
344355 κ_grey_lw= grey_lw,
345356 κ_grey_sw= grey_sw,
@@ -418,7 +429,8 @@ function update_structure!(atmos, mass_tot, frac_atm, frac_core)
418429 atmos. grav_surf = phys. grav_accel (atmos. interior_mass, atmos. rp)
419430
420431 # surface pressure
421- atmos. p_boa = mass_atm * atmos. grav_surf / (4 * pi * atmos. rp^ 2 )
432+ atmos. p_oboa = mass_atm * atmos. grav_surf / (4 * pi * atmos. rp^ 2 )
433+ atmos. p_boa = atmos. p_oboa
422434 atmosphere. generate_pgrid! (atmos)
423435end
424436
@@ -523,16 +535,14 @@ for (i,p) in enumerate(grid_flat)
523535
524536 # Set temperature array based on interpolation from last solution
525537 max_steps = Int (cfg[" execution" ][" max_steps" ])
526- easy_start = Bool (cfg[" execution" ][" easy_start" ])
527- if i > 1
528- if succ_last
529- # last iter was successful
530- setpt. fromarrays! (atmos, result_profs[i- 1 ][" p" ], result_profs[i- 1 ][" t" ])
531- else
532- # last iter failed -> restore initial guess for T(p)
533- setpt. request! (atmos, cfg[" execution" ][" initial_state" ])
534- easy_start = true
535- end
538+ if succ_last && (i > 1 )
539+ # last iter was successful
540+ setpt. fromarrays! (atmos, result_profs[i- 1 ][" p" ], result_profs[i- 1 ][" t" ])
541+ easy_start = false
542+ else
543+ # last iter failed -> restore initial guess for T(p)
544+ setpt. request! (atmos, cfg[" execution" ][" initial_state" ])
545+ easy_start = Bool (cfg[" execution" ][" easy_start" ])
536546 end
537547
538548 # Solve for RCE
@@ -554,20 +564,22 @@ for (i,p) in enumerate(grid_flat)
554564 save_frames= false ,
555565 radiative_Kzz= false ,
556566 perturb_all= perturb_all,
557-
558567 )
559568
560569 # Report radius
561570 @info @sprintf (" found r_phot = %.3f R_earth" ,atmos. transspec_r/ R_earth)
562571
563572 # Write NetCDF file for this case
564573 if save_netcdfs
565- save. write_ncdf (atmos, joinpath (atmos. OUT_DIR,@sprintf (" %08d.nc" ,i)))
574+ save. write_ncdf (atmos, joinpath (atmos. OUT_DIR," nc " , @sprintf (" %08d.nc" ,i)))
566575 end
567576
568577 # Make plot for this case
569578 if save_plots
570- plotting. plot_pt (atmos, joinpath (atmos. OUT_DIR,@sprintf (" %08d_pt.png" ,i)))
579+ plotting. combined (plotting. plot_pt (atmos," " ), plotting. plot_fluxes (atmos, " " ),
580+ plotting. plot_vmr (atmos," " ), plotting. plot_radius (atmos, " " ),
581+ " Index = $i Success = $succ " ,
582+ joinpath (atmos. OUT_DIR," pl" ,@sprintf (" %08d_pl.png" ,i)))
571583 end
572584
573585 # Record keys (all in SI)
0 commit comments