Repository navigation
Fix ESDIRK order loss under a mass matrix - #4245
singhharsh1708 wants to merge 1 commit into
Conversation
51e4af2 to
6dbfff4
Compare
| """ | ||
| _explicit_stage1_rate(mass_matrix, fsalfirst) = fsalfirst | ||
| function _explicit_stage1_rate(mass_matrix::AbstractMatrix, fsalfirst) | ||
| F = lu(mass_matrix, check = false) |
There was a problem hiding this comment.
Why hardcode an lu here?
There was a problem hiding this comment.
switched to backslash.Singular case now uses integrator.isdae instead.
There was a problem hiding this comment.
Replaced by solve(LinearProblem(M, f), alg.linsolve), so it lands on whatever the user's linear solver picks; LinearSolve is now a direct SDIRK dependency.
6dbfff4 to
be6c5e9
Compare
| _explicit_stage1_rate(mass_matrix, fsalfirst, isdae) = fsalfirst | ||
| function _explicit_stage1_rate(mass_matrix::AbstractMatrix, fsalfirst, isdae) | ||
| isdae && return fsalfirst | ||
| return mass_matrix \ fsalfirst |
There was a problem hiding this comment.
Gone: the solve goes through LinearSolve with the algorithm's linsolve now.
|
Makes sense, M isn't inverted anywhere else, it's always folded into W. To do this properly the stages would need to carry f(Y) instead of dt*Ydot so the W solve absorbs it, which is a fair bit bigger than this PR. Should I do that here, or just error for now when there's a non-identity mass matrix with an explicit first stage? |
|
I think I have a better version of this. pr incoming |
|
Sounds good. The convergence test in here should apply to whatever the fix ends up being, happy to split it out or you can just lift it. |
dea6624 to
b90fe14
Compare
|
The red Integrators_II lts lane here is #4425, LinearSolve's QR fallback marking cache.tmp shared on Julia 1.10, not this change. |
6ed9bc8 to
a3accca
Compare
|
@ChrisRackauckas ready for another look, the backslash is gone and it goes through |
a3accca to
7345649
Compare
7345649 to
d5aed48
Compare
|
Letting Oscar take this. |
An ESDIRK's explicit first stage builds
zs[1]fromintegrator.fsalfirst, which under a mass matrix holds the residualfrather than the rateM \ f, so the first step carries an O(dt) error that never refines away and every ESDIRK drops to first order whenM != I.A convergence test under a mass matrix for TRBDF2, Kvaerno3, KenCarp3 and KenCarp4, with
M = Ialongside as the control, fails on master for all four and passes here; TRBDF2 goes from order 0.966 to 1.985. ROBER still solves toSuccesswith TRBDF2, KenCarp4 and Kvaerno3, so behaviour with a consistent first step is unchanged. FullOrdinaryDiffEqSDIRKsuite passes.Mis never inverted anywhere else, only folded intoW, so the proper fix is stages carryingf(Y); @oscardssmith said a better version is coming and this stands until it does.The rate is computed with
solve(LinearProblem(M, f), alg.linsolve)on the steps whosefsalfirstholds the residual, so it uses whatever linear solver the user chose rather than a fixed factorization; that makes LinearSolve a direct SDIRK dependency. Only anAbstractMatrixmass matrix is converted;UniformScalingand operator mass matrices keep the residual as before.Fixes #4173.
AI Disclosure: Claude assisted with this change.