Skip to content

Commit aab16a0

Browse files
committed
add 2M diagnostics
1 parent 1b666dc commit aab16a0

File tree

4 files changed

+152
-7
lines changed

4 files changed

+152
-7
lines changed

src/diagnostics/core_diagnostics.jl

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,130 @@ add_diagnostic_variable!(
866866
compute! = compute_hussn!,
867867
)
868868

869+
compute_clwnm!(out, state, cache, time) =
870+
compute_clwnm!(out, state, cache, time, cache.atmos.precip_model)
871+
compute_clwnm!(_, _, _, _, model::T) where {T} =
872+
error_diagnostic_variable("clwnm", model)
873+
874+
function compute_clwnm!(
875+
out,
876+
state,
877+
cache,
878+
time,
879+
precip_model::Microphysics2Moment,
880+
)
881+
if isnothing(out)
882+
return state.c.ρn_liq
883+
else
884+
out .= state.c.ρn_liq
885+
end
886+
end
887+
888+
add_diagnostic_variable!(
889+
short_name = "clwnm",
890+
long_name = "Number Concentration of Cloud Liquid Water",
891+
standard_name = "number_concentration_of_cloud_liquid_water",
892+
units = "1 m^3",
893+
comments = """
894+
This is calculated as the number of cloud liquid water droplets in the grid
895+
cell divided by the cell volume.
896+
""",
897+
compute! = compute_clwnm!,
898+
)
899+
900+
compute_clinm!(out, state, cache, time) =
901+
compute_clinm!(out, state, cache, time, cache.atmos.precip_model)
902+
compute_clinm!(_, _, _, _, model::T) where {T} =
903+
error_diagnostic_variable("clinm", model)
904+
905+
function compute_clwnm!(
906+
out,
907+
state,
908+
cache,
909+
time,
910+
precip_model::Microphysics2Moment,
911+
)
912+
if isnothing(out)
913+
return state.c.ρn_ice
914+
else
915+
out .= state.c.ρn_ice
916+
end
917+
end
918+
919+
add_diagnostic_variable!(
920+
short_name = "clinm",
921+
long_name = "Number Concentration of Cloud Ice",
922+
standard_name = "number_concentration_of_cloud_ice",
923+
units = "1 m^3",
924+
comments = """
925+
This is calculated as the number of cloud ice chrystals in the grid
926+
cell divided by the cell volume.
927+
""",
928+
compute! = compute_clinm!,
929+
)
930+
931+
compute_nmra!(out, state, cache, time) =
932+
compute_nmra!(out, state, cache, time, cache.atmos.precip_model)
933+
compute_nmra!(_, _, _, _, model::T) where {T} =
934+
error_diagnostic_variable("nmra", model)
935+
936+
function compute_nmra!(
937+
out,
938+
state,
939+
cache,
940+
time,
941+
precip_model::Microphysics2Moment,
942+
)
943+
if isnothing(out)
944+
return state.c.ρn_rai
945+
else
946+
out .= state.c.ρn_rai
947+
end
948+
end
949+
950+
add_diagnostic_variable!(
951+
short_name = "nmra",
952+
long_name = "Number Concentration of Rain",
953+
standard_name = "number_concentration_of_rain",
954+
units = "1 m^3",
955+
comments = """
956+
This is calculated as the number of raindrops in the grid cell divided
957+
by the cell volume.
958+
""",
959+
compute! = compute_nmra!,
960+
)
961+
962+
compute_nmsn!(out, state, cache, time) =
963+
compute_nmsn!(out, state, cache, time, cache.atmos.precip_model)
964+
compute_nmsn!(_, _, _, _, model::T) where {T} =
965+
error_diagnostic_variable("nmsn", model)
966+
967+
function compute_nmsn!(
968+
out,
969+
state,
970+
cache,
971+
time,
972+
precip_model::Microphysics2Moment,
973+
)
974+
if isnothing(out)
975+
return state.c.ρn_sno
976+
else
977+
out .= state.c.ρn_sno
978+
end
979+
end
980+
981+
add_diagnostic_variable!(
982+
short_name = "nmsn",
983+
long_name = "Number Concentration of Snow",
984+
standard_name = "number_concentration_of_snow",
985+
units = "1 m^3",
986+
comments = """
987+
This is calculated as the number of snow flakes in the grid cell divided
988+
by the cell volume.
989+
""",
990+
compute! = compute_nmsn!,
991+
)
992+
869993
###
870994
# Topography
871995
###

