From f210c2ddacf6eecc67edd8561fa7558755993a59 Mon Sep 17 00:00:00 2001 From: kmdeck Date: Wed, 4 Dec 2024 13:47:00 -0800 Subject: [PATCH] up to date with ac/add_snow_ema --- docs/Project.toml | 1 + ext/neural_snow/NeuralSnow.jl | 1 + src/integrated/soil_snow_model.jl | 25 ++++++++++------------- test/standalone/Snow/parameterizations.jl | 3 +-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index b21800b736..4ef46ebaed 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,4 +1,5 @@ [deps] +About = "69d22d85-9f48-4c46-bbbe-7ad8341ff72a" AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" diff --git a/ext/neural_snow/NeuralSnow.jl b/ext/neural_snow/NeuralSnow.jl index 5de529173d..3cd260c4ed 100644 --- a/ext/neural_snow/NeuralSnow.jl +++ b/ext/neural_snow/NeuralSnow.jl @@ -114,6 +114,7 @@ redundant computations in the computation of runoff. """ ClimaLand.Snow.snow_depth(m::NeuralDepthModel, Y, p, params) = Y.snow.Z + """ eval_nn(vmodel, z::FT, swe::FT, P::FT, T::FT, R::FT, qrel::FT, u::FT)::FT where {FT} Helper function for evaluating the neural network in a pointwise manner over a `ClimaCore.Field` diff --git a/src/integrated/soil_snow_model.jl b/src/integrated/soil_snow_model.jl index 8b8d7e9a29..b728f9acdc 100644 --- a/src/integrated/soil_snow_model.jl +++ b/src/integrated/soil_snow_model.jl @@ -387,22 +387,19 @@ function soil_boundary_fluxes!( bc = soil.boundary_conditions.top p.soil.turbulent_fluxes .= turbulent_fluxes(bc.atmos, soil, Y, p, t) p.soil.R_n .= net_radiation(bc.radiation, soil, Y, p, t) - # influx = maximum possible rate of infiltration given precip, snowmelt, evaporation/condensation - # but if this exceeds infiltration capacity of the soil, runoff will - # be generated. - # Use top_bc.water as temporary storage to avoid allocation - influx = p.soil.top_bc.water - @. influx = - p.drivers.P_liq + - p.snow.water_runoff * p.snow.snow_cover_fraction + - p.excess_water_flux + + Soil.Runoff.update_runoff!( + p, + bc.runoff, + p.drivers.P_liq .+ p.snow.water_runoff .* p.snow.snow_cover_fraction .+ + p.excess_water_flux, + Y, + t, + soil, + ) + @. p.soil.top_bc.water = + p.soil.infiltration + (1 - p.snow.snow_cover_fraction) * p.soil.turbulent_fluxes.vapor_flux_liq - # The update_runoff! function computes how much actually infiltrates - # given influx and our runoff model bc.runoff, and updates - # p.soil.infiltration in place - Soil.Runoff.update_runoff!(p, bc.runoff, influx, Y, t, soil) - @. p.soil.top_bc.water = p.soil.infiltration @. p.soil.top_bc.heat = (1 - p.snow.snow_cover_fraction) * ( diff --git a/test/standalone/Snow/parameterizations.jl b/test/standalone/Snow/parameterizations.jl index 73df17a636..6b6f418b58 100644 --- a/test/standalone/Snow/parameterizations.jl +++ b/test/standalone/Snow/parameterizations.jl @@ -78,8 +78,7 @@ for FT in (Float32, Float64) @test specific_heat_capacity(FT(0.0), parameters) == _cp_i @test snow_thermal_conductivity(ρ_snow, parameters) == κ_air + - (FT(0.07) * (ρ_snow / _ρ_i) + FT(0.93) * (ρ_snow / _ρ_i)^2) * - (κ_ice - κ_air) + (FT(7.75e-5) * ρ_snow + FT(1.105e-6) * ρ_snow^2) * (κ_ice - κ_air) @test runoff_timescale.(z, Ksat, FT(Δt)) ≈ max.(Δt, z ./ Ksat)