Skip to content

Commit

Permalink
Merge #324
Browse files Browse the repository at this point in the history
324: Remove DiffEqCallbacks dependency r=juliasloan25 a=juliasloan25



Co-authored-by: Julia Sloan <jsloan@caltech.edu>
  • Loading branch information
bors[bot] and juliasloan25 authored Sep 8, 2023
2 parents 69ecdfe + e0a69c9 commit 74ce724
Show file tree
Hide file tree
Showing 20 changed files with 543 additions and 595 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
ClimaCoreTempestRemap = "d934ef94-cdd4-4710-83d6-720549644b70"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
Expand All @@ -27,11 +27,11 @@ CFTime = "0.1"
ClimaComms = "0.3, 0.4, 0.5"
ClimaCore = "0.10.44"
ClimaCoreTempestRemap = "0.3.5"
DiffEqCallbacks = "2"
DocStringExtensions = "0.8, 0.9"
IntervalSets = "0.5, 0.6, 0.7"
JLD2 = "0.4"
NCDatasets = "0.11, 0.12"
SciMLBase = "1"
StaticArrays = "1"
SurfaceFluxes = "0.6, 0.7"
Thermodynamics = "0.9, 0.10, 0.11"
Expand Down
482 changes: 231 additions & 251 deletions docs/Manifest.toml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
Expand All @@ -22,4 +21,3 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
[compat]
CLIMAParameters = "0.7"
ClimaTimeSteppers = "0.7"
SciMLBase = "<1.51"
11 changes: 4 additions & 7 deletions docs/tutorials/Bucket/bucket_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,9 @@

# # Simulating a standalone bucket model

# First, we need to import necessary packages. We use [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl)
# and [ClimaTimeSteppers.jl](https://github.com/CliMA/ClimaTimeSteppers.jl) for the timestepping,
# and [DiffEqCallbacks.jl](https://github.com/SciML/DiffEqCallbacks.jl) is used as described below,
# for accessing the solver state during the integration.
# First, we need to import necessary packages. We use [SciMLBase.jl](https://github.com/SciML/SciMLBase.jl)
# and [ClimaTimeSteppers.jl](https://github.com/CliMA/ClimaTimeSteppers.jl) for the timestepping.
import SciMLBase
using DiffEqCallbacks
import ClimaTimeSteppers as CTS

# We use [ClimaCore](https://github.com/CliMA/ClimaCore.jl)
Expand Down Expand Up @@ -215,8 +212,8 @@ bucket_domain =
LSMSingleColumnDomain(; zlim = (-soil_depth, 0.0), nelements = 10);


# The PrescribedAtmosphere and PrescribedRadiation need to take in a reference
# time, the date of the start of the simulation. In this tutorial we will
# The PrescribedAtmosphere and PrescribedRadiation need to take in a reference
# time, the date of the start of the simulation. In this tutorial we will
# consider this January 1, 2005.
ref_time = DateTime(2005);

Expand Down
84 changes: 42 additions & 42 deletions docs/tutorials/Canopy/canopy_tutorial.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# # Introduction to the Canopy Model

# This tutorial shows how to instantiate and run a simulation of the
# canopy biophysics model in ClimaLSM. A
# canopy biophysics model in ClimaLSM. A
# [`CanopyModel`](https://clima.github.io/ClimaLSM.jl/dev/APIs/canopy/Canopy/#Canopy-Model-Structs)
# including all component
# models is initialized, then an example simulation is run. The initial conditions,
# atmospheric and radiative flux conditions, and canopy properties are set up
# to match those observed at the US-MOz flux tower, a flux tower located within
# including all component
# models is initialized, then an example simulation is run. The initial conditions,
# atmospheric and radiative flux conditions, and canopy properties are set up
# to match those observed at the US-MOz flux tower, a flux tower located within
# an oak-hickory forest in Ozark, Missouri, USA. See [Wang et al. 2021](https://doi.org/10.5194/gmd-14-6741-2021)
# for details on the site and canopy parameters.

# The canopy biophysics model in ClimaLSM combines a photosynthesis model with a
# canopy radiative transfer scheme, plant hydraulics model, and stomatal
# The canopy biophysics model in ClimaLSM combines a photosynthesis model with a
# canopy radiative transfer scheme, plant hydraulics model, and stomatal
# conductance model, placing them under either prescribed or simulated (as in a
# full Earth System Model) atmospheric and radiative flux conditions.
# full Earth System Model) atmospheric and radiative flux conditions.

