Skip to content

Commit

Permalink
Merge pull request #61 from nichollsh/cond
Browse files Browse the repository at this point in the history
Minor quality of life changes
  • Loading branch information
nichollsh authored Jul 19, 2024
2 parents b00a124 + 81d0863 commit 31f9702
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 183 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
given-names: "Harrison"
orcid: "https://orcid.org/0000-0002-8368-4641"
title: "AGNI"
version: 0.6.0
version: 0.6.1
doi: 10.xx/xx.xx
date-released: 2024-07-17
date-released: 2024-07-18
url: "https://github.com/nichollsh/AGNI"
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AGNI"
uuid = "ede838c1-9ec3-4ebe-8ae8-da4091b3f21c"
authors = ["Harrison Nicholls <[email protected]>"]
version = "0.6.0"
version = "0.6.1"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
118 changes: 67 additions & 51 deletions get_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Download and unpack required and/or optional data
# All files can be found on OSF at https://osf.io/8dumn/

# Exit script if any of the commands fail
set -e

# Check that curl is installed
if ! [ -x "$(command -v curl)" ]; then
echo 'ERROR: curl is not installed.' >&2
Expand Down Expand Up @@ -47,64 +50,77 @@ function osf {

# target file path
tgt="$2/$3"
rm -f $tgt
echo " $1 > $tgt"

# exists?
if [[ -f "$tgt" ]]; then
echo " $1 > file already exists"
return 0
fi

# get data
echo " $1 > $tgt"
mkdir -p $2
curl -LsS "https://osf.io/download/$1/" > $tgt
}

# Handle user input
case $1 in
"basic")
echo $help_basic

osf qmp4e $res/spectral_files/Oak/318/ Oak.sf
osf 5fxr7 $res/spectral_files/Oak/318/ Oak.sf_k

osf heuza $res/spectral_files/Dayspring/48/ Dayspring.sf
osf c5jv3 $res/spectral_files/Dayspring/48/ Dayspring.sf_k

osf b5gsh $res/spectral_files/Dayspring/256/ Dayspring.sf
osf dn6wh $res/spectral_files/Dayspring/256/ Dayspring.sf_k

osf 2qdu8 $res/stellar_spectra sun.txt
;;

"highres")
echo $help_highres

osf p672d $res/spectral_files/Honeyside/4096/ Honeyside.sf
osf ujb4z $res/spectral_files/Honeyside/4096/ Honeyside.sf_k
;;

"steam")
echo $help_steam

osf 6rvfe $res/spectral_files/Frostflow/16/ Frostflow.sf
osf kxve8 $res/spectral_files/Frostflow/16/ Frostflow.sf_k

osf 9n6mw $res/spectral_files/Frostflow/48/ Frostflow.sf
osf xfap8 $res/spectral_files/Frostflow/48/ Frostflow.sf_k

osf mnvyq $res/spectral_files/Frostflow/256/ Frostflow.sf
osf tzsgc $res/spectral_files/Frostflow/256/ Frostflow.sf_k
;;
return 0
}

"stellar")
echo $help_stellar
osf mabp2 $res/stellar_spectra trappist-1.txt
osf rk7mj $res/stellar_spectra eps-eri.txt
osf agsrq $res/stellar_spectra hd97658.txt
osf ehfsy $res/stellar_spectra gj1214.txt
;;
# Handle request for downloading a group of data
function handle_request {
case $1 in
"basic")
echo $help_basic

osf qmp4e $res/spectral_files/Oak/318/ Oak.sf
osf 5fxr7 $res/spectral_files/Oak/318/ Oak.sf_k

osf heuza $res/spectral_files/Dayspring/48/ Dayspring.sf
osf c5jv3 $res/spectral_files/Dayspring/48/ Dayspring.sf_k

osf b5gsh $res/spectral_files/Dayspring/256/ Dayspring.sf
osf dn6wh $res/spectral_files/Dayspring/256/ Dayspring.sf_k

osf 2qdu8 $res/stellar_spectra sun.txt
;;

"highres")
echo $help_highres

osf p672d $res/spectral_files/Honeyside/4096/ Honeyside.sf
osf ujb4z $res/spectral_files/Honeyside/4096/ Honeyside.sf_k
;;

"steam")
echo $help_steam

osf 6rvfe $res/spectral_files/Frostflow/16/ Frostflow.sf
osf kxve8 $res/spectral_files/Frostflow/16/ Frostflow.sf_k

osf 9n6mw $res/spectral_files/Frostflow/48/ Frostflow.sf
osf xfap8 $res/spectral_files/Frostflow/48/ Frostflow.sf_k

osf mnvyq $res/spectral_files/Frostflow/256/ Frostflow.sf
osf tzsgc $res/spectral_files/Frostflow/256/ Frostflow.sf_k
;;

