Skip to content

Commit

Permalink
experiments, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Jul 5, 2024
1 parent 95c98e2 commit f86cc58
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 83 deletions.
9 changes: 1 addition & 8 deletions docs/tutorials/integrated/soil_canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,11 @@ soilco2_sources = (MicrobeProduction{FT}(),);

soilco2_boundary_conditions = (; top = soilco2_top_bc, bottom = soilco2_bot_bc);

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
atmos,
);

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = soil_domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
);

# Next we need to set up the [`CanopyModel`](https://clima.github.io/ClimaLand.jl/dev/APIs/canopy/Canopy/#Canopy-Model-Structs).
Expand Down Expand Up @@ -306,7 +299,7 @@ canopy_model_args = (; parameters = shared_params, domain = canopy_domain);
# atmospheric and radiative flux conditions from the observations at the Ozark
# site as was done in the previous tutorial.

land_input = (atmos = atmos, radiation = radiation)
land_input = (atmos = atmos, radiation = radiation, soil_organic_carbon = Csom)

land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
Expand Down
14 changes: 6 additions & 8 deletions experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,11 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
soilco2_boundary_conditions =
(; top = soilco2_top_bc, bottom = soilco2_bot_bc)

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
atmos,
)

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
)

# Now we set up the canopy model, which we set up by component:
Expand Down Expand Up @@ -538,7 +531,12 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
)

# Integrated plant hydraulics and soil model
land_input = (atmos = atmos, radiation = radiation, runoff = runoff_model)
land_input = (
atmos = atmos,
radiation = radiation,
runoff = runoff_model,
soil_organic_carbon = Csom,
)
land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
Expand Down
9 changes: 1 addition & 8 deletions experiments/integrated/fluxnet/ozark_pft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,11 @@ soilco2_sources = (MicrobeProduction{FT}(),)

soilco2_boundary_conditions = (; top = soilco2_top_bc, bottom = soilco2_bot_bc)

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
atmos,
)

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = soil_domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
)

# Now we set up the canopy model, which we set up by component:
Expand Down Expand Up @@ -242,7 +235,7 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
canopy_model_args = (; parameters = shared_params, domain = canopy_domain)

# Integrated plant hydraulics and soil model
land_input = (atmos = atmos, radiation = radiation)
land_input = (atmos = atmos, radiation = radiation, soil_organic_carbon = Csom)
land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
Expand Down
9 changes: 1 addition & 8 deletions experiments/integrated/fluxnet/run_fluxnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,11 @@ soilco2_sources = (MicrobeProduction{FT}(),)

soilco2_boundary_conditions = (; top = soilco2_top_bc, bottom = soilco2_bot_bc)

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
atmos,
)

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = soil_domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
)

# Now we set up the canopy model, which we set up by component:
Expand Down Expand Up @@ -199,7 +192,7 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
canopy_model_args = (; parameters = shared_params, domain = canopy_domain)

# Integrated plant hydraulics and soil model
land_input = (atmos = atmos, radiation = radiation)
land_input = (atmos = atmos, radiation = radiation, soil_organic_carbon = Csom)
land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
Expand Down
14 changes: 6 additions & 8 deletions experiments/integrated/global/global_soil_canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,11 @@ soilco2_sources = (Soil.Biogeochemistry.MicrobeProduction{FT}(),)

soilco2_boundary_conditions = (; top = soilco2_top_bc, bottom = soilco2_bot_bc)

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
atmos,
)

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
)

# Now we set up the canopy model, which we set up by component:
Expand Down Expand Up @@ -295,7 +288,12 @@ canopy_model_args = (;
)

# Integrated plant hydraulics and soil model
land_input = (atmos = atmos, radiation = radiation, runoff = runoff_model)
land_input = (
atmos = atmos,
radiation = radiation,
runoff = runoff_model,
soil_organic_carbon = Csom,
)
land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,11 @@ soilco2_sources = (MicrobeProduction{FT}(),)

soilco2_boundary_conditions = (; top = soilco2_top_bc, bottom = soilco2_bot_bc)

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
atmos,
)

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = soil_domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
)

# Now we set up the canopy model, which we set up by component:
Expand Down Expand Up @@ -180,7 +173,7 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
canopy_model_args = (; parameters = shared_params, domain = canopy_domain)

# Integrated plant hydraulics and soil model
land_input = (atmos = atmos, radiation = radiation)
land_input = (atmos = atmos, radiation = radiation, soil_organic_carbon = Csom)
land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
Expand Down
9 changes: 1 addition & 8 deletions experiments/integrated/performance/profile_allocations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,11 @@ soilco2_sources = (MicrobeProduction{FT}(),)

soilco2_boundary_conditions = (; top = soilco2_top_bc, bottom = soilco2_bot_bc)

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
atmos,
)

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = soil_domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
)

# Now we set up the canopy model, which we set up by component:
Expand Down Expand Up @@ -315,7 +308,7 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
canopy_model_args = (; parameters = shared_params, domain = canopy_domain)

# Integrated plant hydraulics and soil model
land_input = (atmos = atmos, radiation = radiation)
land_input = (atmos = atmos, radiation = radiation, soil_organic_carbon = Csom)
land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
Expand Down
2 changes: 1 addition & 1 deletion experiments/standalone/Biogeochemistry/experiment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ for (FT, tf) in ((Float32, 2 * dt), (Float64, tf))
)