# ClimaLSM supports either Beer-Lambert law or a Two-Stream model for radiative
# transfer. For this tutorial, we will use the Beer-Lambert law,
# ClimaLSM supports either Beer-Lambert law or a Two-Stream model for radiative
# transfer. For this tutorial, we will use the Beer-Lambert law,
# in which the intensity of light absorbed is a negative exponential function of
# depth in the canopy and an exinction coefficient determined by optical depth.

# The model of photosynthesis in CliMA LSM is the Farquar Model in which GPP is
# calculated based on C3 and C4 photosynthesis, which determines potential
# The model of photosynthesis in CliMA LSM is the Farquar Model in which GPP is
# calculated based on C3 and C4 photosynthesis, which determines potential
# leaf-level photosynthesis.

# The plant hydraulics model in ClimaLSM solves for the water content within
# bulk root-stem-canopy system using Richards equation discretized into an
# arbitrary number of layers. The water content is related to the water
# potential using a retention curve relationship, and the water potential is
# The plant hydraulics model in ClimaLSM solves for the water content within
# bulk root-stem-canopy system using Richards equation discretized into an
# arbitrary number of layers. The water content is related to the water
# potential using a retention curve relationship, and the water potential is
# used to simulate the effect moisture stress has on transpiration and GPP.

# # Preliminary Setup
Expand Down Expand Up @@ -61,19 +61,19 @@ earth_param_set = create_lsm_parameters(FT);

# # Setup the Canopy Model

# We want to simulate a vegetative canopy in standalone mode, without coupling
# the canopy to atmospheric or soil physics models, so we choose a
# [`CanopyModel`](https://clima.github.io/ClimaLSM.jl/dev/APIs/canopy/Canopy/#Canopy-Model-Structs).
# From the linked
# documentation, we can see that we need to provide shared parameters, a domain,
# a radiative transfer model, photosynthesis model, plant hydraulics model,
# stomatal conductance model, and atmospheric and radiative flux conditions
# We want to simulate a vegetative canopy in standalone mode, without coupling
# the canopy to atmospheric or soil physics models, so we choose a
# [`CanopyModel`](https://clima.github.io/ClimaLSM.jl/dev/APIs/canopy/Canopy/#Canopy-Model-Structs).
# From the linked
# documentation, we can see that we need to provide shared parameters, a domain,
# a radiative transfer model, photosynthesis model, plant hydraulics model,
# stomatal conductance model, and atmospheric and radiative flux conditions
# which may be either prescribed or simulated.

# First, define the parameters of the model domain. These values are needed
# by some of the component models. Here we are performing a 1-dimensional
# simulation in a `Point` domain and will use
# single stem and leaf compartments, but for 2D simulations, the parameters of
# First, define the parameters of the model domain. These values are needed
# by some of the component models. Here we are performing a 1-dimensional
# simulation in a `Point` domain and will use
# single stem and leaf compartments, but for 2D simulations, the parameters of
# the [`domain`](https://clima.github.io/ClimaLSM.jl/dev/APIs/shared_utilities/#Domains)
# would change.

Expand All @@ -86,7 +86,7 @@ h_leaf = FT(9.5)
compartment_midpoints = [h_stem / 2, h_stem + h_leaf / 2]
compartment_surfaces = [FT(0), h_stem, h_stem + h_leaf];

# We will be using prescribed atmospheric and radiative flux drivers from the
# We will be using prescribed atmospheric and radiative flux drivers from the
# US-MOz tower observations, which we read in here. We are using prescribed
# atmospheric and radiative flux conditions, but it is also possible to couple
# the simulation with atmospheric and/or radiative flux models.
Expand All @@ -98,7 +98,7 @@ include(
),
);

# Populate the SharedCanopyParameters struct, which holds the parameters
# Populate the SharedCanopyParameters struct, which holds the parameters
# shared between all different components of the canopy model.
z0_m = FT(2)
z0_b = FT(0.2)
Expand All @@ -109,7 +109,7 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
earth_param_set,
);

# For this canopy, we are running in standalone mode, which means we need to
# For this canopy, we are running in standalone mode, which means we need to
# use a prescribed soil driver, defined as follows:

