-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from nichollsh/eos
Groundwork for reading AQUA equation of state
- Loading branch information
Showing
8 changed files
with
882 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# AGNI configuration file | ||
title = "L 98-59 d" | ||
|
||
[planet] | ||
tmp_surf = 2700.0 | ||
instellation = 81690.0 | ||
albedo_b = 0.0 | ||
s0_fact = 0.25 | ||
zenith_angle = 54.74 | ||
surface_material= "res/surface_albedos/lunar_marebasalt.dat" | ||
radius = 6.59051e6 | ||
gravity = 16.73 | ||
tmp_int = 0.0 | ||
turb_coeff = 0.001 | ||
wind_speed = 2.0 | ||
|
||
[files] | ||
input_sf = "res/spectral_files/Honeyside/256/Honeyside.sf" | ||
input_star = "res/stellar_spectra/l-98-59.txt" | ||
output_dir = "out/" | ||
|
||
[composition] | ||
p_top = 1e-6 | ||
p_surf = 215.82518354535077e3 | ||
vmr_dict = {H2S= 0.23988329190194904, SO2= 0.0044668359215096305, N2= 5.623413251903491e-6, H2= 0.7093907341517219} | ||
include_all = true | ||
chemistry = 1 | ||
condensates = [] | ||
|
||
[execution] | ||
clean_output = true | ||
verbosity = 1 | ||
max_steps = 20000 | ||
max_runtime = 400 | ||
num_levels = 60 | ||
continua = true | ||
rayleigh = true | ||
cloud = false | ||
aerosol = false | ||
overlap_method = 4 | ||
thermo_funct = true | ||
sensible_heat = false | ||
latent_heat = true | ||
convection = true | ||
solution_type = 3 | ||
solvers = ["newton"] | ||
dx_max = 400.0 | ||
initial_state = ["loglin", "700"] | ||
linesearch = 0 | ||
easy_start = false | ||
converge_atol = 1.0e-2 | ||
converge_rtol = 1.0e-3 | ||
|
||
[plots] | ||
at_runtime = true | ||
temperature = true | ||
fluxes = true | ||
contribution = true | ||
emission = true | ||
albedo = true | ||
mixing_ratios = true | ||
animate = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Contains routines for loading and working with real-gas equations of state | ||
|
||
# Not for direct execution | ||
if (abspath(PROGRAM_FILE) == @__FILE__) | ||
thisfile = @__FILE__ | ||
error("The file '$thisfile' is not for direct execution") | ||
end | ||
|
||
module realgas | ||
|
||
import ..phys | ||
|
||
using ScatteredInterpolation # 2D interpolation | ||
using LoggingExtras | ||
using DelimitedFiles | ||
|
||
mutable struct Aqua_t | ||
|
||
# Axis | ||
npts_t::Int | ||
npts_p::Int | ||
|
||
# Array limits | ||
lim_prs::Array{Float64} | ||
lim_tmp::Array{Float64} | ||
|
||
# Interpolators | ||
itp_rho # Interpolator for density [kg/m^3] | ||
itp_gad # Interpolator for adiabatic gradient (dlog(T)/dlog(P))_S | ||
itp_mmw # Interpolator for mmw [kg/mol] | ||
|
||
# Struct | ||
Aqua_t() = new() | ||
end | ||
|
||
function read_aqua(fpath::String)::Aqua_t | ||
|
||
# Read the file | ||
@debug "Reading AQUA table at '$fpath'" | ||
data::Array{Float64,2} = readdlm(fpath, Float64; header=false, skipstart=19) | ||
|
||
# Parse the columns | ||
# input | ||
arr_prs::Array{Float64} = data[:,1] | ||
arr_tmp::Array{Float64} = data[:,2] | ||
# output | ||
arr_rho::Array{Float64} = data[:,3] | ||
arr_gad::Array{Float64} = data[:,4] | ||
arr_mmw::Array{Float64} = data[:,8] | ||
|
||
# Create struct | ||
aqua = Aqua_t() | ||
|
||
# Dimensions are hardcoded inside the file | ||
aqua.npts_p = 1093 | ||
aqua.npts_t = 301 | ||
|
||
# Check dimensions vs data | ||
if length(arr_prs) != aqua.npts_p*aqua.npts_t | ||
@error "AQUA lookup table has invalid dimensions" | ||
end | ||
|
||
# Limits | ||
aqua.lim_prs = [minimum(arr_prs), maximum(arr_prs)] | ||
aqua.lim_tmp = [minimum(arr_tmp), maximum(arr_tmp)] | ||
|
||
# Create interpolators | ||
eval_pts = vcat(arr_prs', arr_tmp') | ||
aqua.itp_rho = interpolate(NearestNeighbor(), eval_pts, arr_rho) | ||
aqua.itp_gad = interpolate(NearestNeighbor(), eval_pts, arr_gad) | ||
aqua.itp_mmw = interpolate(NearestNeighbor(), eval_pts, arr_mmw) | ||
|
||
return aqua | ||
end | ||
|
||
# Evaluate density from temperature and pressure | ||
function eval_aqua_rho(aqua::Aqua_t, prs::Float64, tmp::Float64)::Float64 | ||
prs = max(min(prs, aqua.lim_prs[2]), aqua.lim_prs[1]) | ||
tmp = max(min(tmp, aqua.lim_tmp[2]), aqua.lim_tmp[1]) | ||
return aqua.itp_rho(tmp,prs) | ||
end | ||
|
||
end |