Skip to content

Commit

Permalink
generalize_drivers, organic carbon driver
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Jul 15, 2024
1 parent 2c7efd9 commit d5521a5
Show file tree
Hide file tree
Showing 45 changed files with 266 additions and 188 deletions.
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ ClimaLand.jl Release Notes

main
--------
- PR[#690] Use the soil parameters in creating the biogeochemistry SoilMet driver for consistency.
- Use the soil parameters in creating the biogeochemistry SoilMet driver for consistency.
PR[#690](https://github.com/CliMA/ClimaLand.jl/pull/690)
- ![][badge-💥breaking] Generalize our forcing ``drivers" to include prescribed soil organic carbon
PR[#692](https://github.com/CliMA/ClimaLand.jl/pull/692)
- Add a long run with diagnostics
PR[#688](https://github.com/CliMA/ClimaLand.jl/pull/688)

v0.13.0
--------
- NOTE: the breaking PR below was merged by accident in v0.12.5
Expand Down
1 change: 0 additions & 1 deletion docs/src/APIs/SoilBiogeochemistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ClimaLand.Soil.Biogeochemistry.AtmosCO2StateBC
ClimaLand.Soil.Biogeochemistry.AbstractSoilDriver
ClimaLand.Soil.Biogeochemistry.SoilDrivers
ClimaLand.Soil.Biogeochemistry.PrescribedMet
ClimaLand.Soil.Biogeochemistry.PrescribedSOC
```

## Functions of State
Expand Down
1 change: 1 addition & 0 deletions docs/src/APIs/shared_utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ ClimaLand.get_drivers
ClimaLand.PrescribedAtmosphere
ClimaLand.PrescribedPrecipitation
ClimaLand.PrescribedRadiativeFluxes
ClimaLand.PrescribedSoilOrganicCarbon
ClimaLand.CoupledAtmosphere
ClimaLand.CoupledRadiativeFluxes
ClimaLand.AbstractAtmosphericDrivers
Expand Down
5 changes: 3 additions & 2 deletions docs/tutorials/integrated/soil_canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}
soilco2_ps = SoilCO2ModelParameters(FT);

# soil microbes args
Csom = (z, t) -> eltype(z)(5); # kg C m⁻³, this is a guess, not measured at the site
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
soilco2_bot_bc = Soil.Biogeochemistry.SoilCO2StateBC((p, t) -> 0.0);
Expand Down Expand Up @@ -390,7 +390,8 @@ sv = (;
saveval = Array{NamedTuple}(undef, length(saveat)),
)
saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
updateat = Array(t0:1800:tf)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb);
Expand Down
3 changes: 2 additions & 1 deletion docs/tutorials/standalone/Bucket/bucket_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ saved_values = (;
);
saving_cb = ClimaLand.NonInterpSavingCallback(saved_values, saveat);
updateat = copy(saveat)
updatefunc = ClimaLand.make_update_drivers(bucket_atmos, bucket_rad)
model_drivers = ClimaLand.get_drivers(model)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb)

Expand Down
3 changes: 2 additions & 1 deletion docs/tutorials/standalone/Canopy/canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat);
# Create the callback function which updates the forcing variables,
# or drivers.
updateat = Array(t0:1800:tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(canopy)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb);

Expand Down
3 changes: 2 additions & 1 deletion docs/tutorials/standalone/Soil/evaporation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ sv = (;
)
saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
updateat = deepcopy(saveat)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(soil)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb);

Expand Down
6 changes: 4 additions & 2 deletions docs/tutorials/standalone/Soil/evaporation_gilat_loess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ sv = (;
)
saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
updateat = deepcopy(saveat)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(soil)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb)
sol = SciMLBase.solve(prob, ode_algo; dt = dt, callback = cb, saveat = saveat)
Expand Down Expand Up @@ -315,7 +316,8 @@ sv = (;
)
saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
updateat = deepcopy(saveat)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(soil)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb)
sol_no_drainage =
Expand Down
3 changes: 2 additions & 1 deletion docs/tutorials/standalone/Soil/sublimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ sv = (;
)
saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
updateat = deepcopy(saveat)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(soil)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb);

Expand Down
3 changes: 2 additions & 1 deletion experiments/benchmarks/bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ function setup_prob(t0, tf, Δt; nelements = (100, 10))
p,
)
updateat = collect(t0:(3Δt):tf)
updatefunc = ClimaLand.make_update_drivers(bucket_atmos, bucket_rad)
drivers = ClimaLand.get_drivers(model)
updatefunc = ClimaLand.make_update_drivers(drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb)

Expand Down
17 changes: 9 additions & 8 deletions experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
soil_params_mask = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"vGalpha_map_gupta_etal2020_2.5x2.5x4.nc",
"vGalpha_map_gupta_etal2020_1.0x1.0x4.nc",
),
"α",
subsurface_space;
Expand All @@ -219,7 +219,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
vg_α = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"vGalpha_map_gupta_etal2020_2.5x2.5x4.nc",
"vGalpha_map_gupta_etal2020_1.0x1.0x4.nc",
),
"α",
subsurface_space;
Expand All @@ -229,7 +229,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
vg_n = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"vGn_map_gupta_etal2020_2.5x2.5x4.nc",
"vGn_map_gupta_etal2020_1.0x1.0x4.nc",
),
"n",
subsurface_space;
Expand All @@ -251,7 +251,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
θ_r = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"residual_map_gupta_etal2020_2.5x2.5x4.nc",
"residual_map_gupta_etal2020_1.0x1.0x4.nc",
),
"θ_r",
subsurface_space;
Expand All @@ -262,7 +262,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
ν = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"porosity_map_gupta_etal2020_2.5x2.5x4.nc",
"porosity_map_gupta_etal2020_1.0x1.0x4.nc",
),
"ν",
subsurface_space;
Expand All @@ -272,7 +272,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
K_sat = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"ksat_map_gupta_etal2020_2.5x2.5x4.nc",
"ksat_map_gupta_etal2020_1.0x1.0x4.nc",
),
"Ksat",
subsurface_space;
Expand Down Expand Up @@ -409,7 +409,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}

# soil microbes args
Csom = (z, t) -> eltype(z)(5.0)
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

# Set the soil CO2 BC to being atmospheric CO2
soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
Expand Down Expand Up @@ -591,7 +591,8 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
)

updateat = Array(t0:(3600 * 3):tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(drivers)
cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
return prob, cb
end
Expand Down
13 changes: 7 additions & 6 deletions experiments/benchmarks/richards.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
vg_α = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"vGalpha_map_gupta_etal2020_2.5x2.5x4.nc",
"vGalpha_map_gupta_etal2020_1.0x1.0x4.nc",
),
"α",
subsurface_space;
Expand All @@ -135,7 +135,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
vg_n = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"vGn_map_gupta_etal2020_2.5x2.5x4.nc",
"vGn_map_gupta_etal2020_1.0x1.0x4.nc",
),
"n",
subsurface_space;
Expand All @@ -150,7 +150,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
θ_r = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"residual_map_gupta_etal2020_2.5x2.5x4.nc",
"residual_map_gupta_etal2020_1.0x1.0x4.nc",
),
"θ_r",
subsurface_space;
Expand All @@ -161,7 +161,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
ν = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"porosity_map_gupta_etal2020_2.5x2.5x4.nc",
"porosity_map_gupta_etal2020_1.0x1.0x4.nc",
),
"ν",
subsurface_space;
Expand All @@ -172,7 +172,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
K_sat = SpaceVaryingInput(
joinpath(
soil_params_artifact_path,
"ksat_map_gupta_etal2020_2.5x2.5x4.nc",
"ksat_map_gupta_etal2020_1.0x1.0x4.nc",
),
"Ksat",
subsurface_space;
Expand Down Expand Up @@ -277,7 +277,8 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
p,
)
updateat = Array(t0:(2Δt):tf)
updatefunc = ClimaLand.make_update_drivers(atmos, nothing)
drivers = ClimaLand.get_drivers(model)
updatefunc = ClimaLand.make_update_drivers(drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb)

Expand Down
6 changes: 3 additions & 3 deletions experiments/integrated/fluxnet/ozark_pft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}

soilco2_ps = SoilCO2ModelParameters(FT)

# soil microbes args
Csom = (z, t) -> eltype(z)(5.0)
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

# Set the soil CO2 BC to being atmospheric CO2
soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
Expand Down Expand Up @@ -298,7 +297,8 @@ saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
## How often we want to update the drivers. Note that this uses the defined `t0` and `tf`
## defined in the simulatons file
updateat = Array(t0:DATA_DT:tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb);

Expand Down
6 changes: 3 additions & 3 deletions experiments/integrated/fluxnet/run_fluxnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}

soilco2_ps = SoilCO2ModelParameters(FT)

# soil microbes args
Csom = (z, t) -> eltype(z)(5.0)
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

# Set the soil CO2 BC to being atmospheric CO2
soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
Expand Down Expand Up @@ -254,7 +253,8 @@ saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
## How often we want to update the drivers. Note that this uses the defined `t0` and `tf`
## defined in the simulatons file
updateat = Array(t0:DATA_DT:tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
model_drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(model_drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb)

Expand Down
5 changes: 3 additions & 2 deletions experiments/integrated/global/global_soil_canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ soil_model_type = Soil.EnergyHydrology{FT}
soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}

# soil microbes args
Csom = (z, t) -> eltype(z)(5.0)
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

# Set the soil CO2 BC to being atmospheric CO2
soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
Expand Down Expand Up @@ -368,7 +368,8 @@ sv = (;
)
saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)
updateat = Array(t0:(3600 * 3):tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
cb = SciMLBase.CallbackSet(driver_cb, saving_cb)
@time sol = SciMLBase.solve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ for float_type in (Float32, Float64)
saving_cb = ClimaLand.NonInterpSavingCallback(sv, saveat)

updateat = deepcopy(saveat)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}
soilco2_ps = SoilCO2ModelParameters(FT)

# soil microbes args
Csom = (z, t) -> eltype(z)(5.0)
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

# Set the soil CO2 BC to being atmospheric CO2
soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
Expand Down
11 changes: 7 additions & 4 deletions experiments/integrated/performance/profile_allocations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}
soilco2_ps = SoilCO2ModelParameters(FT)

# soil microbes args
Csom = (z, t) -> eltype(z)(5.0)
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

# Set the soil CO2 BC to being atmospheric CO2
soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
Expand Down Expand Up @@ -339,7 +339,8 @@ ode_algo = CTS.IMEXAlgorithm(
),
);

updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
# Set initial conditions
Y, p = set_initial_conditions(land, t0)
Expand Down Expand Up @@ -370,7 +371,8 @@ if PROFILING
# Now that we compiled, solve again but collect profiling information
Y, p = set_initial_conditions(land, t0)
updateat = Array(t0:dt:tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(
Expand All @@ -394,7 +396,8 @@ if PROFILING
@info "Save compute flame to flame_file"
Y, p = set_initial_conditions(land, t0)
updateat = Array(t0:dt:tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(drivers)
driver_cb = ClimaLand.DriverUpdateCallback(updateat, updatefunc)
prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(
Expand Down
5 changes: 3 additions & 2 deletions experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
soilco2_type = Soil.Biogeochemistry.SoilCO2Model{FT}

# soil microbes args
Csom = (z, t) -> eltype(z)(5.0)
Csom = ClimaLand.PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5))

# Set the soil CO2 BC to being atmospheric CO2
soilco2_top_bc = Soil.Biogeochemistry.AtmosCO2StateBC()
Expand Down Expand Up @@ -590,7 +590,8 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
)

updateat = Array(t0:(3600 * 3):tf)
updatefunc = ClimaLand.make_update_drivers(atmos, radiation)
drivers = ClimaLand.get_drivers(land)
updatefunc = ClimaLand.make_update_drivers(drivers)

# ClimaDiagnostics

Expand Down
Loading

0 comments on commit d5521a5

Please sign in to comment.