Skip to content

Commit

Permalink
debugging eisenman
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed May 20, 2024
1 parent a95ce1b commit 25d12a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions experiments/ClimaEarth/components/ocean/eisenman_seaice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function solve_eisenman_model!(Y, Ya, p, thermo_params, Δt)

# local
F_atm = @. F_turb + F_rad
F_atmo∂T_sfc = get_∂F_rad_energy∂T_sfc.(T_sfc, Ref(p_i)) .+ ∂F_turb_energy∂T_sfc
F_atmos∂T_sfc = get_∂F_rad_energy∂T_sfc(T_sfc, p_i) .+ ∂F_turb_energy∂T_sfc

# ice thickness and mixed layer temperature changes due to atmosphereic and ocean fluxes
ice_covered = parent(h_ice)[1] > 0
Expand Down Expand Up @@ -308,7 +308,7 @@ function solve_eisenman_model!(Y, Ya, p, thermo_params, Δt)
h = @. h_ice + Δh_ice
F_conductive = @. k_ice / h * (T_base - T_sfc)
numerator = @. -F_atm + F_conductive
denominator = @. k_ice / h +F_atmo∂T_sfc
denominator = @. k_ice / h +F_atmos∂T_sfc
ΔT_sfc = @. numerator / denominator
surface_melting = (parent(T_sfc .+ ΔT_sfc)[1] > T_freeze)
if surface_melting
Expand Down
11 changes: 6 additions & 5 deletions test/component_model_tests/eisenman_seaice_tests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Test: @test, @testset
import ClimaCore as CC
import ClimaParams as CP
import Thermodynamics as TD
import Thermodynamics.Parameters as TP
import Thermodynamics.Parameters as TDP
import ClimaCoupler
import ClimaCoupler: Interfacer, Regridder, TestHelper

Expand All @@ -19,7 +20,7 @@ for FT in (Float32, Float64)
boundary_space = TestHelper.create_space(FT)

# thermodynamic parameter set
thermo_params = TP.ThermodynamicsParameters(FT)
thermo_params = TDP.ThermodynamicsParameters(FT)

@testset "No net fluxes for FT=$FT" begin
Y, Ya = state_init(params_ice, boundary_space)
Expand All @@ -32,7 +33,7 @@ for FT in (Float32, Float64)
Y.T_ml .= params_ice.T_base

# no atmos fluxes, F_a
Ya.∂F_turb_energy∂T_sfc .= .-get_∂F_rad_energy∂T_sfc.(Y.T_sfc, Ref(params_ice)) # ∂F_turb_energy∂T_sfc + ∂F_rad_energy∂T_sfc = 0
Ya.∂F_turb_energy∂T_sfc .= .-get_∂F_rad_energy∂T_sfc(Y.T_sfc, params_ice) # ∂F_turb_energy∂T_sfc + ∂F_rad_energy∂T_sfc = 0
Ya.F_rad .= 0
Ya.F_turb .= 0

Expand Down Expand Up @@ -247,7 +248,7 @@ for FT in (Float32, Float64)
Y.T_sfc .= params_ice.T_base

# zero atmos fluxes and their derivatives
Ya.∂F_turb_energy∂T_sfc .= .-get_∂F_rad_energy∂T_sfc.(Y.T_sfc, Ref(params_ice)) # ∂F_turb_energy∂T_sfc + ∂F_rad_energy∂T_sfc = 0
Ya.∂F_turb_energy∂T_sfc .= .-get_∂F_rad_energy∂T_sfc(Y.T_sfc, params_ice) # ∂F_turb_energy∂T_sfc + ∂F_rad_energy∂T_sfc = 0
Ya.F_turb .= 0
Ya.F_rad .= 0

Expand Down Expand Up @@ -279,7 +280,7 @@ for FT in (Float32, Float64)
T_ml_0 = deepcopy(Y.T_ml)

# no atmos fluxes or their derivatives
Ya.∂F_turb_energy∂T_sfc .= .-get_∂F_rad_energy∂T_sfc.(Y.T_sfc, Ref(params_ice)) # ∂F_turb_energy∂T_sfc + ∂F_rad_energy∂T_sfc = 0
Ya.∂F_turb_energy∂T_sfc .= .-get_∂F_rad_energy∂T_sfc(Y.T_sfc, params_ice) # ∂F_turb_energy∂T_sfc + ∂F_rad_energy∂T_sfc = 0
Ya.F_turb .= 0
Ya.F_rad .= 0

Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
@safetestset "FieldExchanger tests" begin
include("field_exchanger_tests.jl")
end
gpu_broken || @safetestset "FluxCalculator tests" begin
@safetestset "FluxCalculator tests" begin
include("flux_calculator_tests.jl")
end
gpu_broken || @safetestset "Diagnostics tests" begin
Expand All @@ -54,7 +54,7 @@ end
@safetestset "component model test: prescr. sea ice" begin
include("component_model_tests/prescr_seaice_tests.jl")
end
gpu_broken || @safetestset "component model test: eisenman sea ice" begin
@safetestset "component model test: eisenman sea ice" begin
include("component_model_tests/eisenman_seaice_tests.jl")
end
@safetestset "component model test: slab ocean" begin
Expand Down

0 comments on commit 25d12a9

Please sign in to comment.