src/diagnostics/default_diagnostics.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,19 @@ function default_diagnostics(
230230
return [average_func(precip_diagnostics...; output_writer, start_date)...]
231231
end
232232

233+
function default_diagnostics(
234+
::Microphysics2Moment,
235+
duration,
236+
start_date;
237+
output_writer,
238+
)
239+
precip_diagnostics = ["husra", "hussn", "clwnm", "clinm", "nmra", "nmsn"]
240+
241+
average_func = frequency_averages(duration)
242+
243+
return [average_func(precip_diagnostics...; output_writer, start_date)...]
244+
end
245+
233246
##################
234247
# Radiation mode #
235248
##################

src/initial_conditions/initial_conditions.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,9 +1200,13 @@ function (initial_condition::PrecipitatingColumn)(params)
12001200
thermo_params = CAP.thermodynamics_params(params)
12011201
p_0 = FT(101300.0)
12021202
qᵣ = prescribed_prof(FT, 2000, 5000, 1e-6)
1203+
nᵣ = prescribed_prof(FT, 2000, 5000, 1e3)
12031204
qₛ = prescribed_prof(FT, 5000, 8000, 2e-6)
1205+
nₛ = prescribed_prof(FT, 5000, 8000, 1e3)
12041206
qₗ = prescribed_prof(FT, 4000, 5500, 2e-5)
1207+
nₗ = prescribed_prof(FT, 4000, 5500, 1e7)
12051208
qᵢ = prescribed_prof(FT, 6000, 9000, 1e-5)
1209+
nᵢ = prescribed_prof(FT, 6000, 9000, 1e6)
12061210
θ = APL.Rico_θ_liq_ice(FT)
12071211
q_tot = APL.Rico_q_tot(FT)
12081212
u = prescribed_prof(FT, 0, Inf, 0)
@@ -1222,7 +1226,7 @@ function (initial_condition::PrecipitatingColumn)(params)
12221226
thermo_state = ts,
12231227
velocity = Geometry.UVVector(u(z), v(z)),
12241228
turbconv_state = nothing,
1225-
precip_state = PrecipState1M(; q_rai = qᵣ(z), q_sno = qₛ(z)),
1229+
precip_state = PrecipState2M(; q_rai = qᵣ(z), q_sno = qₛ(z), n_liq = nₗ(z), n_ice = nᵢ(z), n_rai = nᵣ(z), n_sno = nₛ(z)),
12261230
)
12271231
end
12281232
return local_state

src/initial_conditions/local_state.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,18 @@ struct NoPrecipState{FT} <: PrecipState{FT} end
102102
@inline Base.getproperty(::NoPrecipState{FT}, ::Symbol) where {FT} = FT(0)
103103

104104
"""
105-
PrecipState1M(; q_rai, q_sno)
105+
PrecipState2M(; q_rai, q_sno)
106106
107-
Stores the values of `ρq_rai` and `ρq_sno` for the `precip_model`.
108-
If no values are provided, they are set to zero.
107+
Stores the values of `q_rai`, `q_sno`, `n_liq`, `n_ice`, `n_rai` and `n_sno`
108+
for the `precip_model`. If no values are provided, they are set to zero.
109109
"""
110-
struct PrecipState1M{FT} <: PrecipState{FT}
110+
struct PrecipState2M{FT} <: PrecipState{FT}
111111
q_rai::FT
112112
q_sno::FT
113+
n_liq::FT
114+
n_ice::FT
115+
n_rai::FT
116+
n_sno::FT
113117
end
114-
PrecipState1M(; q_rai = 0, q_sno = 0) =
115-
PrecipState1M{typeof(q_rai)}(q_rai, q_sno)
118+
PrecipState2M(; q_rai = 0, q_sno = 0, n_liq = 0, n_ice = 0, n_rai = 0, n_sno = 0) =
119+
PrecipState2M{typeof(q_rai)}(q_rai, q_sno, n_liq, n_ice, n_rai, n_sno)

0 commit comments

Comments
 (0)