ψ_soil0 = FT(0.0)
Expand Down Expand Up @@ -173,7 +173,7 @@ photo_params = FarquharParameters{FT}(

photosynthesis_model = FarquharModel{FT}(photo_params);

# Arguments for plant hydraulics model are more complicated.
# Arguments for plant hydraulics model are more complicated.

# Begin by providing general plant parameters. For the area
# indices of the canopy, we choose a `PrescribedSiteAreaIndex`,
Expand All @@ -192,7 +192,7 @@ function root_distribution(z::T; rooting_depth = rooting_depth) where {T}
return T(1.0 / rooting_depth) * exp(z / T(rooting_depth))
end;

# Create the component conductivity and retention models of the hydraulics
# Create the component conductivity and retention models of the hydraulics
# model. In ClimaLSM, a Weibull parameterization is used for the conductivity as
# a function of potential, and a linear retention curve is used.

Expand Down Expand Up @@ -230,10 +230,10 @@ plant_hydraulics = PlantHydraulics.PlantHydraulicsModel{FT}(;
compartment_midpoints = compartment_midpoints,
);

# Now, instantiate the canopy model, using the atmospheric and radiative
# drivers included from the external file, as well as the soil driver we
# instantiated above. This contains every piece of information needed to
# generate the set of ODEs modeling the canopy biophysics, ready to be passed
# Now, instantiate the canopy model, using the atmospheric and radiative
# drivers included from the external file, as well as the soil driver we
# instantiated above. This contains every piece of information needed to
# generate the set of ODEs modeling the canopy biophysics, ready to be passed
# off to a timestepper.

canopy = ClimaLSM.Canopy.CanopyModel{FT}(;
Expand All @@ -248,8 +248,8 @@ canopy = ClimaLSM.Canopy.CanopyModel{FT}(;
radiation = radiation,
);

# Initialize the state vectors and obtain the model coordinates, then get the
# explicit time stepping tendency that updates auxiliary and prognostic
# Initialize the state vectors and obtain the model coordinates, then get the
# explicit time stepping tendency that updates auxiliary and prognostic
# variables that are stepped explicitly.

Y, p, coords = ClimaLSM.initialize(canopy)
Expand All @@ -272,7 +272,7 @@ for i in 1:2
Y.canopy.hydraulics.ϑ_l.:($i) .= augmented_liquid_fraction.(ν, S_l_ini[i])
end;

# Select a time range to perform time stepping over, and a dt. Also create the
# Select a time range to perform time stepping over, and a dt. Also create the
# saveat Array to contain the data from the model at each time step. As usual,
# the timestep depends on the problem you are solving, the accuracy of the
# solution required, and the timestepping algorithm you are using.
Expand All @@ -282,7 +282,7 @@ N_days = 365
tf = t0 + FT(3600 * 24 * N_days)
dt = FT(225);

# Initialize the auxiliary variables for the canopy using the initial
# Initialize the auxiliary variables for the canopy using the initial
# conditions and initial time.

set_initial_aux_state! = make_set_initial_aux_state(canopy)
Expand Down Expand Up @@ -312,8 +312,8 @@ prob = SciMLBase.ODEProblem(
p,
);

# Now, we can solve the problem and store the model data in the saveat array,
# using [`OrdinaryDiffEq.jl`](https://github.com/SciML/OrdinaryDiffEq.jl) and
# Now, we can solve the problem and store the model data in the saveat array,
# using [`SciMLBase.jl`](https://github.com/SciML/SciMLBase.jl) and
# [`ClimaTimeSteppers.jl`](https://github.com/CliMA/ClimaTimeSteppers.jl).

sol = SciMLBase.solve(prob, ode_algo; dt = dt, callback = cb, saveat = saveat);
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/Soil/richards_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ tf = FT(60 * 60 * 24 * 36);
set_initial_aux_state! = make_set_initial_aux_state(soil);
set_initial_aux_state!(p, Y, t0);

# Next, we turn to timestepping.
# Next, we turn to timestepping.
# As usual, your timestep depends on the problem you are solving, the accuracy
# of the solution required, and the timestepping algorithm you are using.
dt = FT(1e3);
Expand All @@ -185,7 +185,7 @@ jac_kwargs =
(; jac_prototype = RichardsTridiagonalW(Y), Wfact = update_jacobian!);

# And then we can solve the system of equations, using
# [OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl) and
# [SciMLBase.jl](https://github.com/SciML/SciMLBase.jl) and
# [ClimaTimeSteppers.jl](https://github.com/CliMA/ClimaTimeSteppers.jl).
prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/Soil/soil_energy_hydrology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
# # Import necessary modules
# External (non - CliMA) modules
import SciMLBase
using DiffEqCallbacks
using Statistics
using Plots

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/Usage/LSM_single_column_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# stored in the `model` is used to make the system of equations.
# Given initial conditions, these equations can then be stepped forward in
# time using the time-stepper of your choice (we are set up to use
# OrdinaryDiffEq.jl currently).
# SciMLBase.jl currently).
# Note that a model requiring implicit timestepping would instead use an
# `AbstractImExModel` framework.

Expand Down
Loading

0 comments on commit 74ce724

Please sign in to comment.