CliMA / ClimaLand.jl

Clima's Land Model
Apache License 2.0
36 stars 9 forks source link

O2.3.6 Implicit solver for full soil model #135

Closed kmdeck closed 1 day ago

kmdeck commented 1 year ago

Purpose

We need an implicit solver for the soil model (both for Richards equation alone, and the full soil system), and possibly in the future for other models as well. Currently, the implicit solver for Richards equation is implemented and in use. The full soil implicit solver is still in progress.

Components

Inputs

Results and deliverables/Validation

Initial task breakdown

A preliminary list of PRs and a preliminary timeline of PRs, milestones, and key results.

Producers

@juliasloan25 (design and implementation) @kmdeck @dennisYatunin (design, implementation support)

Reviewers

Katherine, Dennis - PRs Tapio - SDI review (@tapios)

SDI Changelog

### step RichardsModel implicitly
- [ ] https://github.com/CliMA/ClimaLand.jl/issues/224
- [ ] https://github.com/CliMA/ClimaLand.jl/issues/268
- [ ] https://github.com/CliMA/ClimaLand.jl/issues/528
- [ ] https://github.com/CliMA/ClimaLand.jl/issues/541
- [ ] https://github.com/CliMA/ClimaLand.jl/issues/647
### step EnergyHydrology implicitly
- [ ] #538
- [ ] #660
- [ ] https://github.com/CliMA/ClimaLand.jl/issues/663
### QA
- [x] write tutorial demonstrating how to use IMEX model (done - EnergyHydrologyModel example)
### canopy implicit timestepping
- [ ] https://github.com/CliMA/ClimaLand.jl/issues/696
tapios commented 1 year ago

LGTM.

We should keep the tridiagonal solver in one central place that we do not have to duplicate it (so that we update it in one place, e.g., for GPU performance, this percolates through).

kmdeck commented 1 year ago

@dennisYatunin could we move the thomas algorithm function to ClimaTimesteppers?

also, if the matrix passed is the identity, will the algorithm spend time inverting it, or will it just return b?

dennisYatunin commented 1 year ago

Actually, ClimaCore might be a slightly better location than ClimaTimeSteppers. We're currently computing Jacobian blocks as ClimaCore Fields, then copying them into arrays to run the Thomas Algorithm. It would probably be better to have a function in ClimaCore that can directly invert a Jacobian block Field (I left a note in ClimaCore last year to add a function like this).

If the Jacobian matrix is I (or some constant times I, which is encoded by the same struct), the matrix inversion will be ldiv!(x, I, b), which is defined in LinearAlgebra to just set x .= b (scaled by a constant, if applicable).

kmdeck commented 1 year ago

If the Jacobian matrix is I (or some constant times I, which is encoded by the same struct), the matrix inversion will be ldiv!(x, I, b), which is defined in LinearAlgebra to just set x .= b (scaled by a constant, if applicable).

excellent!

juliasloan25 commented 1 day ago

completed - see #809 for followup