Skip to content

Commit

Permalink
up to date with ac/add_snow_ema
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Dec 4, 2024
1 parent f781557 commit f210c2d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions ext/neural_snow/NeuralSnow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
25 changes: 11 additions & 14 deletions src/integrated/soil_snow_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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) * (
Expand Down
3 changes: 1 addition & 2 deletions test/standalone/Snow/parameterizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit f210c2d

Please sign in to comment.