Skip to content

Commit bc92f4b

Browse files
committed
Consolidate default values into single location
1 parent 7225d39 commit bc92f4b

2 files changed

Lines changed: 114 additions & 65 deletions

File tree

src/AGNI.jl

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,20 @@ module AGNI
264264

265265
# composition stuff (defaults to be overwritten)
266266
condensates::Array{String,1} = String[]
267-
demixing::Bool = false
268-
chem::Bool = false
269-
rainout::Bool = false
270-
oceans::Bool = false
271-
coldtrap::Bool = true
272-
evap_efficiency::Float64 = 0.05
267+
demixing::Bool = atmosphere.CFG_demixing
268+
chem::Bool = atmosphere.CFG_chem
269+
rainout::Bool = atmosphere.CFG_rainout
270+
oceans::Bool = atmosphere.CFG_oceans
271+
coldtrap::Bool = atmosphere.CFG_coldtrap
272+
evap_efficiency::Float64 = atmosphere.CFG_evap_efficiency
273273
p_surf::Float64 = 0.0
274274
p_top::Float64 = 0.0
275275
pp_dict::Dict{String, Float64} = Dict{String, Float64}()
276276
mf_dict::Dict{String, Float64} = Dict{String, Float64}()
277277
mf_path::String = ""
278278
metallicities::Dict{String, Float64}= Dict{String, Float64}()
279279
transparent::Bool = false
280-
real_gas::Bool = false
280+
real_gas::Bool = atmosphere.CFG_real_gas
281281

282282
# transparent atmosphere?
283283
if haskey(cfg["composition"], "transparent")
@@ -398,8 +398,8 @@ module AGNI
398398

399399
# RFM radtrans
400400
rfm_parfile::String = atmosphere.UNSET_STR
401-
rfm_wn_min::Float64 = 4000.0
402-
rfm_wn_max::Float64 = 4020.0
401+
rfm_wn_min::Float64 = atmosphere.CFG_rfm_wn_min
402+
rfm_wn_max::Float64 = atmosphere.CFG_rfm_wn_max
403403
if haskey(cfg["files"],"rfm_parfile")
404404
rfm_parfile = cfg["files"]["rfm_parfile"]
405405
if haskey(cfg["execution"],"rfm_wn_min") && haskey(cfg["execution"],"rfm_wn_max")
@@ -413,8 +413,8 @@ module AGNI
413413
end
414414

415415
# double grey radtrans opacities
416-
κ_grey_lw::Float64 = 1e-2 # this will be over-written
417-
κ_grey_sw::Float64 = 1e-2 # ^
416+
κ_grey_lw::Float64 = atmosphere.CFG_κ_grey_lw # this will be over-written
417+
κ_grey_sw::Float64 = atmosphere.CFG_κ_grey_sw # ^
418418
if (lowercase(cfg["files"]["input_sf"]) == "greygas") || cfg["execution"]["grey_start"]
419419
if all(k in keys(cfg["physics"]) for k in ["grey_sw","grey_lw"])
420420
κ_grey_lw = Float64(cfg["physics"]["grey_lw"])
@@ -463,7 +463,8 @@ module AGNI
463463

464464
# Read OPTIONAL configuration options from dict
465465
# sensible heat at the surface
466-
roughness::Float64 = 0.001; windspeed::Float64 = 2.0
466+
roughness::Float64 = atmosphere.CFG_surf_roughness
467+
windspeed::Float64 = atmosphere.CFG_surf_windspeed
467468
if incl_sens && !transparent
468469
if ! all(k in keys(cfg["planet"]) for k in ["roughness","wind_speed"])
469470
@error "Config: sensible heating included"
@@ -474,7 +475,9 @@ module AGNI
474475
windspeed = cfg["planet"]["wind_speed"]
475476
end
476477
# conductive skin case
477-
skin_k::Float64=2.0; skin_d::Float64=0.1; tmp_magma::Float64=3000.0 # will be overwritten
478+
skin_k::Float64 = atmosphere.CFG_skin_k
479+
skin_d::Float64 = atmosphere.CFG_skin_d
480+
tmp_magma::Float64 = atmosphere.CFG_tmp_magma
478481
if sol_type == 2
479482
if ! all(k in keys(cfg["planet"]) for k in ["skin_k","skin_d","tmp_magma"])
480483
@error "Config: solution type $sol_type selected"
@@ -486,7 +489,7 @@ module AGNI
486489
tmp_magma = cfg["planet"]["tmp_magma"]
487490
end
488491
# effective temperature case
489-
flux_int::Float64 = 0.0
492+
flux_int::Float64 = atmosphere.CFG_flux_int
490493
if sol_type == 3
491494
if ! haskey(cfg["planet"],"flux_int")
492495
@error "Config: solution type $sol_type selected"
@@ -496,7 +499,7 @@ module AGNI
496499
flux_int = cfg["planet"]["flux_int"]
497500
end
498501
# target OLR case
499-
target_olr::Float64 = 250.0
502+
target_olr::Float64 = atmosphere.CFG_target_olr
500503
if sol_type == 4
501504
if ! haskey(cfg["planet"],"target_olr")
502505
@error "Config: solution type $sol_type selected"

