Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alphabetize names, standardize symbols for parametric types #907

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions experiments/integrated/global/global_soil_canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ exp_tendency! = make_exp_tendency(land);
imp_tendency! = ClimaLand.make_imp_tendency(land);
jacobian! = ClimaLand.make_jacobian(land);
set_initial_cache!(p, Y, t0)
stepper = CTS.ARS343()
stepper = CTS.ARS111()
ode_algo = CTS.IMEXAlgorithm(
stepper,
CTS.NewtonsMethod(
max_iters = 1,
update_j = CTS.UpdateEvery(CTS.NewTimeStep),
max_iters = 3,
update_j = CTS.UpdateEvery(CTS.NewNewtonIteration),
),
)

Expand Down Expand Up @@ -286,6 +286,11 @@ for short_name in ClimaAnalysis.available_vars(simdir)
viz.heatmap2D_on_globe!(
fig,
ClimaAnalysis.slice(var, time = t; kwargs...),
mask = viz.oceanmask(),
more_kwargs = Dict(
:mask => ClimaAnalysis.Utils.kwargs(color = :white),
:plot => ClimaAnalysis.Utils.kwargs(rasterize = true),
),
)
CairoMakie.save(joinpath(outdir, "$short_name.png"), fig)
end
Expand Down
73 changes: 36 additions & 37 deletions src/integrated/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@ export LandModel
"""
struct LandModel{
FT,
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
SM <: Soil.EnergyHydrology{FT},
VM <: Canopy.CanopyModel{FT},
CM <: Canopy.CanopyModel{FT},
SnM <: Snow.SnowModel{FT},
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
} <: AbstractLandModel{FT}
"The soil microbe model to be used"
soilco2::MM
"The soil model to be used"
soil::SM
"The canopy model to be used"
canopy::VM
canopy::CM
"The snow model to be used"
snow::SnM
end
"The soil model to be used"
soil::SM
"The soil microbe model to be used"
soilco2::MM


A concrete type of land model used for simulating systems with
soil, canopy, snow, soilco2.
$(DocStringExtensions.FIELDS)
"""
struct LandModel{
FT,
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
SM <: Soil.EnergyHydrology{FT},
VM <: Canopy.CanopyModel{FT},
CM <: Canopy.CanopyModel{FT},
SnM <: Snow.SnowModel{FT},
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
} <: AbstractLandModel{FT}
"The soil microbe model to be used"
soilco2::MM
"The soil model to be used"
soil::SM
"The canopy model to be used"
canopy::VM
canopy::CM
"The snow model to be used"
snow::SnM
"The soil model to be used"
soil::SM
"The soil microbe model to be used"
soilco2::MM
end



"""
LandModel{FT}(;
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
land_args::NamedTuple = (;),
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
canopy_component_types::NamedTuple = (;),
canopy_component_args::NamedTuple = (;),
canopy_model_args::NamedTuple = (;),
snow_model_type::Type{SnM},
snow_args::NamedTuple = (;),
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
) where {
FT,
SnM <: Snow.SnowModel,
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
SnM <: Snow.SnowModel{FT}
}

A constructor for the `LandModel`, which takes in the concrete model
Expand All @@ -68,23 +68,22 @@ forward in time, including boundary conditions, source terms, and interaction
terms.
"""
function LandModel{FT}(;
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
land_args::NamedTuple = (;),
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
canopy_component_types::NamedTuple = (;),
canopy_component_args::NamedTuple = (;),
canopy_model_args::NamedTuple = (;),
snow_model_type::Type{SnM},
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
snow_args::NamedTuple = (;),
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
) where {
FT,
SnM <: Snow.SnowModel,
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
SnM <: Snow.SnowModel,
}

(; atmos, radiation, soil_organic_carbon) = land_args
# These should always be set by the constructor.
prognostic_land_components = (:canopy, :snow, :soil, :soilco2)
Expand Down Expand Up @@ -175,7 +174,7 @@ function LandModel{FT}(;
)
soilco2 = soilco2_type(; soilco2_args..., drivers = soilco2_drivers)

args = (soilco2, soil, canopy, snow)
args = (canopy, snow, soil, soilco2)
return LandModel{FT, typeof.(args)...}(args...)
end

