From 55111a625423f2cc9633d8cbdd9c0320c19556c6 Mon Sep 17 00:00:00 2001 From: kmdeck Date: Wed, 4 Sep 2024 10:17:30 -0700 Subject: [PATCH] clip whe condensing --- src/shared_utilities/drivers.jl | 4 ++++ src/standalone/Soil/energy_hydrology.jl | 29 ++++++++++++------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/shared_utilities/drivers.jl b/src/shared_utilities/drivers.jl index 6ce71264e9..2f090b85b9 100644 --- a/src/shared_utilities/drivers.jl +++ b/src/shared_utilities/drivers.jl @@ -339,6 +339,7 @@ function turbulent_fluxes_at_a_point( SVector{2, FT}(u, 0), ts_in, ) + q_in::FT = Thermodynamics.total_specific_humidity(thermo_params, ts_in); # State containers sc = SurfaceFluxes.ValuesOnly( @@ -366,6 +367,9 @@ function turbulent_fluxes_at_a_point( E0::FT = SurfaceFluxes.evaporation(surface_flux_params, sc, conditions.Ch) E = E0 * r_ae / (r_sfc + r_ae) + if q_sfc < q_in # condensation breaks things + E *= 0 + end Ẽ = E / _ρ_liq H = -ρ_air * cp_m * ΔT / r_ae LH = _LH_v0 * E diff --git a/src/standalone/Soil/energy_hydrology.jl b/src/standalone/Soil/energy_hydrology.jl index 92de094011..69e9980846 100644 --- a/src/standalone/Soil/energy_hydrology.jl +++ b/src/standalone/Soil/energy_hydrology.jl @@ -715,14 +715,13 @@ end """ function ClimaLand.surface_evaporative_scaling(model::EnergyHydrology{FT}, Y, p) where {FT} (; ν, θ_r, d_ds, earth_param_set, hydrology_cm) = model.parameters - θ_l_sfc = ClimaLand.top_center_to_surface(p.soil.θ_l)#p.soil.sfc_scratch - # ClimaLand.Domains.linear_interpolation_to_surface!( - # θ_l_sfc, - # p.soil.θ_l, - # model.domain.fields.z, - # model.domain.fields.Δz_top, - # ) - # These are non-allocating + θ_l_sfc = p.soil.sfc_scratch + ClimaLand.Domains.linear_interpolation_to_surface!( + θ_l_sfc, + p.soil.θ_l, + model.domain.fields.z, + model.domain.fields.Δz_top, + ) θ_i_sfc = ClimaLand.Domains.top_center_to_surface(Y.soil.θ_i) hydrology_cm_sfc = ClimaLand.Domains.top_center_to_surface(hydrology_cm) ν_sfc = ClimaLand.Domains.top_center_to_surface(ν) @@ -747,13 +746,13 @@ function ClimaLand.surface_resistance( t, ) where {FT} (; ν, θ_r, d_ds, earth_param_set, hydrology_cm) = model.parameters - θ_l_sfc = ClimaLand.Domains.top_center_to_surface(p.soil.θ_l)#p.soil.sfc_scratch - # ClimaLand.Domains.linear_interpolation_to_surface!( - # θ_l_sfc, - # p.soil.θ_l, - # model.domain.fields.z, - # model.domain.fields.Δz_top, - # ) + θ_l_sfc = p.soil.sfc_scratch + ClimaLand.Domains.linear_interpolation_to_surface!( + θ_l_sfc, + p.soil.θ_l, + model.domain.fields.z, + model.domain.fields.Δz_top, + ) # These are non-allocating θ_i_sfc = ClimaLand.Domains.top_center_to_surface(Y.soil.θ_i) hydrology_cm_sfc = ClimaLand.Domains.top_center_to_surface(hydrology_cm)