@@ -37,20 +37,6 @@ struct BucketSimulation{M <: CL.Bucket.BucketModel, I <: SciMLBase.AbstractODEIn
37
37
output_writer:: OW
38
38
end
39
39
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
-
54
40
"""
55
41
bucket_init
56
42
@@ -140,9 +126,6 @@ function BucketSimulation(
140
126
# Initial conditions with no moisture
141
127
Y, p, coords = CL. initialize (model)
142
128
143
- # Add space in the cache for the energy if energy checks are enabled
144
- p = get_new_cache (p, Y, energy_check)
145
-
146
129
# Get temperature anomaly function
147
130
T_functions = Dict (" aquaplanet" => temp_anomaly_aquaplanet, " amip" => temp_anomaly_amip)
148
131
haskey (T_functions, land_temperature_anomaly) ||
@@ -262,29 +245,26 @@ Interfacer.get_field(sim::BucketSimulation, ::Val{:surface_temperature}) =
262
245
"""
263
246
Interfacer.get_field(sim::BucketSimulation, ::Val{:energy})
264
247
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.
275
251
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
278
255
279
256
"""
280
257
Interfacer.get_field(sim::BucketSimulation, ::Val{:water})
281
258
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.
283
264
"""
284
265
function Interfacer. get_field (sim:: BucketSimulation , :: Val{:water} )
285
266
ρ_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
288
268
end
289
269
290
270
function Interfacer. update_field! (sim:: BucketSimulation , :: Val{:air_density} , field)
0 commit comments