-
Notifications
You must be signed in to change notification settings - Fork 8
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
solving for Implicit operators #41
Comments
Sounds like a good plan. |
From Tapio:
|
The decision was made today to reduce the priority of this in favor of CG work |
After some discussion with @bischtob, I think the way to think of it is as follows:
|
Hum... I think this form does not really follow the canonical form. Is |
No, it is going to be the current state + explicit part (e.g. explicit RK stages). I was just trying to write it in a general-ish form to clarify what the timestepper actually requires. |
See some old notes Thomas and I wrote here: https://clima.github.io/TimeMachine.jl/dev/background/ark/ |
OrdinaryDiffEq.jl v6 has changed its interface such that our existing approach no longer works: see this comment: CliMA/ClimateMachine.jl#2255 (comment) From what I understand, the main changes:
@dennisYatunin can you expand on how we do all that? |
As far as I currently understand the OrdinaryDiffEq interface, we should do the following:
|
@ChrisRackauckas Can you give a few pointers on how this should work? For example, suppose that we have: # our internal representation of our Jacobian operator
struct CustomJacobian
...
end
# function which updates the CustomJacobian at the current state
function jupdate!(J::CustomJacobian, u, p, t)
...
end
# function which solves (I - alpha * J) * x = b
function wsolve!(x, J::CustomJacobian, alpha::Real, b)
...
end how should we incorporate this into the new framework? |
As a starting point, I would highly recommend looking at the new large-scale PDE tutorial. That will give the vocabulary of what the new structure is like and we can use that as a starting point. https://diffeq.sciml.ai/stable/tutorials/advanced_ode_example/
I'm not sure what a custom Details about W will get added to https://diffeq.sciml.ai/stable/features/linear_nonlinear/ shortly, as we now expect users to interact with it in the preconditioner interface so we need to define the fields and actions.
What you're describing here is equivalent to
Mostly correct. Instead of a custom W representation, you just define a custom J representation, so it knows what to do with the Jacobian. If that's a DiffEqOperator, then it keeps the pieces separate in the WOperator anyways, and you just need
Note that Pardiso's solvers have a Schur complement solve setup with MKL goodies, so you might want to look into that? It's not enabled with the LinearSolve.jl's defaults, but I saw it in the Pardiso docs so it shouldn't be hard to expose. It should just be the flip of a few options.
So yeah, onto the action items for @simonbyrne. The steps would be to:
linsolvecache = SciMLBase.init(prob::LinearProblem,alg::YourAlgorithm)
linearsolution = SciMLBase.solve(linearcache::YourLinearCacheType;kwargs...) and the caching API interface functions (http://linearsolve.sciml.ai/dev/basics/CachingAPI/). But, given that most of the shuttling like "don't refactor" and "don't redo symbolic factorization" is all very common between algorithms, I think doing a "from scratch" implementation of a linear solve is probably not the right way to do it. Instead, we should write some documentation in LinearSolve.jl for how to easily add new linear solver algorithms using the internal machinery. I'll go write that right now. Essentially you provide two functions:
For example, the KLU.jl wrapper is quite clear: https://github.com/SciML/LinearSolve.jl/blob/main/src/factorization.jl#L97-L99 and https://github.com/SciML/LinearSolve.jl/blob/main/src/factorization.jl#L101-L130. That's all, and that will make it cache symbolic factorizations, factorizations, etc. So let me get that written up. We can jump on a call afterwards to discuss it a bit more. You're the first to define outside linear solvers on the new interface so in theory it all works but in practice I may need to make a few things less bumpy. |
looks like a lot of the functionality OP seeks is available in SciMLOperators.jl |
take a look at how I'm doing BVPs in code: https://github.com/vpuri3/PDEInterfaces.jl/tree/master/src/BoundaryConditions In principle with implicit solvers, you are solving a BVP at every time step. I'm still cleaning up the BC interface but i think you can get away with passing in a BC respecting rank sufficient SciMLOperator to the implicit part of your SplitODEProblem. everything should just work :)) |
We need a way to handle part of the operators implicitly. To reduce the scope of this problem, initially we will only consider:
Rough plan:
MatrixOperator
: this would wrap anAbstractMatrix
object (typically aBidiagonal
orTridiagonal
, could expand to BandedMatrices.jl objects for more complicated stencils).stencil_interior
,stencil_left_boundary
, etc.): mainly so that we can check it is correct.FactorizedMatrixOperator
: this would wrap the result offactorize
of the underlying matrix.ldiv!
:jac
argument)Once we have this in place, we can tackle the more ambitious stuff:
some of this I think we can do using autodiff.
The text was updated successfully, but these errors were encountered: