Skip to content

Commit 506bc3f

Browse files
authored
Fix bug in saturation adjustment solver for MoistAirBuoyancy (#120)
This PR fixes a bug in the saturation adjustment solver that only gets hit under certain conditions: when the secant iteration accesses unsaturated states during the course of finding a saturated state. Before this PR, we assume that during adjustment the state was saturated. However, this assumption does not hold if "intermediate" (eg test) states that are accessed during the iteration are not saturated. The result of the bug is a spurious change in the total moisture fraction. It is fixed in this PR.
1 parent 01d9775 commit 506bc3f

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/MoistAirBuoyancies.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,15 @@ Solution of ``r(T) = 0`` is found via the [secant method](https://en.wikipedia.o
203203
q₁ = MoistureMassFractions(qᵛ⁺₁, qˡ₁, zero(qˡ₁))
204204
𝒰₁ = with_moisture(𝒰₀, q₁)
205205

206-
# We generate a second guess simply by adding 1 K to T₁...
207-
208-
# NOTE: We could also generate a second guess to start a secant iteration
206+
# We generate a second guess to start a secant iteration
209207
# by applying the potential temperature assuming a liquid fraction
210208
# associated with T₁. This should represent an _overestimate_,
211209
# since ``qᵛ⁺₁(T₁)`` underestimates the saturation specific humidity,
212210
# and therefore qˡ₁ is overestimated. This is similar to an approach
213211
# used in Pressel et al 2015. However, it doesn't work for large liquid fractions.
214-
T₂ = T₁ + 1
215-
216-
#=
217212
ℒˡᵣ = thermo.liquid.reference_latent_heat
218213
cᵖᵐ = mixture_heat_capacity(q₁, thermo)
219214
T₂ = T₁ + ℒˡᵣ * qˡ₁ / cᵖᵐ
220-
=#
221-
222215
𝒰₂ = adjust_state(𝒰₁, T₂, thermo)
223216

224217
# Initialize saturation adjustment
@@ -267,7 +260,8 @@ end
267260
qᵛ⁺ = adjustment_saturation_specific_humidity(T, 𝒰₀, thermo)
268261
qᵗ = total_moisture_mass_fraction(𝒰₀)
269262
= max(0, qᵗ - qᵛ⁺)
270-
q₁ = MoistureMassFractions(qᵛ⁺, qˡ, zero(qˡ))
263+
qᵛ = qᵗ -
264+
q₁ = MoistureMassFractions(qᵛ, qˡ, zero(qˡ))
271265
return with_moisture(𝒰₀, q₁)
272266
end
273267

0 commit comments

Comments
 (0)