# Create integrated model instance
land_args = (atmos, Csom)
land_args = (atmos = atmos, soil_organic_carbon = Csom)
model = LandSoilBiogeochemistry{FT}(;
land_args = land_args,
soil_args = soil_args,
Expand Down
13 changes: 5 additions & 8 deletions lib/ClimaLandSimulations/src/Fluxnet/run_fluxnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,11 @@ function run_fluxnet(
soilco2_boundary_conditions =
(; top = soilco2_top_bc, bottom = CO2 = soilco2_bot_bc)

soilco2_drivers = Soil.Biogeochemistry.SoilDrivers(
Soil.Biogeochemistry.PrognosticMet{FT}(),
Soil.Biogeochemistry.PrescribedSOC{FT}(Csom),
drivers.atmos,
)

soilco2_args = (;
boundary_conditions = soilco2_boundary_conditions,
sources = soilco2_sources,
domain = soil_domain,
parameters = soilco2_ps,
drivers = soilco2_drivers,
)

# Now we set up the canopy model, which we set up by component:
Expand Down Expand Up @@ -218,7 +211,11 @@ function run_fluxnet(
(; parameters = shared_params, domain = domain.canopy_domain)

# Integrated plant hydraulics and soil model
land_input = (atmos = drivers.atmos, radiation = drivers.radiation)
land_input = (
atmos = drivers.atmos,
radiation = drivers.radiation,
soil_organic_carbon = Csom,
)
land = SoilCanopyModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
Expand Down
20 changes: 11 additions & 9 deletions src/integrated/soil_canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function SoilCanopyModel{FT}(;
MM <: Soil.Biogeochemistry.SoilCO2Model{FT},
}

(; atmos, radiation) = land_args
(; atmos, radiation, soil_organic_carbon) = land_args
# These should always be set by the constructor.
sources = (RootExtraction{FT}(), Soil.PhaseChange{FT}())
if :runoff propertynames(land_args)
Expand Down Expand Up @@ -116,7 +116,7 @@ function SoilCanopyModel{FT}(;
)

transpiration = Canopy.PlantHydraulics.DiagnosticTranspiration{FT}()
soil_driver = PrognosticSoil{typeof(soil.parameters.PAR_albedo)}(
canopy_soil_driver = PrognosticSoil{typeof(soil.parameters.PAR_albedo)}(
soil.parameters.PAR_albedo,
soil.parameters.NIR_albedo,
)
Expand All @@ -142,7 +142,7 @@ function SoilCanopyModel{FT}(;
energy = canopy_component_types.energy(
canopy_component_args.energy.parameters,
),
soil_driver = soil_driver,
soil_driver = canopy_soil_driver,
atmos = atmos,
radiation = radiation,
canopy_model_args...,
Expand All @@ -165,18 +165,20 @@ function SoilCanopyModel{FT}(;
transpiration = transpiration,
canopy_component_args.hydraulics...,
),
soil_driver = soil_driver,
soil_driver = canopy_soil_driver,
atmos = atmos,
radiation = radiation,
canopy_model_args...,
)
end

soilco2 = Soil.Biogeochemistry.SoilCO2Model{FT}(; soilco2_args...)

if !(soilco2_args.drivers.met isa PrognosticMet)
throw(AssertionError("Must be of type PrognosticMet."))
end
co2_prognostic_soil = Soil.Biogeochemistry.PrognosticMet(soil.parameters)
soil_co2_drivers = Soil.Biogeochemistry.SoilDrivers(
co2_prognostic_soil,
Soil.Biogeochemistry.PrescribedSOC{FT}(soil_organic_carbon),
atmos,
)
soilco2 = soil_co2_model(; soilco2_args..., drivers = soil_co2_drivers)

return SoilCanopyModel{FT, typeof(soilco2), typeof(soil), typeof(canopy)}(
soilco2,
Expand Down
2 changes: 1 addition & 1 deletion src/integrated/soil_energy_hydrology_biogeochemistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function LandSoilBiogeochemistry{FT}(;
soilco2_args::NamedTuple = (;),
) where {FT}

(atmos, Csom) = land_args
(; atmos, soil_organic_carbon) = land_args
soil = Soil.EnergyHydrology{FT}(;
soil_args..., # soil_args must have sources, boundary_conditions, domain, parameters
)
Expand Down
16 changes: 8 additions & 8 deletions src/standalone/Soil/Biogeochemistry/Biogeochemistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct SoilCO2Model{FT, PS, D, BC, S, DT} <:
"A tuple of sources, each of type AbstractSource"
sources::S
"Drivers"
driver::DT
drivers::DT
end


Expand Down Expand Up @@ -411,14 +411,14 @@ function ClimaLand.make_update_aux(model::SoilCO2Model)
function update_aux!(p, Y, t)
params = model.parameters
z = model.domain.fields.z
T_soil = soil_temperature(model.driver.met, p, Y, t, z)
θ_l = soil_moisture(model.driver.met, p, Y, t, z)
Csom = soil_SOM_C(model.driver.soc, p, Y, t, z)
T_soil = soil_temperature(model.drivers.met, p, Y, t, z)
θ_l = soil_moisture(model.drivers.met, p, Y, t, z)
Csom = soil_SOM_C(model.drivers.soc, p, Y, t, z)
P_sfc = p.drivers.P
θ_w = θ_l
ν = model.driver.met.ν
θ_a100 = model.driver.met.θ_a100
b = model.driver.met.b
ν = model.drivers.met.ν
θ_a100 = model.drivers.met.θ_a100
b = model.drivers.met.b

p.soilco2.D .=
co2_diffusivity.(T_soil, θ_w, P_sfc, θ_a100, b, ν, params)
Expand Down Expand Up @@ -592,7 +592,7 @@ function ClimaLand.boundary_flux(
end

function ClimaLand.get_drivers(model::SoilCO2Model)
return (model.driver.atmos, nothing)
return (model.drivers.atmos, nothing)
end

Base.broadcastable(ps::SoilCO2ModelParameters) = tuple(ps)
Expand Down

0 comments on commit f86cc58

Please sign in to comment.