Expand Down Expand Up @@ -246,13 +245,13 @@ lsm_aux_domain_names(m::LandModel) = (

"""
make_update_boundary_fluxes(
land::LandModel{FT, MM, SM, RM, SnM},
land::LandModel{FT, CM, SnM, SM, MM},
) where {
FT,
CM <: Canopy.CanopyModel{FT},
SnM <: Snow.SnowModel{FT},
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
SM <: Soil.RichardsModel{FT},
RM <: Canopy.CanopyModel{FT}
SnM <: Snow.SnowModel{FT}
}

A method which makes a function; the returned function
Expand All @@ -264,13 +263,13 @@ This function is called each ode function evaluation, prior to the tendency func
evaluation.
"""
function make_update_boundary_fluxes(
land::LandModel{FT, MM, SM, RM, SnM},
land::LandModel{FT, CM, SnM, SM, MM},
) where {
FT,
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
SM <: Soil.EnergyHydrology{FT},
RM <: Canopy.CanopyModel{FT},
CM <: Canopy.CanopyModel{FT},
SnM <: Snow.SnowModel{FT},
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
}
update_soil_bf! = make_update_boundary_fluxes(land.soil)
update_soilco2_bf! = make_update_boundary_fluxes(land.soilco2)
Expand Down
71 changes: 33 additions & 38 deletions src/integrated/soil_canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,48 @@ export SoilCanopyModel
"""
struct SoilCanopyModel{
FT,
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
CM <: Canopy.CanopyModel{FT},
SM <: Soil.EnergyHydrology{FT},
VM <: Canopy.CanopyModel{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
} <: AbstractLandModel{FT}
"The soil microbe model to be used"
soilco2::MM
"The canopy model to be used"
canopy::CM
"The soil model to be used"
soil::SM
"The canopy model to be used"
canopy::VM
end
"The soil microbe model to be used"
soilco2::MM

A concrete type of land model used for simulating systems with a
canopy and a soil component.
$(DocStringExtensions.FIELDS)
"""
struct SoilCanopyModel{
FT,
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
CM <: Canopy.CanopyModel{FT},
SM <: Soil.EnergyHydrology{FT},
VM <: Canopy.CanopyModel{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
} <: AbstractLandModel{FT}
"The soil microbe model to be used"
soilco2::MM
"The canopy model to be used"
canopy::CM
"The soil model to be used"
soil::SM
"The canopy model to be used"
canopy::VM
"The soil microbe model to be used"
soilco2::MM
end



"""
SoilCanopyModel{FT}(;
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
land_args::NamedTuple = (;),
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
canopy_component_types::NamedTuple = (;),
canopy_component_args::NamedTuple = (;),
canopy_model_args::NamedTuple = (;),
) where {
land_args::NamedTuple = (;),
canopy_component_types::NamedTuple = (;),
canopy_component_args::NamedTuple = (;),
canopy_model_args::NamedTuple = (;),
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
) where {
FT,
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
Expand All @@ -59,14 +58,14 @@ forward in time, including boundary conditions, source terms, and interaction
terms.
"""
function SoilCanopyModel{FT}(;
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
land_args::NamedTuple = (;),
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
canopy_component_types::NamedTuple = (;),
canopy_component_args::NamedTuple = (;),
canopy_model_args::NamedTuple = (;),
soil_model_type::Type{SM},
soil_args::NamedTuple = (;),
soilco2_type::Type{MM},
soilco2_args::NamedTuple = (;),
) where {
FT,
SM <: Soil.EnergyHydrology{FT},
Expand Down Expand Up @@ -147,12 +146,8 @@ function SoilCanopyModel{FT}(;
atmos,
)
soilco2 = soilco2_type(; soilco2_args..., drivers = soilco2_drivers)

return SoilCanopyModel{FT, typeof(soilco2), typeof(soil), typeof(canopy)}(
soilco2,
soil,
canopy,
)
args = (canopy, soil, soilco2)
return SoilCanopyModel{FT, typeof.(args)...}(args...)
end

"""
Expand Down Expand Up @@ -210,12 +205,12 @@ lsm_aux_domain_names(m::SoilCanopyModel) = (

"""
make_update_boundary_fluxes(
land::SoilCanopyModel{FT, MM, SM, RM},
land::SoilCanopyModel{FT, CM, SM, MM}
) where {
FT,
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
CM <: Canopy.CanopyModel{FT}
SM <: Soil.RichardsModel{FT},
RM <: Canopy.CanopyModel{FT}
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
}

A method which makes a function; the returned function
Expand All @@ -227,12 +222,12 @@ This function is called each ode function evaluation, prior to the tendency func
evaluation.
"""
function make_update_boundary_fluxes(
land::SoilCanopyModel{FT, MM, SM, RM},
land::SoilCanopyModel{FT, CM, SM, MM},
) where {
FT,
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
CM <: Canopy.CanopyModel{FT},
SM <: Soil.EnergyHydrology{FT},
RM <: Canopy.CanopyModel{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
}
update_soil_bf! = make_update_boundary_fluxes(land.soil)
update_soilco2_bf! = make_update_boundary_fluxes(land.soilco2)
Expand Down
15 changes: 8 additions & 7 deletions src/integrated/soil_energy_hydrology_biogeochemistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@ export LandSoilBiogeochemistry, PrognosticMet
"""
struct LandSoilBiogeochemistry{
FT,
SEH <: Soil.EnergyHydrology{FT},
SB <: Soil.Biogeochemistry.SoilCO2Model{FT},
SM <: Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
} <: AbstractLandModel{FT}

A concrete type of land model used for simulating systems with a
soil energy, hydrology, and biogeochemistry component.
$(DocStringExtensions.FIELDS)"""
struct LandSoilBiogeochemistry{
FT,
SEH <: Soil.Soil.EnergyHydrology{FT},
SB <: Soil.Biogeochemistry.SoilCO2Model{FT},
SM <: Soil.Soil.EnergyHydrology{FT},
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
} <: AbstractLandModel{FT}
"The soil model"
soil::SEH
soil::SM
"The biochemistry model"
soilco2::SB
soilco2::MM
end

"""
LandSoilBiogeochemistry{FT}(;
land_args::NamedTuple,
soil_args::NamedTuple = (;),
biogeochemistry_args::NamedTuple = (;),
soilco2_args::NamedTuple = (;),
) where {FT}
A constructor for the `LandSoilBiogeochemistry` model, which takes in
the required arguments for each component, constructs those models,
Expand Down
Loading
Loading