Skip to content

Commit

Permalink
CLIMAParameters updates
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Feb 5, 2024
1 parent f04c128 commit aaf89f9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[zd_rayleigh]
alias = "zd_rayleigh"
value = 35000.0
type = "float"

[alpha_rayleigh_uh]
alias = "alpha_rayleigh_uh"
value = 0.0
type = "float"
7 changes: 2 additions & 5 deletions test/component_model_tests/eisenman_seaice_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ for FT in (Float32, Float64)
# create a boundary space
boundary_space = TestHelper.create_space(FT)

# thermodynammic parameter set
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
thermo_params = TP.ThermodynamicsParameters{FT}(; pairs...)
# thermodynamic parameter set
thermo_params = TP.ThermodynamicsParameters(FT)

@testset "No net fluxes for FT=$FT" begin
Y, Ya = state_init(params_ice, boundary_space)
Expand Down
5 changes: 1 addition & 4 deletions test/component_model_tests/prescr_seaice_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ for FT in (Float32, Float64)
ice_fraction = Fields.ones(space) .* FT(global_mask)
dt = FT(1.0)

toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TDP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
thermo_params = TDP.ThermodynamicsParameters{FT}(; param_pairs...)
thermo_params = TDP.ThermodynamicsParameters(FT)

additional_cache = (;
F_turb_energy = ClimaCore.Fields.zeros(space),
Expand Down
54 changes: 8 additions & 46 deletions test/flux_calculator_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import ClimaCoupler: Interfacer

import CLIMAParameters as CP
import Thermodynamics as TD
import Thermodynamics.Parameters as TP
import Thermodynamics.Parameters.ThermodynamicsParameters
import SurfaceFluxes as SF
import SurfaceFluxes.Parameters.SurfaceFluxesParameters
import SurfaceFluxes.UniversalFunctions as UF

using StaticArrays
Expand All @@ -43,41 +44,6 @@ function atmos_turbulent_fluxes!(sim::DummySimulation, csf)
sim.cache.flux .= (csf.T_sfc .- sim.state.T) .* sim.cache.κ ./ sim.cache.dz # Eq. 1
end

# Test for the PartitionedStateFluxes() case
# parameter set generated CLIMAParamerers and helper functions from SurfaceFluxes.jl
function create_uf_parameters(toml_dict, ::UF.BusingerType)
FT = CP.float_type(toml_dict)
aliases = ["Pr_0_Businger", "a_m_Businger", "a_h_Businger", "ζ_a_Businger", "γ_Businger"]

pairs = CP.get_parameter_values!(toml_dict, aliases, "UniversalFunctions")
pairs = (; pairs...) # convert to NamedTuple

pairs = (;
Pr_0 = pairs.Pr_0_Businger,
a_m = pairs.a_m_Businger,
a_h = pairs.a_h_Businger,
ζ_a = pairs.ζ_a_Businger,
γ = pairs.γ_Businger,
)
return UF.BusingerParams{FT}(; pairs...)
end

function create_parameters(toml_dict, ufpt)
FT = CP.float_type(toml_dict)

ufp = create_uf_parameters(toml_dict, ufpt)
AUFP = typeof(ufp)

aliases = string.(fieldnames(TD.Parameters.ThermodynamicsParameters))
pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
thermo_params = TD.Parameters.ThermodynamicsParameters{FT}(; pairs...)
TP = typeof(thermo_params)

aliases = ["von_karman_const"]
pairs = CP.get_parameter_values!(toml_dict, aliases, "SurfaceFluxesParameters")
return SF.Parameters.SurfaceFluxesParameters{FT, AUFP, TP}(; pairs..., ufp, thermo_params)
end

# atmos sim object and extensions
struct TestAtmos{P, Y, D, I} <: Interfacer.AtmosModelSimulation
params::P
Expand All @@ -104,16 +70,13 @@ end

function get_thermo_params(sim::TestAtmos)
FT = sim.params.FT
aliases = string.(fieldnames(TP.ThermodynamicsParameters))
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
TP.ThermodynamicsParameters{FT}(; pairs...)
thermo_params = ThermodynamicsParameters(FT)
return thermo_params
end

function get_surface_params(sim::TestAtmos)
FT = sim.params.FT
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
sf_params = create_parameters(toml_dict, UF.BusingerType())
sf_params = SurfaceFluxesParameters(FT, UF.BusingerParams)
return sf_params
end

Expand All @@ -138,7 +101,7 @@ Interfacer.get_field(sim::TestOcean, ::Val{:albedo}) = sim.integrator.p.α

function surface_thermo_state(
sim::TestOcean,
thermo_params::TD.Parameters.ThermodynamicsParameters,
thermo_params::ThermodynamicsParameters,
thermo_state_int,
colidx::Fields.ColumnIndex,
)
Expand Down Expand Up @@ -172,7 +135,7 @@ function Interfacer.update_field!(sim::DummySurfaceSimulation3, ::Val{:∂F_turb
end
function surface_thermo_state(
sim::DummySurfaceSimulation3,
thermo_params::TD.Parameters.ThermodynamicsParameters,
thermo_params::ThermodynamicsParameters,
thermo_state_int,
colidx::Fields.ColumnIndex,
)
Expand Down Expand Up @@ -325,8 +288,7 @@ for FT in (Float32, Float64)
end

@testset "get_surface_params for FT=$FT" begin
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
sf_params = create_parameters(toml_dict, UF.BusingerType())
sf_params = SurfaceFluxesParameters(FT, UF.BusingerParams)

@test get_surface_params(TestAtmos((; FT = FT), [], [], [])) == sf_params
sim = DummySimulation([], [])
Expand Down
5 changes: 1 addition & 4 deletions test/interfacer_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ for FT in (Float32, Float64)

# test for a simple generic surface model
@testset "get_field for a SurfaceStub" begin
toml_dict = CP.create_toml_dict(FT; dict_type = "alias")
aliases = string.(fieldnames(TDP.ThermodynamicsParameters))
param_pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics")
thermo_params = TDP.ThermodynamicsParameters{FT}(; param_pairs...)
thermo_params = TDP.ThermodynamicsParameters(FT)

stub = SurfaceStub((;
area_fraction = FT(1),
Expand Down
1 change: 0 additions & 1 deletion toml/default_coarse.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[C_E]
alias = "C_E"
value = 0.044
type = "float"

0 comments on commit aaf89f9

Please sign in to comment.