-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
190: Jacobian update defaults r=kmdeck a=kmdeck ## Purpose Part of SDI #135 Adds functions which compute the Jacobian and Jacobian due to the boundary terms in the tendency. Adds default functions + extends those for Richards equation. ## Content - adds three functions: `make_update_jacobian`, `make_tendency_jacobian`, and `\partialtendencyBC\partialY`. - adds the methods of these for RichardsModel. - adds unit tests which demonstrate that the Jacobian is computed correctly. Review checklist I have: - followed the codebase contribution guide: https://clima.github.io/ClimateMachine.jl/latest/Contributing/ - followed the style guide: https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/ - followed the documentation policy: https://github.com/CliMA/policies/wiki/Documentation-Policy - checked that this PR does not duplicate an open PR. In the Content, I have included - relevant unit tests, and integration tests, - appropriate docstrings on all functions, structs, and modules, and included relevant documentation. ---- - [x] I have read and checked the items on the review checklist. Co-authored-by: kmdeck <kdeck@caltech.edu>
- Loading branch information
Showing
16 changed files
with
565 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
export make_tendency_jacobian, | ||
make_update_jacobian, AbstractTridiagonalW, ∂tendencyBC∂Y | ||
|
||
|
||
""" | ||
make_tendency_jacobian(model::AbstractModel) | ||
Creates and returns a function which updates the auxiliary | ||
variables `p` in place and then updates the entries of the | ||
Jacobian matrix `W` for the `model` in place. | ||
The default is that no updates are required, no implicit tendency is | ||
present, and hence the timestepping is entirely explicit. | ||
Note that the returned function `tendency_jacobian!` should be | ||
used as `Wfact!` in `ClimaTimeSteppers.jl` and `OrdinaryDiffEq.jl`. | ||
""" | ||
function make_tendency_jacobian(model::AbstractModel) | ||
update_aux! = make_update_aux(model) | ||
update_jacobian! = make_update_jacobian(model) | ||
function tendency_jacobian!(W, Y, p, dtγ, t) | ||
update_aux!(p, Y, t) | ||
update_jacobian!(W, Y, p, dtγ, t) | ||
end | ||
return tendency_jacobian! | ||
end | ||
|
||
""" | ||
make_update_jacobian(model::AbstractModel) | ||
Creates and returns a function which updates the entries | ||
of the Jacobian matrix `W` in place. | ||
If the implicit tendency function is given by | ||
`T!(dY, Y, p, t) = make_implicit_tendency(model)`, the Jacobian | ||
should be given by `W_{i,j}! = ∂T!_i/∂Y_j`, where `Y_j` is the | ||
`j-th` state variable | ||
and `T!_i` is the implicit tendency of the `i-th` state variable. | ||
The default is that no updates are required, no implicit tendency is | ||
present, and hence the timestepping is entirely explicit. | ||
""" | ||
function make_update_jacobian(model::AbstractModel) | ||
function update_jacobian!(W, Y, p, dtγ, t) end | ||
return update_jacobian | ||
end | ||
|
||
""" | ||
∂tendencyBC∂Y(::AbstractModel, | ||
::AbstractBC, | ||
::AbstractBoundary, | ||
_...)::Union{ClimaCore.Fields.FieldVector, Nothing} | ||
A function stub which returns the derivative of the implicit tendency | ||
term of the `model` arising from the boundary condition, | ||
with respect to the state Y. | ||
""" | ||
function ∂tendencyBC∂Y( | ||
::AbstractModel, | ||
::AbstractBC, | ||
::AbstractBoundary, | ||
_..., | ||
)::Union{ClimaCore.Fields.FieldVector, Nothing} end | ||
|
||
""" | ||
AbstractTridiagonalW | ||
An abstract type for tridiagonal Jacobian matrices. | ||
""" | ||
abstract type AbstractTridiagonalW end | ||
|
||
Base.similar(w::AbstractTridiagonalW) = w |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.