Skip to content

Commit a5fe9c3

Browse files
authored
Merge pull request #1437 from CliMA/js/cache
remove bucket get_new_cache
2 parents c3a929d + 7a5271f commit a5fe9c3

File tree

3 files changed

+19
-33
lines changed

3 files changed

+19
-33
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ ClimaCoupler.jl Release Notes
66

77
### ClimaCoupler features
88

9+
#### Remove bucket `get_new_cache` PR[#1437](https://github.com/CliMA/ClimaCoupler.jl/pull/1437)
10+
11+
As of ClimaLand v0.16.2, total energy and and water are always stored in the bucket cache.
12+
This PR removes the `get_new_cache`, which allocated space for the energy field,
13+
and instead accesses the cached fields directly.
14+
915
#### Add option for integrated land spun up IC. PR[#1318](https://github.com/CliMA/ClimaCoupler.jl/pull/1318)
1016

1117
Adds a boolean flag `land_spun_up_ic` that allows the user to request reading integrated land

experiments/ClimaEarth/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ClimaAnalysis = "0.5.10"
3939
ClimaAtmos = "0.27, 0.28, 0.29, 0.30, 0.31"
4040
ClimaCalibrate = "0.1"
4141
ClimaDiagnostics = "0.2.6"
42-
ClimaLand = "0.17"
42+
ClimaLand = "0.17.1"
4343
ClimaOcean = "0.7"
4444
ClimaParams = "0.10"
4545
ClimaTimeSteppers = "0.7, 0.8"

experiments/ClimaEarth/components/land/climaland_bucket.jl

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,6 @@ struct BucketSimulation{M <: CL.Bucket.BucketModel, I <: SciMLBase.AbstractODEIn
3737
output_writer::OW
3838
end
3939

40-
"""
41-
get_new_cache(p, Y, energy_check)
42-
Returns a new `p` with an updated field to store e_per_area if energy conservation
43-
checks are turned on.
44-
"""
45-
function get_new_cache(p, Y, energy_check)
46-
if energy_check
47-
e_per_area_field = CC.Fields.zeros(axes(Y.bucket.W))
48-
return merge(p, (; e_per_area = e_per_area_field))
49-
else
50-
return p
51-
end
52-
end
53-
5440
"""
5541
bucket_init
5642
@@ -140,9 +126,6 @@ function BucketSimulation(
140126
# Initial conditions with no moisture
141127
Y, p, coords = CL.initialize(model)
142128

143-
# Add space in the cache for the energy if energy checks are enabled
144-
p = get_new_cache(p, Y, energy_check)
145-
146129
# Get temperature anomaly function
147130
T_functions = Dict("aquaplanet" => temp_anomaly_aquaplanet, "amip" => temp_anomaly_amip)
148131
haskey(T_functions, land_temperature_anomaly) ||
@@ -262,29 +245,26 @@ Interfacer.get_field(sim::BucketSimulation, ::Val{:surface_temperature}) =
262245
"""
263246
Interfacer.get_field(sim::BucketSimulation, ::Val{:energy})
264247
265-
Extension of Interfacer.get_field that provides the total energy contained in the bucket, including the latent heat due to snow melt.
266-
"""
267-
function Interfacer.get_field(sim::BucketSimulation, ::Val{:energy})
268-
# required by ConservationChecker
269-
e_per_area = sim.integrator.p.e_per_area .= 0
270-
CC.Operators.column_integral_definite!(e_per_area, sim.model.parameters.ρc_soil .* sim.integrator.u.bucket.T)
271-
272-
e_per_area .+=
273-
-LP.LH_f0(sim.model.parameters.earth_param_set) .* LP.ρ_cloud_liq(sim.model.parameters.earth_param_set) .*
274-
sim.integrator.u.bucket.σS
248+
Extension of Interfacer.get_field that provides the total energy contained in the bucket,
249+
computed from the temperature of the bucket and also including the latent heat of fusion
250+
of frozen water in the snow.
275251
276-
return e_per_area
277-
end
252+
This method is required by the ConservationChecker to check energy conservation.
253+
"""
254+
Interfacer.get_field(sim::BucketSimulation, ::Val{:energy}) = sim.integrator.p.bucket.total_energy
278255

279256
"""
280257
Interfacer.get_field(sim::BucketSimulation, ::Val{:water})
281258
282-
Extension of Interfacer.get_field that provides the total water contained in the bucket, including the liquid water in snow.
259+
Extension of Interfacer.get_field that provides the total water contained in the bucket.
260+
The total water contained in the bucket is the sum of the subsurface water storage `W`,
261+
the snow water equivalent `σS`, and surface water content `Ws`.
262+
263+
This method is required by the ConservationChecker to check water conservation.
283264
"""
284265
function Interfacer.get_field(sim::BucketSimulation, ::Val{:water})
285266
ρ_cloud_liq = CL.LP.ρ_cloud_liq(sim.model.parameters.earth_param_set)
286-
return
287-
@. (sim.integrator.u.bucket.σS + sim.integrator.u.bucket.W + sim.integrator.u.bucket.Ws) * ρ_cloud_liq # kg water / m2
267+
return sim.integrator.p.bucket.total_water .* ρ_cloud_liq # kg water / m2
288268
end
289269

290270
function Interfacer.update_field!(sim::BucketSimulation, ::Val{:air_density}, field)

0 commit comments

Comments
 (0)