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

O2.3.6 Implicit solver for full soil model #135

Open
8 of 16 tasks
kmdeck opened this issue Jan 11, 2023 · 4 comments
Open
8 of 16 tasks

O2.3.6 Implicit solver for full soil model #135

kmdeck opened this issue Jan 11, 2023 · 4 comments
Assignees
Labels
SDI Software Design Issue

Comments

@kmdeck
Copy link
Collaborator

kmdeck commented Jan 11, 2023

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

  • For Richards equation: plots of mass conservation and solution error vs timestep for modified Picard iterations, for constant flux and state BC test runs. Comparison to an explicit solver of the same order - obtain max dt the explicit solver runs at. - in our buildkite
  • Richards equation: unit test of Jacobian computed by the code with the analytic expression
  • Make sure the above validation results are preserved with new CTS interface
  • For full soil model : plots of mass conservation and solution error vs timestep for modified Picard iterations, for constant flux, moisture state BC, and for AtmosDrivenBC. Comparison to an explicit solver of the same order - obtain max dt the explicit solver runs at.
  • Unit tests of jacobian
  • flexible implementation that allows for LSM models - with many component models - to also have Jacobians specified. Start with soil/canopy model

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

  • 4 March 2024: SDI updated for clarity and to more accurately reflect current status (by @juliasloan25)

step RichardsModel implicitly

  1. enhancement
    juliasloan25
  2. enhancement
    juliasloan25
  3. enhancement
    juliasloan25
  4. GPU enhancement
    juliasloan25
  5. enhancement
    juliasloan25

step EnergyHydrology implicitly

  1. enhancement
    juliasloan25
  2. enhancement
  3. enhancement
    kmdeck
  4. enhancement
  5. enhancement
  6. enhancement
    kmdeck

QA

@kmdeck kmdeck added the SDI Software Design Issue label Jan 11, 2023
@tapios
Copy link

tapios commented Jan 13, 2023

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
Copy link
Collaborator Author

kmdeck commented Jan 13, 2023

@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
Copy link
Member

dennisYatunin commented Jan 13, 2023

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
Copy link
Collaborator Author

kmdeck commented Jan 14, 2023

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!

@kmdeck kmdeck mentioned this issue May 9, 2023
1 task
bors bot added a commit that referenced this issue May 12, 2023
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>
bors bot added a commit that referenced this issue May 12, 2023
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>
This was referenced Jun 9, 2023
mitraA90 pushed a commit that referenced this issue Dec 22, 2023
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>
@juliasloan25 juliasloan25 changed the title Soil implicit solvers O2.3.5 Implicit solver for full soil model Apr 24, 2024
@juliasloan25 juliasloan25 changed the title O2.3.5 Implicit solver for full soil model O2.3.6 Implicit solver for full soil model Apr 24, 2024
@kmdeck kmdeck mentioned this issue Jul 2, 2024
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDI Software Design Issue
Projects
None yet
Development

No branches or pull requests

4 participants