"stellar")
echo $help_stellar
osf mabp2 $res/stellar_spectra trappist-1.txt
osf rk7mj $res/stellar_spectra eps-eri.txt
osf agsrq $res/stellar_spectra hd97658.txt
osf ehfsy $res/stellar_spectra gj1214.txt
osf 2qdu8 $res/stellar_spectra sun.txt
;;

*)
echo "$help"
return 0
;;
esac
return 0
}

*)
echo "$help"
exit 1
;;
esac
handle_request $1

echo "Done!"

Expand Down
5 changes: 3 additions & 2 deletions res/config/55cnce_chem.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ title = "Roughly 55 Cancri e @ fO2=IW"
thermo_funct = true
sensible_heat = false
latent_heat = true
convection_type = "mlt"
convection = true
solution_type = 3
solvers = ["newton"]
dx_max = 400.0
initial_state = ["iso", "2700"]
linesearch = false
linesearch = false
easy_start = false
converge_atol = 1.0e-2
converge_rtol = 1.0e-3

Expand Down
7 changes: 4 additions & 3 deletions res/config/condense.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ title = "Condensation test"
verbosity = 1
max_steps = 300
max_runtime = 400
num_levels = 38
num_levels = 35
continua = true
rayleigh = false
cloud = false
Expand All @@ -45,12 +45,13 @@ title = "Condensation test"
thermo_funct = true
sensible_heat = true
latent_heat = true
convection_type = "mlt"
convection = true
solution_type = 3
solvers = ["newton"]
dx_max = 500.0
initial_state = ["loglin","600"]
linesearch = true
linesearch = true
easy_start = true
converge_atol = 0.1
converge_rtol = 1.0e-3

Expand Down
3 changes: 2 additions & 1 deletion res/config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ title = "Default" # Name for this configuration file
thermo_funct = false # Use temperature-dependent thermodynamic properties?
sensible_heat = false # Include sensible heat transport at the surface?
latent_heat = false # Include heat release from phase change
convection_type = "" # Convection type (mlt = use mixing length theory).
convection = true # Include heat transport by convection
solution_type = 0 # Solution type (see wiki).
solvers = [] # Ordered list of solvers to apply (see wiki).
dx_max = 200.0 # Maximum step size [Kelvin], when using nonlinear solvers
initial_state = ["dry", "sat", "H2O"] # Ordered list of requests describing the initial state of the atmosphere (see wiki).
linesearch = false # Use linesearch?
easy_start = false # Initially down-scale convective/condensation fluxes, if initial guess is poor.
converge_atol = 1.0e-3 # Convergence criterion on absolute flux divergence [W m-2].
converge_rtol = 1.0e-1 # Convergence criterion on relative flux divergence [dimensionless].

Expand Down
5 changes: 3 additions & 2 deletions res/config/hotdry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ title = "Hot and dry"
thermo_funct = true
sensible_heat = true
latent_heat = false
convection_type = "mlt"
convection = true
solution_type = 3
solvers = ["newton"]
dx_max = 400.0
initial_state = ["iso","2300"]
linesearch = false
linesearch = false
easy_start = false
converge_atol = 1.0e-2
converge_rtol = 1.0e-4

Expand Down
12 changes: 6 additions & 6 deletions src/AGNI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,15 @@ module AGNI
flag_aer::Bool = cfg["execution" ]["aerosol"]
overlap::Int = cfg["execution" ]["overlap_method"]
thermo_funct::Bool = cfg["execution" ]["thermo_funct"]
conv_type::String = cfg["execution" ]["convection_type"]
incl_convect::Bool = cfg["execution" ]["convection"]
incl_sens::Bool = cfg["execution" ]["sensible_heat"]
incl_latent::Bool = cfg["execution" ]["latent_heat"]
sol_type::Int = cfg["execution" ]["solution_type"]
solvers_cmd::Array{String,1} = cfg["execution" ]["solvers"]
initial_req::Array{String,1} = cfg["execution" ]["initial_state"]
dx_max::Float64 = cfg["execution" ]["dx_max"]
linesearch::Bool = cfg["execution" ]["linesearch"]
easy_start::Bool = cfg["execution" ]["easy_start"]
conv_atol::Float64 = cfg["execution" ]["converge_atol"]
conv_rtol::Float64 = cfg["execution" ]["converge_rtol"]
max_steps::Int = cfg["execution" ]["max_steps"]
Expand Down Expand Up @@ -455,8 +456,6 @@ module AGNI
end

# Solver variables
incl_convect::Bool= !isempty(conv_type)
use_mlt::Bool = (conv_type == "mlt")
modplot::Int = 0
incl_conduct::Bool = false

Expand Down Expand Up @@ -498,9 +497,10 @@ module AGNI
convect=incl_convect, latent=incl_latent,
sens_heat=incl_sens, max_steps=max_steps,
max_runtime=max_runtime,
conv_atol=conv_atol,
conv_rtol=conv_rtol, method=method_idx,
conv_atol=conv_atol, conv_rtol=conv_rtol,
method=method_idx,
dx_max=dx_max, linesearch=linesearch,
easy_start=easy_start,
modplot=modplot,save_frames=plt_ani)
return_success = return_success && solver_success

