@@ -11,13 +11,12 @@ import ClimaCore.Fields as Fields
1111 buoyancy_gradients(
1212 closure::AbstractEnvBuoyGradClosure,
1313 thermo_params,
14- moisture_model,
14+
1515 # Arguments for the first method (most commonly called):
1616 ts::TD.ThermodynamicState,
1717 ::Type{C3}, # Covariant3 vector type, for projecting gradients
18- ∂θv∂z_unsat::AbstractField, # Vertical gradient of virtual potential temperature in unsaturated part
19- ∂qt∂z_sat::AbstractField, # Vertical gradient of total specific humidity in saturated part
20- ∂θli∂z_sat::AbstractField, # Vertical gradient of liquid-ice potential temperature in saturated part
18+ ∂qt∂z::AbstractField, # Vertical gradient of total specific humidity
19+ ∂θli∂z::AbstractField, # Vertical gradient of liquid-ice potential temperature
2120 local_geometry::Fields.LocalGeometry,
2221 # Argument for the second method (internal use with precomputed EnvBuoyGradVars):
2322 # bg_model::EnvBuoyGradVars
@@ -47,12 +46,10 @@ variables.
4746Arguments:
4847- `closure`: The environmental buoyancy gradient closure type (e.g., `BuoyGradMean`).
4948- `thermo_params`: Thermodynamic parameters from `CLIMAParameters`.
50- - `moisture_model`: Moisture model (e.g., `EquilMoistModel`, `NonEquilMoistModel`).
5149- `ts`: Center-level thermodynamic state of the environment.
5250- `C3`: The `ClimaCore.Geometry.Covariant3Vector` type, used for projecting input vertical gradients.
53- - `∂θv∂z_unsat`: Field of vertical gradients of virtual potential temperature in the unsaturated part.
54- - `∂qt∂z_sat`: Field of vertical gradients of total specific humidity in the saturated part.
55- - `∂θli∂z_sat`: Field of vertical gradients of liquid-ice potential temperature in the saturated part.
51+ - `∂qt∂z`: Field of vertical gradients of total specific humidity.
52+ - `∂θli∂z`: Field of vertical gradients of liquid-ice potential temperature.
5653- `local_geometry`: Field of local geometry at cell centers, used for gradient projection.
5754The second method takes a precomputed `EnvBuoyGradVars` object instead of `ts` and gradient fields.
5855
@@ -64,25 +61,23 @@ function buoyancy_gradients end
6461function buoyancy_gradients (
6562 ebgc:: AbstractEnvBuoyGradClosure ,
6663 thermo_params,
67- moisture_model,
6864 ts,
65+ cf,
6966 :: Type{C3} ,
70- ∂θv∂z_unsat,
71- ∂qt∂z_sat,
72- ∂θli∂z_sat,
67+ ∂qt∂z,
68+ ∂θli∂z,
7369 ᶜlg,
7470) where {C3}
7571 return buoyancy_gradients (
7672 ebgc,
7773 thermo_params,
78- moisture_model,
7974 EnvBuoyGradVars (
8075 ts,
76+ cf,
8177 projected_vector_buoy_grad_vars (
8278 C3,
83- ∂θv∂z_unsat,
84- ∂qt∂z_sat,
85- ∂θli∂z_sat,
79+ ∂qt∂z,
80+ ∂θli∂z,
8681 ᶜlg,
8782 ),
8883 ),
9287function buoyancy_gradients (
9388 ebgc:: AbstractEnvBuoyGradClosure ,
9489 thermo_params,
95- moisture_model,
9690 bg_model:: EnvBuoyGradVars ,
9791)
9892 FT = eltype (bg_model)
9993
10094 g = TDP. grav (thermo_params)
10195 Rv_over_Rd = TDP. Rv_over_Rd (thermo_params)
102- R_d = TDP. R_d (thermo_params)
10396 R_v = TDP. R_v (thermo_params)
10497
10598 ts = bg_model. ts
106- p = TD. air_pressure (thermo_params, ts)
107- Π = TD. exner_given_pressure (thermo_params, p)
108- ∂b∂θv = g * (R_d * TD. air_density (thermo_params, ts) / p) * Π
99+ ∂b∂θv = g / TD. virtual_pottemp (thermo_params, ts)
109100
110- t_sat = TD. air_temperature (thermo_params, ts)
101+ T = TD. air_temperature (thermo_params, ts)
111102 λ = TD. liquid_fraction (thermo_params, ts)
112103 lh =
113- λ * TD. latent_heat_vapor (thermo_params, t_sat ) +
114- (1 - λ) * TD. latent_heat_sublim (thermo_params, t_sat )
104+ λ * TD. latent_heat_vapor (thermo_params, T ) +
105+ (1 - λ) * TD. latent_heat_sublim (thermo_params, T )
115106 cp_m = TD. cp_m (thermo_params, ts)
116- qv_sat = TD. vapor_specific_humidity (thermo_params, ts)
117- qt_sat = TD. total_specific_humidity (thermo_params, ts)
107+ q_sat = TD. q_vap_saturation (thermo_params, ts)
108+ q_tot = TD. total_specific_humidity (thermo_params, ts)
109+ θ = TD. dry_pottemp (thermo_params, ts)
110+ ∂b∂θli_unsat = ∂b∂θv * (1 + (Rv_over_Rd - 1 ) * q_tot)
111+ ∂b∂qt_unsat = ∂b∂θv * (Rv_over_Rd - 1 ) * θ
118112 ∂b∂θli_sat = (
119113 ∂b∂θv *
120- (1 + Rv_over_Rd * (1 + lh / R_v / t_sat ) * qv_sat - qt_sat ) /
121- (1 + lh * lh / cp_m / R_v / t_sat / t_sat * qv_sat )
114+ (1 + Rv_over_Rd * (1 + lh / R_v / T ) * q_sat - q_tot ) /
115+ (1 + lh^ 2 / cp_m / R_v / T ^ 2 * q_sat )
122116 )
123117 ∂b∂qt_sat =
124- (lh / cp_m / t_sat * ∂b∂θli_sat - ∂b∂θv) *
125- TD. dry_pottemp (thermo_params, ts)
118+ (lh / cp_m / T * ∂b∂θli_sat - ∂b∂θv) * θ
126119
127120 ∂b∂z = buoyancy_gradient_chain_rule (
128121 ebgc,
129122 bg_model,
130123 thermo_params,
131- ∂b∂θv,
124+ ∂b∂θli_unsat,
125+ ∂b∂qt_unsat,
132126 ∂b∂θli_sat,
133127 ∂b∂qt_sat,
134128 )
140134 closure::AbstractEnvBuoyGradClosure,
141135 bg_model::EnvBuoyGradVars,
142136 thermo_params,
143- ∂b∂θv::FT,
144137 ∂b∂θli_sat::FT,
145138 ∂b∂qt_sat::FT,
146139 ) where {FT}
@@ -165,7 +158,6 @@ Arguments:
165158- `closure`: The environmental buoyancy gradient closure type.
166159- `bg_model`: Precomputed environmental buoyancy gradient variables (`EnvBuoyGradVars`).
167160- `thermo_params`: Thermodynamic parameters from `CLIMAParameters`.
168- - `∂b∂θv`: Partial derivative of buoyancy w.r.t. virtual potential temperature (unsaturated part).
169161- `∂b∂θli_sat`: Partial derivative of buoyancy w.r.t. liquid-ice potential temperature (saturated part).
170162- `∂b∂qt_sat`: Partial derivative of buoyancy w.r.t. total specific humidity (saturated part).
171163
@@ -176,18 +168,19 @@ function buoyancy_gradient_chain_rule(
176168 :: AbstractEnvBuoyGradClosure ,
177169 bg_model:: EnvBuoyGradVars ,
178170 thermo_params,
179- ∂b∂θv,
171+ ∂b∂θli_unsat,
172+ ∂b∂qt_unsat,
180173 ∂b∂θli_sat,
181174 ∂b∂qt_sat,
182175)
183- en_cld_frac = ifelse (TD. has_condensate (thermo_params, bg_model. ts), 1 , 0 )
184-
185- ∂b∂z_θl_sat = ∂b∂θli_sat * bg_model.∂θli∂z_sat
186- ∂b∂z_qt_sat = ∂b∂qt_sat * bg_model.∂qt∂z_sat
176+ ∂b∂z_θli_unsat = ∂b∂θli_unsat * bg_model.∂θli∂z
177+ ∂b∂z_qt_unsat = ∂b∂qt_unsat * bg_model.∂qt∂z
178+ ∂b∂z_unsat = ∂b∂z_θli_unsat + ∂b∂z_qt_unsat
179+ ∂b∂z_θl_sat = ∂b∂θli_sat * bg_model.∂θli∂z
180+ ∂b∂z_qt_sat = ∂b∂qt_sat * bg_model.∂qt∂z
187181 ∂b∂z_sat = ∂b∂z_θl_sat + ∂b∂z_qt_sat
188- ∂b∂z_unsat = ∂b∂θv * bg_model.∂θv∂z_unsat
189182
190- ∂b∂z = (1 - en_cld_frac ) * ∂b∂z_unsat + en_cld_frac * ∂b∂z_sat
183+ ∂b∂z = (1 - bg_model . cf ) * ∂b∂z_unsat + bg_model . cf * ∂b∂z_sat
191184
192185 return ∂b∂z
193186end
0 commit comments