src/atmosphere.jl

Lines changed: 96 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,59 @@ module atmosphere
4040
HYDROGRAV_steps::Int64 = 2000 # total number of steps in height integration
4141
HYDROGRAV_maxdr::Float64 = 1e8 # maximum dz across each layer [m]
4242
HYDROGRAV_mindr::Float64 = 1e-5 # minimum dz across each layer [m]
43-
HYDROGRAV_ming::Float64 = 1e-4 # minimum allowed gravity [m/s^2]
43+
HYDROGRAV_ming::Float64 = 1e-4 # minimum allowed gravity [m/s^2]
4444
HYDROGRAV_constg::Bool = false # constant gravity with height?
4545
HYDROGRAV_selfg::Bool = true # include self-gravity of the atmosphere?
4646

47-
# Other constants
47+
# Configuration defaults
48+
const CFG_surface_material::String = "greybody"
49+
const CFG_albedo_s::Float64 = 0.0
50+
const CFG_tmp_floor::Float64 = 2.0
51+
const CFG_tmp_ceiling::Float64 = 2e4
52+
const CFG_surf_roughness::Float64 = 0.001
53+
const CFG_surf_windspeed::Float64 = 2.0
54+
const CFG_Kzz_kbreak::Float64 = 1e5
55+
const CFG_Kzz_pbreak::Float64 = 1e5 # 1 bar
56+
const CFG_Kzz_type::Int = 2
57+
const CFG_mlt_asymptotic::Bool = true
58+
const CFG_mlt_criterion::Char = 's'
59+
const CFG_tmp_magma::Float64 = 3000.0
60+
const CFG_skin_d::Float64 = 0.05
61+
const CFG_skin_k::Float64 = 2.0
62+
const CFG_overlap_method::String = "ee"
63+
const CFG_target_olr::Float64 = 250.0
64+
const CFG_flux_int::Float64 = 0.0
65+
const CFG_all_channels::Bool = true
66+
const CFG_flag_rayleigh::Bool = true
67+
const CFG_flag_gcontinuum::Bool = true
68+
const CFG_flag_aerosol::Bool = false
69+
const CFG_flag_cloud::Bool = false
70+
const CFG_phs_timescale::Float64 = 1e6
71+
const CFG_evap_efficiency::Float64 = 0.05
72+
const CFG_coldtrap::Bool = true
73+
const CFG_rainout::Bool = false
74+
const CFG_oceans::Bool = false
75+
const CFG_real_gas::Bool = true
76+
const CFG_demixing::Bool = false
77+
const CFG_chem::Bool = false
78+
const CFG_thermo_functions::Bool = true
79+
const CFG_use_all_gases::Bool = false
80+
const CFG_use_all_vols::Bool = false
81+
const CFG_check_integrity::Bool = true
82+
const CFG_rfm_wn_min::Float64 = 4000.0
83+
const CFG_rfm_wn_max::Float64 = 4020.0
84+
const CFG_κ_grey_lw::Float64 = 8e-4
85+
const CFG_κ_grey_sw::Float64 = 2e-4
86+
const CFG_fastchem_floor::Float64 = 400.0
87+
const CFG_fastchem_maxiter_chem::Int = 80000
88+
const CFG_fastchem_maxiter_solv::Int = 40000
89+
const CFG_fastchem_xtol_chem::Float64 = 1e-3
90+
const CFG_fastchem_xtol_elem::Float64 = 1e-3
91+
const CFG_fastchem_wellmixed::Bool = false
92+
const CFG_ocean_ob_frac::Float64 = 0.6
93+
const CFG_ocean_cs_height::Float64 = 3000.0
94+
95+
# Variable limits and defaults
4896
const UNSET_STR::String = "__AGNI_UNSET_STR"
4997
const NLEV_minimum::Int = 25 # minimum allowed number of levels
5098
const PHS_TIMESCALE_MIN::Float64 = 0.01 # minimum phase change timescale [s]
@@ -55,8 +103,6 @@ module atmosphere
55103
const SKIN_K_MIN::Float64 = 1e-6 # [W K-1 m-1]
56104
const COND_DISALLOWED::Array = ["H2","He"]
57105
const T_INI_MAX::Float64 = 1500.0 # Maximum initial temperature [K]
58-
59-
# Pressure grid
60106
const PRESSURE_RATIO_MIN::Float64 = 1.0001 # minimum p_boa/p_toa ratio
61107
const PRESSURE_FACT_BOT::Float64 = 0.6 # Pressure factor at bottom layer
62108
const PRESSURE_FACT_TOP::Float64 = 0.8 # Pressure factor at top layer
@@ -429,6 +475,7 @@ module atmosphere
429475
- `surf_roughness::Float64` surface roughness length scale [m]
430476
- `surf_windspeed::Float64` surface wind speed [m s-1].
431477
- `Kzz_kbreak::Float64` reference eddy diffusion coefficient, SI units [m2 s-1]
478+
- `Kzz_pbreak::Float64` reference pressure for Kzz break point [Pa]
432479
- `Kzz_type::Int` parametrisation of Kzz. Options: 1 (constant), 2 (MLT wl), 3 (MLT Fc)
433480
- `mlt_asymptotic::Bool` mixing length scales asymptotically, but ~0 near ground
434481
- `mlt_criterion::Char` MLT stability criterion. Options: (s)chwarzschild, (l)edoux.
@@ -441,7 +488,6 @@ module atmosphere
441488
- `all_channels::Bool` use all channels available for RT?
442489
- `flag_rayleigh::Bool` include rayleigh scattering?
443490
- `flag_gcontinuum::Bool` include generalised continuum absorption?
444-
- `flag_continuum::Bool` include continuum absorption?
445491
- `flag_aerosol::Bool` include aerosols?
446492
- `aerosol_species::Dict` aerosols MMR values or associated condensates
447493
- `flag_cloud::Bool` include clouds?
@@ -478,56 +524,56 @@ module atmosphere
478524
IO_DIR::String = UNSET_STR,
479525
condensates = String[],
480526
metallicities::Dict = Dict{String,Float64}(),
481-
surface_material::String = "greybody",
482-
albedo_s::Float64 = 0.0,
483-
tmp_floor::Float64 = 2.0,
484-
tmp_ceiling::Float64 = 2e4,
485-
surf_roughness::Float64 = 0.001,
486-
surf_windspeed::Float64 = 2.0,
487-
Kzz_kbreak::Float64 = 1e5,
488-
Kzz_type::Int = 2,
489-
mlt_asymptotic::Bool = true,
490-
mlt_criterion::Char = 's',
491-
tmp_magma::Float64 = 3000.0,
492-
skin_d::Float64 = 0.05,
493-
skin_k::Float64 = 2.0,
494-
overlap_method::String = "ee",
495-
target_olr::Float64 = 0.0,
496-
flux_int::Float64 = 0.0,
497-
all_channels::Bool = true,
498-
flag_rayleigh::Bool = false,
499-
flag_gcontinuum::Bool = false,
500-
flag_continuum::Bool = false,
501-
flag_aerosol::Bool = false,
502-
flag_cloud::Bool = false,
527+
surface_material::String = CFG_surface_material,
528+
albedo_s::Float64 = CFG_albedo_s,
529+
tmp_floor::Float64 = CFG_tmp_floor,
530+
tmp_ceiling::Float64 = CFG_tmp_ceiling,
531+
surf_roughness::Float64 = CFG_surf_roughness,
532+
surf_windspeed::Float64 = CFG_surf_windspeed,
533+
Kzz_kbreak::Float64 = CFG_Kzz_kbreak,
534+
Kzz_pbreak::Float64 = CFG_Kzz_pbreak,
535+
Kzz_type::Int = CFG_Kzz_type,
536+
mlt_asymptotic::Bool = CFG_mlt_asymptotic,
537+
mlt_criterion::Char = CFG_mlt_criterion,
538+
tmp_magma::Float64 = CFG_tmp_magma,
539+
skin_d::Float64 = CFG_skin_d,
540+
skin_k::Float64 = CFG_skin_k,
541+
overlap_method::String = CFG_overlap_method,
542+
target_olr::Float64 = CFG_target_olr,
543+
flux_int::Float64 = CFG_flux_int,
544+
all_channels::Bool = CFG_all_channels,
545+
flag_rayleigh::Bool = CFG_flag_rayleigh,
546+
flag_gcontinuum::Bool = CFG_flag_gcontinuum,
547+
flag_aerosol::Bool = CFG_flag_aerosol,
548+
flag_cloud::Bool = CFG_flag_cloud,
503549
aerosol_species::Dict = Dict{String, Union{Float64,String}}(),
504550

