Skip to content

Commit ea5237d

Browse files
imreddyTejajuliasloan25
authored andcommitted
store total energy and water in bucket cache
1 parent ee56822 commit ea5237d

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

src/standalone/Bucket/Bucket.jl

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ auxiliary_types(::BucketModel{FT}) where {FT} = (
321321
FT,
322322
FT,
323323
ClimaCore.Geometry.WVector{FT},
324+
FT,
325+
FT,
324326
)
325327
auxiliary_vars(::BucketModel) = (
326328
:q_sfc,
@@ -336,6 +338,8 @@ auxiliary_vars(::BucketModel) = (
336338
:snow_melt,
337339
:infiltration,
338340
:top_bc_wvec,
341+
:total_energy,
342+
:total_water,
339343
)
340344
auxiliary_domain_names(::BucketModel) = (
341345
:surface,
@@ -351,6 +355,8 @@ auxiliary_domain_names(::BucketModel) = (
351355
:surface,
352356
:surface,
353357
:surface,
358+
:surface,
359+
:surface,
354360
)
355361

356362

@@ -497,6 +503,9 @@ function make_update_aux(model::BucketModel{FT}) where {FT}
497503
model.parameters.W_f,
498504
) # Equation (2) of the text.
499505

506+
# Compute the integrated energy and water per area
507+
ClimaLand.total_energy_per_area!(p.bucket.total_energy, model, Y, p, t)
508+
ClimaLand.total_water_per_area!(p.bucket.total_water, model, Y, p, t)
500509
end
501510
return update_aux!
502511
end
@@ -576,6 +585,81 @@ function surface_air_density(
576585
return p.bucket.ρ_sfc
577586
end
578587

588+
"""
589+
590+
ClimaLand.total_energy_per_area!(
591+
surface_field,
592+
model::BucketModel,
593+
Y,
594+
p,
595+
t,
596+
)
597+
598+
A function which updates `surface_field` in place with the value for
599+
the total energy per unit ground area for the `BucketModel`.
600+
601+
The ground of the bucket model has temperature `Y.bucket.T`, with
602+
volumetric specific heat approximated with the parameter `ρc_soil`.
603+
Additional energy is present due to the latent heat of fusion of
604+
frozen water, in the form of snow. We also add in this energy (below).
605+
We do not model or account for the sensible energy of snow (`ρ_snow T_snow`),
606+
as this is much smaller.
607+
"""
608+
function ClimaLand.total_energy_per_area!(
609+
surface_field,
610+
model::BucketModel,
611+
Y,
612+
p,
613+
t,
614+
)
615+
surface_field .= 0
616+
# Sensible energy of the soil
617+
ClimaCore.Operators.column_integral_definite!(
618+
surface_field,
619+
model.parameters.ρc_soil .* Y.bucket.T,
620+
)
621+
622+
# Latent heat of fusion of frozen water in the snow
623+
surface_field .+=
624+
-LP.LH_f0(model.parameters.earth_param_set) .*
625+
LP.ρ_cloud_liq(model.parameters.earth_param_set) .* Y.bucket.σS
626+
return nothing
627+
end
628+
629+
"""
630+
631+
ClimaLand.total_water_per_area!(
632+
surface_field,
633+
model::BucketModel,
634+
Y,
635+
p,
636+
t,
637+
)
638+
639+
A function which updates `surface_field` in place with the value for
640+
the total water per unit ground area for the `BucketModel`, in kg m⁻².
641+
642+
The total water contained in the bucket is the sum of the
643+
subsurface water storage `W`, the snow water equivalent `σS` and
644+
surface water content `Ws`, times the density of liquid water `ρ_cloud_liq`.
645+
"""
646+
function ClimaLand.total_water_per_area!(
647+
surface_field,
648+
model::BucketModel,
649+
Y,
650+
p,
651+
t,
652+
)
653+
ρ_cloud_liq = LP.ρ_cloud_liq(sim.model.parameters.earth_param_set)
654+
@. surface_field =
655+
(
656+
sim.integrator.u.bucket.σS +
657+
sim.integrator.u.bucket.W +
658+
sim.integrator.u.bucket.Ws
659+
) * ρ_cloud_liq
660+
return nothing
661+
end
662+
579663
include("./bucket_parameterizations.jl")
580664

581665
end

0 commit comments

Comments
 (0)