You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix DAE mass matrix initialization with vector abstol
Fixes issue #2820 where DAE mass matrix initialization failed when
using vector abstol instead of scalar abstol.
The problem was in multiple locations in initialize_dae.jl where
the code attempted direct comparison of norm results (Float64) with
abstol (which can be Vector{Float64}). This caused MethodError when
abstol was a vector.
The fix normalizes the error by dividing by abstol before taking the
norm, then checks if the resulting norm is <= 1. This approach:
- Works with both scalar and vector abstol
- Maintains backward compatibility
- Follows the tolerance checking pattern used elsewhere
Changes:
- Updated all tolerance comparisons in _initialize_dae! functions
- Fixed both ShampineCollocationInit and BrownFullBasicInit algorithms
- Applied fix to all variants (in-place/out-of-place, ODE/DAE problems)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
isAD =alg_autodiff(integrator.alg) isa AutoForwardDiff
466
470
if isAD
@@ -539,7 +543,7 @@ function _initialize_dae!(integrator, prob::DAEProblem,
539
543
normtmp =get_tmp_cache(integrator)[1]
540
544
f(normtmp, du, u, p, t)
541
545
542
-
if integrator.opts.internalnorm(normtmp, t) <=alg.abstol
546
+
if integrator.opts.internalnorm(normtmp./ alg.abstol, t) <=1
543
547
return
544
548
elseif differential_vars ===nothing
545
549
error("differential_vars must be set for DAE initialization to occur. Either set consistent initial conditions, differential_vars, or use a different initialization algorithm.")
@@ -600,7 +604,8 @@ function _initialize_dae!(integrator, prob::DAEProblem,
600
604
@unpack p, t, f = integrator
601
605
differential_vars = prob.differential_vars
602
606
603
-
if integrator.opts.internalnorm(f(integrator.du, integrator.u, p, t), t) <= alg.abstol
607
+
if integrator.opts.internalnorm(f(integrator.du, integrator.u, p, t) ./ alg.abstol, t) <=
608
+
1
604
609
return
605
610
elseif differential_vars ===nothing
606
611
error("differential_vars must be set for DAE initialization to occur. Either set consistent initial conditions, differential_vars, or use a different initialization algorithm.")
0 commit comments