Skip to content

Commit 2b1bdf4

Browse files
committed
zero out tendencies
1 parent 79351f2 commit 2b1bdf4

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

experiments/ClimaEarth/components/ocean/prescr_seaice.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,13 @@ function ice_rhs!(dY, Y, p, t)
270270

271271
# Calculate the conductive flux, and set it to zero if the area fraction is zero
272272
F_conductive = @. params.k_ice / (params.h) * (params.T_base - Y.T_sfc) # fluxes are defined to be positive when upward
273-
@. F_conductive = ifelse(p.area_fraction 0, zero(F_conductive), F_conductive)
274273

275274
rhs = @. (-p.F_turb_energy - p.F_radiative + F_conductive) /
276275
(params.h * params.ρ * params.c)
276+
277+
# Zero out tendencies where there is no ice, so that ice temperature remains constant there
278+
@. rhs = ifelse(p.area_fraction 0, zero(rhs), rhs)
279+
277280
# If tendencies lead to temperature above freezing, set temperature to freezing
278281
@. dY.T_sfc = min(rhs, (params.T_freeze - Y.T_sfc) / float(p.dt))
279282
end

experiments/ClimaEarth/components/ocean/slab_ocean.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ function slab_ocean_rhs!(dY, Y, cache, t)
199199
p, F_turb_energy, F_radiative = cache
200200
rhs = @. -(F_turb_energy + F_radiative) / (p.h * p.ρ * p.c)
201201

202+
# Zero out tendencies where there is no ocean, so that temperature remains constant there
203+
@. rhs = ifelse(cache.area_fraction 0, zero(rhs), rhs)
204+
202205
# Note that the area fraction has already been applied to the fluxes,
203206
# so we don't need to multiply by it here.
204207
@. dY.T_sfc = rhs * p.evolving_switch

experiments/ClimaEarth/test/component_model_tests/prescr_seaice_tests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ for FT in (Float32, Float64)
7171
# check that nothing changes with no fluxes (zero conduction when T_base == initial T_sfc)
7272
T_base_eq = IceSlabParameters{FT}().T_freeze - FT(5.0)
7373
dY, Y, p = test_sea_ice_rhs(T_base = T_base_eq)
74-
@test all([i for i in extrema(dY)] .≈ [FT(0.0), FT(0.0)])
74+
@test all(T -> T == FT(0), Array(parent(dY.T_sfc)))
7575

7676
# check expected dT due to radiative flux only (again set T_base == initial T_sfc)
7777
dY, Y, p = test_sea_ice_rhs(F_radiative = 1.0, T_base = T_base_eq)
7878
dT_expected = -1.0 / (p.params.h * p.params.ρ * p.params.c)
79-
@test all(extrema(dY) .≈ FT(dT_expected))
79+
@test all(T -> T == FT(0) || T dT_expected, Array(parent(dY.T_sfc)))
8080

8181
# check that tendency will not result in above freezing T
8282
dY, Y, p = test_sea_ice_rhs(F_radiative = 0.0, T_base = 330.0) # Float32 requires a large number here!

0 commit comments

Comments
 (0)