Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard code pottemp methods to eos and remove entropy option #70

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/EDMF_Environment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function saturation_adjustment(self::EnvironmentThermodynamics, EnvVar::Environm
mph = mph_struct()

@inbounds for k in real_center_indicies(self.Gr)
sa = eos(self.t_to_prog_fp, self.prog_to_t_fp, self.Ref.p0_half[k], EnvVar.QT.values[k], EnvVar.H.values[k])
sa = eos(self.Ref.p0_half[k], EnvVar.QT.values[k], EnvVar.H.values[k])

EnvVar.T.values[k] = sa.T
EnvVar.QL.values[k] = sa.ql
Expand Down Expand Up @@ -184,7 +184,7 @@ function sgs_mean(self::EnvironmentThermodynamics, EnvVar::EnvironmentVariables,

@inbounds for k in real_center_indicies(self.Gr)
# condensation
sa = eos(self.t_to_prog_fp, self.prog_to_t_fp, self.Ref.p0_half[k], EnvVar.QT.values[k], EnvVar.H.values[k])
sa = eos(self.Ref.p0_half[k], EnvVar.QT.values[k], EnvVar.H.values[k])
# autoconversion and accretion
mph = microphysics_rain_src(
Rain.rain_model,
Expand Down Expand Up @@ -325,7 +325,7 @@ function sgs_quadrature(self::EnvironmentThermodynamics, EnvVar::EnvironmentVari
end

# condensation
sa = eos(self.t_to_prog_fp, self.prog_to_t_fp, self.Ref.p0_half[k], qt_hat, h_hat)
sa = eos(self.Ref.p0_half[k], qt_hat, h_hat)
# autoconversion and accretion
mph = microphysics_rain_src(
Rain.rain_model,
Expand Down Expand Up @@ -411,7 +411,7 @@ function sgs_quadrature(self::EnvironmentThermodynamics, EnvVar::EnvironmentVari

else
# if variance and covariance are zero do the same as in SA_mean
sa = eos(self.t_to_prog_fp, self.prog_to_t_fp, self.Ref.p0_half[k], EnvVar.QT.values[k], EnvVar.H.values[k])
sa = eos(self.Ref.p0_half[k], EnvVar.QT.values[k], EnvVar.H.values[k])
mph = microphysics_rain_src(
Rain.rain_model,
Rain.max_supersaturation,
Expand Down
4 changes: 1 addition & 3 deletions src/EDMF_Updrafts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ function initialize_DryBubble(self::UpdraftVariables, GMV::GridMeanVariables, Re
# for now temperature is provided as diagnostics from LES

# sa = eos(
# t_to_thetali_c,
# eos_first_guess_thetal,
# Ref.p0_half[k],
# self.QT.values[i,k],
# self.H.values[i,k]
Expand Down Expand Up @@ -439,7 +437,7 @@ function buoyancy(
elseif UpdVar.Area.values[i, k - 1] > 0.0 && k > self.Gr.gw
# TODO: report bug:
# qt and h were not defined here before the function call.
sa = eos(self.t_to_prog_fp, self.prog_to_t_fp, self.Ref.p0_half[k], qt, h)
sa = eos(self.Ref.p0_half[k], qt, h)
qt -= sa.ql
qv = qt
t = sa.T
Expand Down
6 changes: 3 additions & 3 deletions src/ReferenceState.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function initialize(self::ReferenceState, Gr::Grid, Stats::NetCDFIO_Stats)
# determine the reference pressure

function rhs(p, u, z)
ret = eos(t_to_entropy_c, eos_first_guess_entropy, exp(p), self.qtg, self.sg)
ret = eos(exp(p), self.qtg, self.sg; t_to_prog = t_to_entropy_c, prog_to_t = eos_first_guess_entropy)
q_i = 0.0
q_l = ret.ql
T = ret.T
Expand Down Expand Up @@ -109,15 +109,15 @@ function initialize(self::ReferenceState, Gr::Grid, Stats::NetCDFIO_Stats)
# Compute reference state thermodynamic profiles

@inbounds for k in center_indicies(Gr)
ret = eos(t_to_entropy_c, eos_first_guess_entropy, p_half_[k], self.qtg, self.sg)
ret = eos(p_half_[k], self.qtg, self.sg; t_to_prog = t_to_entropy_c, prog_to_t = eos_first_guess_entropy)
temperature_half[k] = ret.T
ql_half[k] = ret.ql
qv_half[k] = self.qtg - (ql_half[k] + qi_half[k])
alpha_half[k] = alpha_c(p_half_[k], temperature_half[k], self.qtg, qv_half[k])
end

@inbounds for k in face_indicies(Gr)
ret = eos(t_to_entropy_c, eos_first_guess_entropy, p_[k], self.qtg, self.sg)
ret = eos(p_[k], self.qtg, self.sg; t_to_prog = t_to_entropy_c, prog_to_t = eos_first_guess_entropy)
temperature[k] = ret.T
ql[k] = ret.ql
qv[k] = self.qtg - (ql[k] + qi[k])
Expand Down
16 changes: 2 additions & 14 deletions src/Turbulence_PrognosticTKE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1372,13 +1372,7 @@ function solve_updraft_scalars(self::EDMF_PrognosticTKE, GMV::GridMeanVariables)
end

# saturation adjustment
sa = eos(
self.UpdThermo.t_to_prog_fp,
self.UpdThermo.prog_to_t_fp,
ref_state.p0_half[k],
self.UpdVar.QT.new[i, k],
self.UpdVar.H.new[i, k],
)
sa = eos(ref_state.p0_half[k], self.UpdVar.QT.new[i, k], self.UpdVar.H.new[i, k])
self.UpdVar.QL.new[i, k] = sa.ql
self.UpdVar.T.new[i, k] = sa.T
continue
Expand Down Expand Up @@ -1427,13 +1421,7 @@ function solve_updraft_scalars(self::EDMF_PrognosticTKE, GMV::GridMeanVariables)
end

# saturation adjustment
sa = eos(
self.UpdThermo.t_to_prog_fp,
self.UpdThermo.prog_to_t_fp,
ref_state.p0_half[k],
self.UpdVar.QT.new[i, k],
self.UpdVar.H.new[i, k],
)
sa = eos(ref_state.p0_half[k], self.UpdVar.QT.new[i, k], self.UpdVar.H.new[i, k])
self.UpdVar.QL.new[i, k] = sa.ql
self.UpdVar.T.new[i, k] = sa.T
end
Expand Down
2 changes: 1 addition & 1 deletion src/Variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function satadjust(self::GridMeanVariables)
h = self.H.values[k]
qt = self.QT.values[k]
p0 = self.Ref.p0_half[k]
sa = eos(self.t_to_prog_fp, self.prog_to_t_fp, p0, qt, h)
sa = eos(p0, qt, h)
self.QL.values[k] = sa.ql
self.T.values[k] = sa.T
qv = qt - sa.ql
Expand Down
2 changes: 1 addition & 1 deletion src/thermodynamic_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function eos_first_guess_entropy(H, pd, pv, qt)
)
end

function eos(t_to_prog, prog_to_t, p0, qt, prog)
function eos(p0, qt, prog; t_to_prog = t_to_thetali_c, prog_to_t = eos_first_guess_thetal)
qv = qt
ql = 0.0

Expand Down
28 changes: 1 addition & 27 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ Base.@kwdef mutable struct GridMeanVariables{PS}
QT::VariablePrognostic
RH::VariablePrognostic
H::VariablePrognostic
t_to_prog_fp::Function
prog_to_t_fp::Function
QL::VariableDiagnostic
T::VariableDiagnostic
B::VariableDiagnostic
Expand Down Expand Up @@ -420,8 +418,6 @@ function GridMeanVariables(namelist, Gr::Grid, Ref::ReferenceState, param_set::P
RH = VariablePrognostic(Gr, "half", "scalar", "sym", "RH", "%")

H = VariablePrognostic(Gr, "half", "scalar", "sym", "thetal", "K")
t_to_prog_fp = t_to_thetali_c
prog_to_t_fp = eos_first_guess_thetal

# Diagnostic Variables--same class as the prognostic variables, but we append to diagnostics list
QL = VariableDiagnostic(Gr, "half", "scalar", "sym", "ql", "kg/kg")
Expand Down Expand Up @@ -478,8 +474,6 @@ function GridMeanVariables(namelist, Gr::Grid, Ref::ReferenceState, param_set::P
QT,
RH,
H,
t_to_prog_fp,
prog_to_t_fp,
QL,
T,
B,
Expand All @@ -503,8 +497,6 @@ struct UpdraftThermodynamics{A1, A2}
Gr::Grid
Ref::ReferenceState
n_updraft::Int
t_to_prog_fp::Function
prog_to_t_fp::Function
prec_source_h::A2
prec_source_qt::A2
prec_source_h_tot::A1
Expand All @@ -516,8 +508,6 @@ struct UpdraftThermodynamics{A1, A2}
UpdVar::UpdraftVariables,
Rain::RainVariables,
)
t_to_prog_fp = t_to_thetali_c
prog_to_t_fp = eos_first_guess_thetal

# rain source from each updraft from all sub-timesteps
prec_source_h = center_field(Gr, n_updraft)
Expand All @@ -528,17 +518,7 @@ struct UpdraftThermodynamics{A1, A2}
prec_source_qt_tot = center_field(Gr)
A1 = typeof(prec_source_h_tot)
A2 = typeof(prec_source_h)
return new{A1, A2}(
Gr,
Ref,
n_updraft,
t_to_prog_fp,
prog_to_t_fp,
prec_source_h,
prec_source_qt,
prec_source_h_tot,
prec_source_qt_tot,
)
return new{A1, A2}(Gr, Ref, n_updraft, prec_source_h, prec_source_qt, prec_source_h_tot, prec_source_qt_tot)
end

end
Expand Down Expand Up @@ -708,8 +688,6 @@ struct EnvironmentThermodynamics{A1}
Ref::ReferenceState
quadrature_order::Int
quadrature_type::String
t_to_prog_fp::Function
prog_to_t_fp::Function
qt_dry::A1
th_dry::A1
t_cloudy::A1
Expand Down Expand Up @@ -738,8 +716,6 @@ struct EnvironmentThermodynamics{A1}
catch
"gaussian"
end
t_to_prog_fp = t_to_thetali_c
prog_to_t_fp = eos_first_guess_thetal

qt_dry = center_field(Gr)
th_dry = center_field(Gr)
Expand All @@ -761,8 +737,6 @@ struct EnvironmentThermodynamics{A1}
Ref,
quadrature_order,
quadrature_type,
t_to_prog_fp,
prog_to_t_fp,
qt_dry,
th_dry,
t_cloudy,
Expand Down