Skip to content

Commit d1f6923

Browse files
committed
style format
1 parent 72a0440 commit d1f6923

File tree

9 files changed

+178
-148
lines changed

9 files changed

+178
-148
lines changed

post_processing/ci_plots.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,18 @@ function make_plots(
637637
figsize = (1200, 600)
638638
pr_row = 3
639639
else
640-
short_names = ["hus", "clw", "cli", "husra", "hussn", "ta", "clwnm", "clinm", "nmra", "nmsn"]
640+
short_names = [
641+
"hus",
642+
"clw",
643+
"cli",
644+
"husra",
645+
"hussn",
646+
"ta",
647+
"clwnm",
648+
"clinm",
649+
"nmra",
650+
"nmsn",
651+
]
641652
figsize = (1200, 1000)
642653
pr_row = 5
643654
end

src/cache/precipitation_precomputed_quantities.jl

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ function set_precipitation_velocities!(
104104
moisture_model::NonEquilMoistModel,
105105
precip_model::Microphysics2Moment,
106106
)
107-
(; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwnₗ, ᶜwnᵢ, ᶜwnᵣ, ᶜwnₛ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts, ᶜu) = p.precomputed
107+
(; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwnₗ, ᶜwnᵢ, ᶜwnᵣ, ᶜwnₛ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts, ᶜu) =
108+
p.precomputed
108109
(; q_liq, q_ice, q_rai, q_sno) = p.precomputed.ᶜspecific
109110
(; ᶜΦ) = p.core
110111

@@ -115,59 +116,26 @@ function set_precipitation_velocities!(
115116

116117
# compute the precipitation terminal velocity [m/s]
117118
# TODO sedimentation of snow is based on the 1M scheme
118-
@. ᶜwnᵣ = getindex(CM2.rain_terminal_velocity(
119-
cm2p.sb,
120-
cm2p.tv,
121-
q_rai,
122-
Y.c.ρ,
123-
Y.c.ρn_rai,
124-
), 1)
125-
@. ᶜwᵣ = getindex(CM2.rain_terminal_velocity(
126-
cm2p.sb,
127-
cm2p.tv,
128-
q_rai,
129-
Y.c.ρ,
130-
Y.c.ρn_rai,
131-
), 2)
132-
@. ᶜwnₛ = CM1.terminal_velocity(
133-
cm1p.ps,
134-
cm1p.tv.snow,
135-
Y.c.ρ,
136-
q_sno,
119+
@. ᶜwnᵣ = getindex(
120+
CM2.rain_terminal_velocity(cm2p.sb, cm2p.tv, q_rai, Y.c.ρ, Y.c.ρn_rai),
121+
1,
137122
)
138-
@. ᶜwₛ = CM1.terminal_velocity(
139-
cm1p.ps,
140-
cm1p.tv.snow,
141-
Y.c.ρ,
142-
q_sno,
123+
@. ᶜwᵣ = getindex(
124+
CM2.rain_terminal_velocity(cm2p.sb, cm2p.tv, q_rai, Y.c.ρ, Y.c.ρn_rai),
125+
2,
143126
)
127+
@. ᶜwnₛ = CM1.terminal_velocity(cm1p.ps, cm1p.tv.snow, Y.c.ρ, q_sno)
128+
@. ᶜwₛ = CM1.terminal_velocity(cm1p.ps, cm1p.tv.snow, Y.c.ρ, q_sno)
144129
# compute sedimentation velocity for cloud condensate [m/s]
145130
# TODO sedimentation velocities of cloud condensates are based
146131
# on the 1M scheme.
147-
@. ᶜwnₗ = CMNe.terminal_velocity(
148-
cm1c.liquid,
149-
cm1c.Ch2022.rain,
150-
Y.c.ρ,
151-
q_liq,
152-
)
153-
@. ᶜwₗ = CMNe.terminal_velocity(
154-
cm1c.liquid,
155-
cm1c.Ch2022.rain,
156-
Y.c.ρ,
157-
q_liq,
158-
)
159-
@. ᶜwnᵢ = CMNe.terminal_velocity(
160-
cm1c.ice,
161-
cm1c.Ch2022.small_ice,
162-
Y.c.ρ,
163-
q_ice,
164-
)
165-
@. ᶜwᵢ = CMNe.terminal_velocity(
166-
cm1c.ice,
167-
cm1c.Ch2022.small_ice,
168-
Y.c.ρ,
169-
q_ice,
170-
)
132+
@. ᶜwnₗ =
133+
CMNe.terminal_velocity(cm1c.liquid, cm1c.Ch2022.rain, Y.c.ρ, q_liq)
134+
@. ᶜwₗ = CMNe.terminal_velocity(cm1c.liquid, cm1c.Ch2022.rain, Y.c.ρ, q_liq)
135+
@. ᶜwnᵢ =
136+
CMNe.terminal_velocity(cm1c.ice, cm1c.Ch2022.small_ice, Y.c.ρ, q_ice)
137+
@. ᶜwᵢ =
138+
CMNe.terminal_velocity(cm1c.ice, cm1c.Ch2022.small_ice, Y.c.ρ, q_ice)
171139

172140
# compute their contributions to energy and total water advection
173141
@. ᶜwₜqₜ =
@@ -391,7 +359,7 @@ function set_precipitation_cache!(Y, p, ::Microphysics2Moment, _)
391359
@. ᶜSqₛᵖ = 0
392360
@. ᶜSnᵢᵖ = 0
393361
@. ᶜSnₛᵖ = 0
394-
362+
395363
return nothing
396364
end
397365
function set_precipitation_cache!(

src/cache/precomputed_quantities.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ function precomputed_quantities(Y, atmos)
126126
)
127127
sedimentation_quantities =
128128
atmos.moisture_model isa NonEquilMoistModel ?
129-
(; ᶜwₗ = similar(Y.c, FT), ᶜwᵢ = similar(Y.c, FT), ᶜwnₗ = similar(Y.c, FT), ᶜwnᵢ = similar(Y.c, FT)) : (;)
129+
(;
130+
ᶜwₗ = similar(Y.c, FT),
131+
ᶜwᵢ = similar(Y.c, FT),
132+
ᶜwnₗ = similar(Y.c, FT),
133+
ᶜwnᵢ = similar(Y.c, FT),
134+
) : (;)
130135
if atmos.precip_model isa Microphysics0Moment
131136
precipitation_quantities =
132137
(; ᶜS_ρq_tot = similar(Y.c, FT), ᶜS_ρe_tot = similar(Y.c, FT))

src/diagnostics/core_diagnostics.jl

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,10 @@ function compute_hussfc!(
470470
cache.precomputed.sfc_conditions.ts,
471471
)
472472
else
473-
out .=
474-
TD.total_specific_humidity.(
475-
thermo_params,
476-
cache.precomputed.sfc_conditions.ts,
477-
)
473+
out .= TD.total_specific_humidity.(
474+
thermo_params,
475+
cache.precomputed.sfc_conditions.ts,
476+
)
478477
end
479478
end
480479

@@ -504,11 +503,10 @@ add_diagnostic_variable!(
504503
cache.precomputed.sfc_conditions.ts,
505504
)
506505
else
507-
out .=
508-
TD.air_temperature.(
509-
thermo_params,
510-
cache.precomputed.sfc_conditions.ts,
511-
)
506+
out .= TD.air_temperature.(
507+
thermo_params,
508+
cache.precomputed.sfc_conditions.ts,
509+
)
512510
end
513511
end,
514512
)
@@ -530,11 +528,10 @@ add_diagnostic_variable!(
530528
Fields.level(cache.precomputed.ᶜts, 1),
531529
)
532530
else
533-
out .=
534-
TD.air_temperature.(
535-
thermo_params,
536-
Fields.level(cache.precomputed.ᶜts, 1),
537-
)
531+
out .= TD.air_temperature.(
532+
thermo_params,
533+
Fields.level(cache.precomputed.ᶜts, 1),
534+
)
538535
end
539536
end,
540537
)
@@ -552,14 +549,13 @@ add_diagnostic_variable!(
552549
if isnothing(out)
553550
return copy(
554551
u_component.(
555-
Geometry.UVector.(Fields.level(cache.precomputed.ᶜu, 1))
552+
Geometry.UVector.(Fields.level(cache.precomputed.ᶜu, 1)),
556553
),
557554
)
558555
else
559-
out .=
560-
u_component.(
561-
Geometry.UVector.(Fields.level(cache.precomputed.ᶜu, 1))
562-
)
556+
out .= u_component.(
557+
Geometry.UVector.(Fields.level(cache.precomputed.ᶜu, 1)),
558+
)
563559
end
564560
end,
565561
)
@@ -577,14 +573,13 @@ add_diagnostic_variable!(
577573
if isnothing(out)
578574
return copy(
579575
v_component.(
580-
Geometry.VVector.(Fields.level(cache.precomputed.ᶜu, 1))
576+
Geometry.VVector.(Fields.level(cache.precomputed.ᶜu, 1)),
581577
),
582578
)
583579
else
584-
out .=
585-
v_component.(
586-
Geometry.VVector.(Fields.level(cache.precomputed.ᶜu, 1))
587-
)
580+
out .= v_component.(
581+
Geometry.VVector.(Fields.level(cache.precomputed.ᶜu, 1)),
582+
)
588583
end
589584
end,
590585
)
@@ -598,16 +593,12 @@ function compute_tau!(out, state, cache, component)
598593

599594
if isnothing(out)
600595
return getproperty(
601-
Geometry.UVVector.(
602-
adjoint.(ρ_flux_uₕ) .* surface_ct3_unit
603-
).components.data,
596+
Geometry.UVVector.(adjoint.(ρ_flux_uₕ) .* surface_ct3_unit).components.data,
604597
component,
605598
)
606599
else
607600
out .= getproperty(
608-
Geometry.UVVector.(
609-
adjoint.(ρ_flux_uₕ) .* surface_ct3_unit
610-
).components.data,
601+
Geometry.UVVector.(adjoint.(ρ_flux_uₕ) .* surface_ct3_unit).components.data,
611602
component,
612603
)
613604
end
@@ -808,10 +799,7 @@ function compute_husra!(
808799
state,
809800
cache,
810801
time,
811-
precip_model::Union{
812-
Microphysics1Moment,
813-
Microphysics2Moment,
814-
},
802+
precip_model::Union{Microphysics1Moment, Microphysics2Moment},
815803
)
816804
if isnothing(out)
817805
return state.c.ρq_rai ./ state.c.ρ
@@ -842,10 +830,7 @@ function compute_hussn!(
842830
state,
843831
cache,
844832
time,
845-
precip_model::Union{
846-
Microphysics1Moment,
847-
Microphysics2Moment,
848-
},
833+
precip_model::Union{Microphysics1Moment, Microphysics2Moment},
849834
)
850835
if isnothing(out)
851836
return state.c.ρq_sno ./ state.c.ρ
@@ -1362,11 +1347,10 @@ function compute_husv!(
13621347
cache.precomputed.ᶜts,
13631348
)
13641349
else
1365-
out .=
1366-
TD.vapor_specific_humidity.(
1367-
CAP.thermodynamics_params(cache.params),
1368-
cache.precomputed.ᶜts,
1369-
)
1350+
out .= TD.vapor_specific_humidity.(
1351+
CAP.thermodynamics_params(cache.params),
1352+
cache.precomputed.ᶜts,
1353+
)
13701354
end
13711355
end
13721356

@@ -1498,15 +1482,14 @@ function compute_cape!(out, state, cache, time)
14981482
lazy.(TD.liquid_ice_pottemp.(thermo_params, surface_thermal_state))
14991483

15001484
# Create parcel thermodynamic states at each level based on energy & moisture at surface
1501-
parcel_ts_moist =
1502-
lazy.(
1503-
TD.PhaseEquil_pθq.(
1504-
thermo_params,
1505-
cache.precomputed.ᶜp,
1506-
surface_θ_liq_ice,
1507-
surface_q,
1508-
)
1509-
)
1485+
parcel_ts_moist = lazy.(
1486+
TD.PhaseEquil_pθq.(
1487+
thermo_params,
1488+
cache.precomputed.ᶜp,
1489+
surface_θ_liq_ice,
1490+
surface_q,
1491+
),
1492+
)
15101493

15111494
# Calculate virtual temperatures for parcel & environment
15121495
parcel_Tv = lazy.(TD.virtual_temperature.(thermo_params, parcel_ts_moist))
@@ -1520,8 +1503,7 @@ function compute_cape!(out, state, cache, time)
15201503
# restrict to tropospheric buoyancy (generously below 20km) TODO: integrate from LFC to LNB
15211504
FT = Spaces.undertype(axes(ᶜbuoyancy))
15221505
ᶜbuoyancy .=
1523-
ᶜbuoyancy .*
1524-
ifelse.(
1506+
ᶜbuoyancy .* ifelse.(
15251507
Fields.coordinate_field(state.c.ρ).z .< FT(20000.0),
15261508
FT(1.0),
15271509
FT(0.0),

src/initial_conditions/initial_conditions.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,11 @@ function overwrite_initial_conditions!(
398398
Y.c.ρ .= TD.air_density.(thermo_params, ᶜts)
399399
# Velocity is first assigned on cell-centers and then interpolated onto
400400
# cell faces.
401-
vel =
402-
Geometry.UVWVector.(
403-
SpaceVaryingInputs.SpaceVaryingInput(file_path, "u", center_space),
404-
SpaceVaryingInputs.SpaceVaryingInput(file_path, "v", center_space),
405-
SpaceVaryingInputs.SpaceVaryingInput(file_path, "w", center_space),
406-
)
401+
vel = Geometry.UVWVector.(
402+
SpaceVaryingInputs.SpaceVaryingInput(file_path, "u", center_space),
403+
SpaceVaryingInputs.SpaceVaryingInput(file_path, "v", center_space),
404+
SpaceVaryingInputs.SpaceVaryingInput(file_path, "w", center_space),
405+
)
407406
Y.c.uₕ .= C12.(Geometry.UVVector.(vel))
408407
Y.f.u₃ .= ᶠinterp.(C3.(Geometry.WVector.(vel)))
409408
e_kin = similar(ᶜT)
@@ -1226,7 +1225,14 @@ function (initial_condition::PrecipitatingColumn)(params)
12261225
thermo_state = ts,
12271226
velocity = Geometry.UVVector(u(z), v(z)),
12281227
turbconv_state = nothing,
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)),
1228+
precip_state = PrecipState2M(;
1229+
q_rai = qᵣ(z),
1230+
q_sno = qₛ(z),
1231+
n_liq = nₗ(z),
1232+
n_ice = nᵢ(z),
1233+
n_rai = nᵣ(z),
1234+
n_sno = nₛ(z),
1235+
),
12301236
)
12311237
end
12321238
return local_state
@@ -1264,12 +1270,12 @@ function (initial_condition::GCMDriven)(params)
12641270
return LocalState(;
12651271
params,
12661272
geometry = local_geometry,
1267-
thermo_state = ts = TD.PhaseEquil_ρTq(
1273+
thermo_state = ts = TD.PhaseEquil_ρTq(
12681274
thermo_params,
12691275
FT(ρ₀(z)),
12701276
FT(T(z)),
12711277
FT(q_tot(z)),
1272-
),
1278+
) ,
12731279
velocity = Geometry.UVVector(FT(u(z)), FT(v(z))),
12741280
turbconv_state = EDMFState(; tke = FT(0)),
12751281
)
@@ -1320,12 +1326,12 @@ function (initial_condition::InterpolatedColumnProfile)(params)
13201326
return LocalState(;
13211327
params,
13221328
geometry = local_geometry,
1323-
thermo_state = ts = TD.PhaseEquil_ρTq(
1329+
thermo_state = ts = TD.PhaseEquil_ρTq(
13241330
thermo_params,
13251331
FT(ρ₀(z)),
13261332
FT(T(z)),
13271333
FT(q_tot(z)),
1328-
),
1334+
) ,
13291335
velocity = Geometry.UVVector(FT(u(z)), FT(v(z))),
13301336
turbconv_state = EDMFState(; tke = FT(0)),
13311337
)

src/initial_conditions/local_state.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,11 @@ struct PrecipState2M{FT} <: PrecipState{FT}
115115
n_rai::FT
116116
n_sno::FT
117117
end
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)
118+
PrecipState2M(;
119+
q_rai = 0,
120+
q_sno = 0,
121+
n_liq = 0,
122+
n_ice = 0,
123+
n_rai = 0,
124+
n_sno = 0,
125+
) = PrecipState2M{typeof(q_rai)}(q_rai, q_sno, n_liq, n_ice, n_rai, n_sno)

0 commit comments

Comments
 (0)