505-
phs_timescale::Float64 = 1e6,
506-
evap_efficiency::Float64 = 0.05,
551+
phs_timescale::Float64 = CFG_phs_timescale,
552+
evap_efficiency::Float64 = CFG_evap_efficiency,
507553

508-
coldtrap::Bool = true,
509-
real_gas::Bool = true,
510-
demixing::Bool = false,
511-
thermo_functions::Bool = true,
512-
use_all_gases::Bool = false,
513-
use_all_vols::Bool = false,
514-
check_integrity::Bool = true,
554+
coldtrap::Bool = CFG_coldtrap,
555+
real_gas::Bool = CFG_real_gas,
556+
demixing::Bool = CFG_demixing,
557+
thermo_functions::Bool = CFG_thermo_functions,
558+
use_all_gases::Bool = CFG_use_all_gases,
559+
use_all_vols::Bool = CFG_use_all_vols,
560+
check_integrity::Bool = CFG_check_integrity,
515561

516-
κ_grey_lw::Float64 = 8e-4,
517-
κ_grey_sw::Float64 = 2e-4,
562+
κ_grey_lw::Float64 = CFG_κ_grey_lw,
563+
κ_grey_sw::Float64 = CFG_κ_grey_sw,
518564

519565
fastchem_work::String = UNSET_STR,
520-
fastchem_floor::Float64 = 400.0,
521-
fastchem_maxiter_chem::Int = 80000,
522-
fastchem_maxiter_solv::Int = 40000,
523-
fastchem_xtol_chem::Float64 = 1.0e-3,
524-
fastchem_xtol_elem::Float64 = 1.0e-3,
525-
fastchem_wellmixed::Bool = false,
566+
fastchem_floor::Float64 = CFG_fastchem_floor,
567+
fastchem_maxiter_chem::Int = CFG_fastchem_maxiter_chem,
568+
fastchem_maxiter_solv::Int = CFG_fastchem_maxiter_solv,
569+
fastchem_xtol_chem::Float64 = CFG_fastchem_xtol_chem,
570+
fastchem_xtol_elem::Float64 = CFG_fastchem_xtol_elem,
571+
fastchem_wellmixed::Bool = CFG_fastchem_wellmixed,
526572

