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

use dss in ClimaODEfunction; update docs #321

Closed
wants to merge 5 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
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CFTime = "179af706-886a-5703-950a-314cd64e0468"
ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
ClimaCoreTempestRemap = "d934ef94-cdd4-4710-83d6-720549644b70"
ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
Expand All @@ -27,6 +28,7 @@ CFTime = "0.1"
ClimaComms = "0.3, 0.4, 0.5"
ClimaCore = "0.10.44"
ClimaCoreTempestRemap = "0.3.5"
ClimaTimeSteppers = "0.7"
DocStringExtensions = "0.8, 0.9"
IntervalSets = "0.5, 0.6, 0.7"
JLD2 = "0.4"
Expand Down
52 changes: 27 additions & 25 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

julia_version = "1.9.1"
manifest_format = "2.0"
project_hash = "14af05f91b5633dd5211334568bc346a7be1f927"
project_hash = "cf146a17e08c22c52d1d495030b4f2d39964861b"

[[deps.ADTypes]]
git-tree-sha1 = "d68758475ff90600488eb975b5ac222709a7dd6f"
git-tree-sha1 = "f2b16fe1a3491b295105cae080c2a5f77a842718"
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
version = "0.2.2"
version = "0.2.3"

[[deps.AMD]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse_jll"]
Expand Down Expand Up @@ -69,9 +69,9 @@ version = "7.4.11"

[[deps.ArrayLayouts]]
deps = ["FillArrays", "LinearAlgebra"]
git-tree-sha1 = "dcda7e0ac618210eabf43751d5cafde100dd539b"
git-tree-sha1 = "0d61921af2799487b80453a44abb57db7a0c1381"
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
version = "1.3.0"
version = "1.4.1"
weakdeps = ["SparseArrays"]

[deps.ArrayLayouts.extensions]
Expand Down Expand Up @@ -153,9 +153,9 @@ version = "0.1.2"

[[deps.CLIMAParameters]]
deps = ["DocStringExtensions", "TOML", "Test"]
git-tree-sha1 = "91ba1a09c86300e814655914b120183ee16cdc53"
git-tree-sha1 = "7f3b89db2aabb81ec5750300a37d424f1f38240d"
uuid = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
version = "0.7.15"
version = "0.7.18"

[[deps.CPUSummary]]
deps = ["CpuId", "IfElse", "PrecompileTools", "Static"]
Expand Down Expand Up @@ -218,7 +218,7 @@ uuid = "d934ef94-cdd4-4710-83d6-720549644b70"
version = "0.3.5"

[[deps.ClimaLSM]]
deps = ["ArtifactWrappers", "CFTime", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "Dates", "DocStringExtensions", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics", "UnPack"]
deps = ["ArtifactWrappers", "CFTime", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "ClimaTimeSteppers", "Dates", "DocStringExtensions", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "SurfaceFluxes", "Thermodynamics", "UnPack"]
path = ".."
uuid = "7884a58f-fab6-4fd0-82bb-ecfedb2d8430"
version = "0.3.2"
Expand Down Expand Up @@ -303,9 +303,9 @@ version = "2.2.1"

[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "fe2838a593b5f776e1597e086dcd47560d94e816"
git-tree-sha1 = "c53fc348ca4d40d7b371e71fd52251839080cbc9"
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
version = "1.5.3"
version = "1.5.4"
weakdeps = ["IntervalSets", "StaticArrays"]

[deps.ConstructionBase.extensions]
Expand Down Expand Up @@ -369,9 +369,9 @@ version = "0.1.0+0"

[[deps.DiffEqBase]]
deps = ["ArrayInterface", "ChainRulesCore", "DataStructures", "DocStringExtensions", "EnumX", "FastBroadcast", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "Printf", "RecursiveArrayTools", "Reexport", "Requires", "SciMLBase", "SciMLOperators", "Setfield", "SparseArrays", "Static", "StaticArraysCore", "Statistics", "Tricks", "TruncatedStacktraces", "ZygoteRules"]
git-tree-sha1 = "df8638dbfa03d1b336c410e23a9dfbf89cb53937"
git-tree-sha1 = "dee066b8dce741815729f5973b6db757416948b7"
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
version = "6.128.2"
version = "6.128.4"

[deps.DiffEqBase.extensions]
DiffEqBaseDistributionsExt = "Distributions"
Expand Down Expand Up @@ -655,10 +655,10 @@ uuid = "88fa7841-ef32-4516-bb70-c6ec135699d9"
version = "0.1.0"

[[deps.Glib_jll]]
deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Pkg", "Zlib_jll"]
git-tree-sha1 = "d3b3624125c1474292d0d8ed0f65554ac37ddb23"
deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Zlib_jll"]
git-tree-sha1 = "e94c92c7bf4819685eb80186d51c43e71d4afa17"
uuid = "7746bdde-850d-59dc-9ae8-88ece973131d"
version = "2.74.0+2"
version = "2.76.5+0"

[[deps.Graphite2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand All @@ -685,9 +685,9 @@ version = "1.12.2+2"

[[deps.HTTP]]
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
git-tree-sha1 = "cb56ccdd481c0dd7f975ad2b3b62d9eda088f7e2"
git-tree-sha1 = "19e974eced1768fb46fd6020171f2cec06b1edb5"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "1.9.14"
version = "1.9.15"

[[deps.HarfBuzz_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
Expand Down Expand Up @@ -1159,9 +1159,9 @@ version = "1.4.1"

[[deps.OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "bbb5c2115d63c2f1451cb70e5ef75e8fe4707019"
git-tree-sha1 = "a12e56c72edee3ce6b96667745e6cbbe5498f200"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "1.1.22+0"
version = "1.1.23+0"

[[deps.OpenSpecFun_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -1347,17 +1347,19 @@ version = "0.6.12"

[[deps.RecursiveArrayTools]]
deps = ["Adapt", "ArrayInterface", "DocStringExtensions", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "Requires", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"]
git-tree-sha1 = "7ed35fb5f831aaf09c2d7c8736d44667a1afdcb0"
git-tree-sha1 = "9dbbf698bdd943fbf380f81bb4c365bc76287dc3"
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
version = "2.38.7"
version = "2.38.9"

[deps.RecursiveArrayTools.extensions]
RecursiveArrayToolsMeasurementsExt = "Measurements"
RecursiveArrayToolsMonteCarloMeasurementsExt = "MonteCarloMeasurements"
RecursiveArrayToolsTrackerExt = "Tracker"
RecursiveArrayToolsZygoteExt = "Zygote"

[deps.RecursiveArrayTools.weakdeps]
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

Expand Down Expand Up @@ -1401,9 +1403,9 @@ version = "0.1.0"

[[deps.SciMLBase]]
deps = ["ADTypes", "ArrayInterface", "ChainRulesCore", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "PrecompileTools", "Preferences", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables", "TruncatedStacktraces", "ZygoteRules"]
git-tree-sha1 = "54b005258bb5ee4b6fd0f440b528e7b7af4c9975"
git-tree-sha1 = "c0781c7ebb65776e9770d333b5e191d20dd45fcf"
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
version = "1.96.2"
version = "1.97.0"

[deps.SciMLBase.extensions]
ZygoteExt = "Zygote"
Expand Down Expand Up @@ -1489,9 +1491,9 @@ weakdeps = ["OffsetArrays", "StaticArrays"]

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore"]
git-tree-sha1 = "9cabadf6e7cd2349b6cf49f1915ad2028d65e881"
git-tree-sha1 = "51621cca8651d9e334a659443a74ce50a3b6dfab"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.6.2"
version = "1.6.3"
weakdeps = ["Statistics"]

[deps.StaticArrays.extensions]
Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ClimaLSM = "7884a58f-fab6-4fd0-82bb-ecfedb2d8430"
ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
Expand Down
16 changes: 8 additions & 8 deletions docs/tutorials/Bucket/bucket_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,17 @@ set_initial_aux_state!(p, Y, t0);
# of ordinary differential equations:
exp_tendency! = make_exp_tendency(model);

# Now we choose our timestepping algorithm.
# Now we choose our (explicit) timestepping algorithm from
# the selection available in [ClimaTimeSteppers.jl](https://github.com/CliMA/ClimaTimeSteppers.jl).
timestepper = CTS.RK4()
ode_algo = CTS.ExplicitAlgorithm(timestepper)
ode_algo = CTS.ExplicitAlgorithm(timestepper);

# To set up the ClimaODEFunction which will be executed to step the
# system explicitly in time, we call `get_ClimaODEFunction`:
clima_ode_function = ClimaLSM.get_ClimaODEFunction(model, Y)
# Then we can set up the simulation and solve it:
prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(T_exp! = exp_tendency!),
Y,
(t0, tf),
p,
);
prob = SciMLBase.ODEProblem(clima_ode_function, Y, (t0, tf), p);


# We need a callback to get and store the auxiliary fields, as they
# are not stored by default.
Expand Down
19 changes: 6 additions & 13 deletions docs/tutorials/Canopy/canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +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
# variables that are stepped explicitly.

# Initialize the state vectors and obtain the model coordinates
Y, p, coords = ClimaLSM.initialize(canopy)
exp_tendency! = make_exp_tendency(canopy);

# Provide initial conditions for the canopy hydraulics model

Expand Down Expand Up @@ -300,17 +296,14 @@ sv = (;
)
cb = ClimaLSM.NonInterpSavingCallback(sv, saveat);

# Select a timestepping algorithm and setup the ODE problem.

# Select an (explicit) timestepping algorithm from [ClimaTimeSteppers.jl](https://github.com/CliMA/ClimaTimeSteppers.jl)
timestepper = CTS.RK4();
ode_algo = CTS.ExplicitAlgorithm(timestepper)

prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(T_exp! = exp_tendency!, dss! = ClimaLSM.dss!),
Y,
(t0, tf),
p,
);
# To set up the ClimaODEFunction which will be executed to step the
# system explicitly in time, we call `get_ClimaODEFunction`:
clima_ode_function = ClimaLSM.get_ClimaODEFunction(canopy, Y)
prob = SciMLBase.ODEProblem(clima_ode_function, Y, (t0, tf), p);

# 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
Expand Down
46 changes: 20 additions & 26 deletions docs/tutorials/Canopy/soil_canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,8 @@ land = SoilCanopyModel{FT}(;
canopy_model_args = canopy_model_args,
);

# Now we can initialize the state vectors and model coordinates, and initialize
# the explicit/implicit tendencies as usual. The Richard's equation time
# stepping is done implicitly, while the canopy model may be explicitly stepped,
# so we use an IMEX (implicit-explicit) scheme for the combined model.

# Now we can initialize the state vectors and model coordinates.
Y, p, coords = initialize(land);
exp_tendency! = make_exp_tendency(land);

# We need to provide initial conditions for the soil and canopy hydraulics
# models:
Expand Down Expand Up @@ -354,39 +349,38 @@ for i in 1:2
augmented_liquid_fraction.(plant_ν, S_l_ini[i])
end;

# Now set the initial conditions for the auxiliary variables for the combined soil and plant model.

t0 = FT(0)
set_initial_aux_state! = make_set_initial_aux_state(land)
set_initial_aux_state!(p, Y, t0);

# Select the timestepper and solvers needed for the specific problem. Specify the time range and dt
# value over which to perform the simulation.

t0 = FT(150 * 3600 * 24)# start mid year
N_days = 100
tf = t0 + FT(3600 * 24 * N_days)
dt = FT(30)
n = 120
saveat = Array(t0:(n * dt):tf)

# Now set the initial conditions for the auxiliary variables for the combined soil and plant model.
set_initial_aux_state! = make_set_initial_aux_state(land)
set_initial_aux_state!(p, Y, t0);

# Pick the timestepper, timestep. Here we choose an explicit algorithm,
# which is appropriate for this model, from [ClimaTimeSteppers.jl](https://github.com/CliMA/ClimaTimeSteppers.jl)
dt = FT(30)
timestepper = CTS.RK4()
ode_algo = CTS.ExplicitAlgorithm(timestepper);

# And now perform the simulation as always.

# By default, only the state Y is saved. We'd like to save `p` as well,
# so we can define a callback which does so here:
n = 120
saveat = Array(t0:(n * dt):tf)
sv = (;
t = Array{FT}(undef, length(saveat)),
saveval = Array{ClimaCore.Fields.NamedTuple}(undef, length(saveat)),
)
cb = ClimaLSM.NonInterpSavingCallback(sv, saveat)
cb = ClimaLSM.NonInterpSavingCallback(sv, saveat);

prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(T_exp! = exp_tendency!),
Y,
(t0, tf),
p,
);
# To set up the ClimaODEFunction which will be executed to step the
# system explicitly in time, we call `get_ClimaODEFunction`:
clima_ode_function = ClimaLSM.get_ClimaODEFunction(land, Y)
prob = SciMLBase.ODEProblem(clima_ode_function, Y, (t0, tf), p);

# Now, wrap the problem, algorithm, timestep, and callback together
# to carry out the simulation.
sol = SciMLBase.solve(
prob,
ode_algo;
Expand Down
29 changes: 16 additions & 13 deletions docs/tutorials/Soil/freezing_front.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,25 +200,28 @@ end

init_soil!(Y, coords.z, soil.parameters);

# We choose the initial and final simulation times:
# Here we choose the timestepping algorithm. For the energy & hydrology
# soil model, we currently only support explicit timestepping.
# Here, we use the explicit timestepping algorithm RK4, which is suitable
# for this model because it has no defined implicit tendendency function.
# More options are available at [ClimaTimeSteppers.jl](https://github.com/CliMA/ClimaTimeSteppers.jl).
timestepper = CTS.RK4();
ode_algo = CTS.ExplicitAlgorithm(timestepper);

# Choose a timestep, integration timespan:
t0 = FT(0)
tf = FT(60 * 60 * 50);
tf = FT(60 * 60 * 50)
dt = FT(60);

# We set the aux state corresponding to the initial conditions
# of the state Y:
set_initial_aux_state! = make_set_initial_aux_state(soil);
set_initial_aux_state!(p, Y, t0);
# Create the tendency function, and choose a timestep, and timestepper:
exp_tendency! = make_exp_tendency(soil)
dt = FT(60)
timestepper = CTS.RK4()
ode_algo = CTS.ExplicitAlgorithm(timestepper)
prob = SciMLBase.ODEProblem(
CTS.ClimaODEFunction(T_exp! = exp_tendency!, dss! = ClimaLSM.dss!),
Y,
(t0, tf),
p,
);
# To set up the ClimaODEFunction which will be executed to step the
# system explicitly in time, we call `get_ClimaODEFunction`:
clima_ode_function = ClimaLSM.get_ClimaODEFunction(soil, Y)
prob = SciMLBase.ODEProblem(clima_ode_function, Y, (t0, tf), p);


# Now we can solve the problem.
sol = SciMLBase.solve(prob, ode_algo; dt = dt, saveat = 0:3600:tf);
Expand Down
Loading
Loading