Expand Down Expand Up @@ -529,7 +529,7 @@ module AGNI
plt_vmr && plotting.plot_vmr(atmos, joinpath(atmos.OUT_DIR,"plot_vmrs.png"), size_x=600)
plt_cff && plotting.plot_contfunc(atmos, joinpath(atmos.OUT_DIR,"plot_contfunc.png"))
plt_tmp && plotting.plot_pt(atmos, joinpath(atmos.OUT_DIR,"plot_ptprofile.png"), incl_magma=(sol_type==2))
plt_flx && plotting.plot_fluxes(atmos, joinpath(atmos.OUT_DIR,"plot_fluxes.png"), incl_mlt=use_mlt, incl_eff=(sol_type==3), incl_cdct=incl_conduct, incl_latent=incl_latent)
plt_flx && plotting.plot_fluxes(atmos, joinpath(atmos.OUT_DIR,"plot_fluxes.png"), incl_mlt=incl_convect, incl_eff=(sol_type==3), incl_cdct=incl_conduct, incl_latent=incl_latent)
plt_ems && plotting.plot_emission(atmos, joinpath(atmos.OUT_DIR,"plot_emission.png"))
plt_alb && plotting.plot_albedo(atmos, joinpath(atmos.OUT_DIR,"plot_albedo.png"))

Expand Down
16 changes: 13 additions & 3 deletions src/atmosphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ module atmosphere
# Conduction
flux_cdct::Array{Float64,1} # Conductive flux [W m-2]

# Phase change
# Phase change
phs_tau_mix::Float64 # Time scale (mixed composition)
phs_tau_sgl::Float64 # Time scale (single gas)
phs_wrk_df::Array{Float64,1} # work array: flux difference
phs_wrk_fl::Array{Float64,1} # work array: edge fluxes
flux_l::Array{Float64, 1} # Latent heat energy flux [W m-2]
mask_l::Array{Bool,1} # Layers transporting latent heat

Expand Down Expand Up @@ -310,7 +314,7 @@ module atmosphere
end

# Code versions
atmos.AGNI_VERSION = "0.6.0"
atmos.AGNI_VERSION = "0.6.1"
atmos.SOCRATES_VERSION = readchomp(joinpath(ENV["RAD_DIR"],"version"))
@debug "AGNI VERSION = $(atmos.AGNI_VERSION)"
@debug "Using SOCRATES at $(ENV["RAD_DIR"])"
Expand Down Expand Up @@ -416,6 +420,10 @@ module atmosphere
atmos.cloud_arr_l = zeros(Float64, atmos.nlev_c)
atmos.cloud_arr_f = zeros(Float64, atmos.nlev_c)

# Phase change timescales [seconds]
atmos.phs_tau_mix = 1.0e4 # mixed composition case
atmos.phs_tau_sgl = 1.0e4 # single gas case

# Hardcoded cloud properties
atmos.cond_alpha = 0.0 # 0% of condensate is retained (i.e. complete rainout)
atmos.cloud_val_r = 1.0e-5 # 10 micron droplets
Expand Down Expand Up @@ -1347,10 +1355,12 @@ module atmosphere
atmos.mask_l = falses(atmos.nlev_l) # Phase change
atmos.mask_c = falses(atmos.nlev_l) # Dry convection

atmos.phs_wrk_df = zeros(Float64, atmos.nlev_c) # flux difference
atmos.phs_wrk_fl = zeros(Float64, atmos.nlev_l) # edge fluxes
atmos.flux_l = zeros(Float64, atmos.nlev_l) # Latent heat / phase change
atmos.flux_cdry = zeros(Float64, atmos.nlev_l) # Dry convection
atmos.flux_cdct = zeros(Float64, atmos.nlev_l) # Conduction
atmos.Kzz = zeros(Float64, atmos.nlev_l)
atmos.Kzz = zeros(Float64, atmos.nlev_l) # eddy diffusion coeff.

atmos.flux_tot = zeros(Float64, atmos.nlev_l)
atmos.flux_dif = zeros(Float64, atmos.nlev_c)
Expand Down
7 changes: 4 additions & 3 deletions src/dump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ module dump
# into PROTEUS without compatibility issues.

# Absorb output from these calls, because they spam the Debug logger
@debug "ALL OUTPUT SUPPRESSED"
with_logger(NullLogger()) do
@debug "ALL DEBUG SUPPRESSED"
with_logger(MinLevelLogger(current_logger(), Logging.Info-200)) do

ds = Dataset(fname,"c")

Expand Down Expand Up @@ -327,8 +327,9 @@ module dump
var_albs[:] = atmos.albedo_s_arr

close(ds)

end # suppress output
@debug "ALL OUTPUT RESTORED"
@debug "ALL DEBUG RESTORED"

return nothing
end # end write_ncdf
Expand Down
Loading

0 comments on commit 31f9702

Please sign in to comment.