-
Notifications
You must be signed in to change notification settings - Fork 9
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
initial full soil imp solver #651
Conversation
for the freezing front test, maybe we can try a higher order IMEX stepper? E.g. ARS343 It may be that using explicit euler as the explicit stepper is not sufficient or requires a very small step, while when we were using RK4 we could use a bigger step. |
Even using ARS343 with a timestep as small as 0.1s (was 60s when explicit), all prognostic variables are NaN at the second timestep. Maybe we do need to add more terms to our jacobian approximation? |
Let's think about this a bit more. It seems odd that treating RHS terms all explicitly is OK, but moving one to be treated implicitly (which should only making things more stable) and leaving the others explicit causes errors. Do you want to meet this afternoon to try some debugging? |
Yeah, good point. Want to meet at 1pm? |
sure! |
8b192f7
to
236d580
Compare
@@ -192,8 +192,15 @@ land = SoilCanopyModel{FT}(; | |||
canopy_model_args = canopy_model_args, | |||
) | |||
exp_tendency! = make_exp_tendency(land) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, this file was already using ARS111 and an IMEXAlgorithm (lines 18-32 of this file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh! that's totally it. We were using explicit euler before, but the only option for that is IMEX ars111 (with imp_tendency! doing nothing). there is no pure explicit euler option in ClimaTimestppers. this matters just because the expected energy and water changes we compute are computed assuming explicit euler timesteps.
like, if Var(t+dt)= Var(t) + function(fluxes(t)) * dt, we can check conservation by comparing Var(t+dt) - Var(t) = function(fluxes(t)) * dt (but over many steps - and just expect roundoff error)
but if the timestepper changes, this is not the case. if it was implicit, we could do
Var(t+dt) - Var(t) = function(fluxes(t+dt)) * dt
basically im not really sure how to compute the "truth" for higher order imex schemes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can ask Dennis. We mostly want to verify that d(energy in land) = energy in - energy out over the whole sim.
I think the important thing is that this is not growing. so I am inclined to think this is OK, we just are computing what we want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh I see! Would it be possible to use the equation you gave for the explicit case for explicitly-stepped variables, and the implicit one for implicitly-stepped variables? Or does that not make sense because we have to consider both variables and fluxes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im not sure! maybe we can discuss more tomorrow? Im not worried about this really for this PR though... we maybe need to rethink that conversation test in general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to discuss tomorrow! I opened an issue for this too so we can keep track of it #662
present, and hence the timestepping is entirely explicit. | ||
""" | ||
function make_update_jacobian(model::AbstractModel) | ||
function update_jacobian!(W, Y, p, dtγ, t) end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this do nothing? or should it return minus identity matrix?
or do we never rely on this default (and never will)? if so, maybe we can note that this is only a stub and must be extended or ? not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it needs to return -I. I know that we had previously set the jacobian blocks for explicitly-stepped variables to -I in update_jacobian!
, but I realized that we just can initialize these as -I in our ImplicitEquationJacobian
constructor. Then we just do nothing for these blocks in update_jacobian!
.
And now that I'm writing this out, I notice that update_jacobian!
is now identical for RichardsModel
and EnergyHydrology
with the jacobian approximation we're using right now. I can move it into src/Soil
and change the type dispatch to use one method for both, or we could just keep it split up since we'll be changing the EnergyHydrology
version as we iterate on the jacobian anyway. I'm fine with either.
I'll add a note to the generic update_jacobian!
to explain that it needs to be extended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great as a starting point! Mostly comments about keeping track of our to-do list afterwards
236d580
to
2cc1bcc
Compare
Purpose
Adds a simple implicit tendency for the
EnergyHydrology
model, which only treats the liquid water content implicitly (using the functions already defined forRichardsModel
)closes #538
Requirements for a model with implicit and explicit prognostic variables
Changes in src
(@name(var), @name(var)) => block
in the Jacobian. The block should be the negative identity matrix for variables that are stepped explicitly, and a tridiagonal matrix for variables that are stepped implicitlydY.model .= 0
for implicitly-stepped variablesdY.model .= 0
for explicitly-stepped variablesChanges in driver
exp_tendency!
, createimp_tendency!
,tendency_jacobian!
, andjac_kwargs
CTS.ExplicitAlgorithm
toCTS.IMEXAlgorithm
, and add theNewtonsMethod
argumentSciMLBase.ODEFunction(imp_tendency!; jac_kwargs...)
toCTS.ClimaODEFunction
call)Next steps (separate PRs)
dT/dI
drhoe_int / dtheta_l
Content
src/Soil
imp_tendency
function forEnergyHydrology
EnergyHydrology
to use implicit tendency (docs, tests)SoilCanopyModel
ImplicitEquationJacobian
imp_tendency!
(replacedo_nothing_imp_tendency
? --> updatecompute_imp_tendency
(andexp_tendency
defaults to setdY .= 0
)make_jac_tendency
function forAbstractLandModel
- calling functions of component models, analogous to ALMupdate_aux
Check run output
docs
experiments (visually inspected)