527573
rfm_parfile::String = UNSET_STR,
528574

529-
ocean_ob_frac::Float64 = 0.6,
530-
ocean_cs_height::Float64 = 3000.0
575+
ocean_ob_frac::Float64 = CFG_ocean_ob_frac,
576+
ocean_cs_height::Float64 = CFG_ocean_cs_height
531577
)::Bool
532578

533579
# Say hello
@@ -691,7 +737,7 @@ module atmosphere
691737
atmos.κ_grey_sw = κ_grey_sw
692738
_check_range("Grey SW opacity", atmos.κ_grey_sw; min=0) || return false
693739

694-
atmos.Kzz_pbreak = 1e5 # 1 bar as default location for break point
740+
atmos.Kzz_pbreak = max(1.0, Kzz_pbreak)
695741
atmos.Kzz_kbreak = max(0.0, Kzz_kbreak)
696742
atmos.Kzz_power = -0.4
697743
atmos.Kzz_type = Kzz_type
@@ -750,7 +796,7 @@ module atmosphere
750796
# absorption contributors
751797
atmos.control.l_gas::Bool = true
752798
atmos.control.l_rayleigh::Bool = flag_rayleigh
753-
atmos.control.l_continuum::Bool = flag_continuum
799+
atmos.control.l_continuum::Bool = false # legacy
754800
atmos.control.l_cont_gen::Bool = flag_gcontinuum
755801
atmos.control.l_aerosol::Bool = flag_aerosol
756802
atmos.control.l_cloud::Bool = flag_cloud
@@ -801,7 +847,7 @@ module atmosphere
801847
atmos.evap_efficiency = evap_efficiency
802848
_check_range("Evaporation efficiency", atmos.evap_efficiency; min=0, max=1) || return false
803849

804-
# Hardcoded cloud properties
850+
# Hardcoded default cloud properties
805851
atmos.cloud_alpha = 0.01 # [INPUT] 1% of condensed water forms substantial clouds
806852
atmos.cloud_val_r = 1.0e-5 # [INPUT] 10 micron droplets
807853
atmos.cloud_val_l = 0.8 # [INPUT] Mass mixing ratio of water in each layer
@@ -1103,7 +1149,7 @@ module atmosphere
11031149

11041150
# Set initial temperature profile to a small value which still keeps
11051151
# all of the gases supercritical. This should be a safe condition to
1106-
# default to, although the user must specify a profile in the cfg.
1152+
# default to, although the user must specify a profile in the CFG_
11071153
for g in atmos.gas_names
11081154
atmos.tmpl[end] = clamp(atmos.tmpl[end], atmos.gas_dat[g].T_crit+5.0, T_INI_MAX)
11091155
fill!(atmos.tmpl, atmos.tmpl[end])

0 commit comments

Comments
 (0)