Skip to content

FBDF: first steps of a mass-matrix DAE collapse to ~1e-18 s and then grow ~1500× in one step (order-1 step size not based on the error estimate) #5003

Open

Description

@johanandberger

Describe the bug 🐞

Hi, thank you for your work on the OrdinaryDiffEq package! I am struggling with the following issue: On a small, smooth index-1 mass-matrix DAE that starts from rest FBDF accepts its first steps at about 5e-19 s, then grows dt by about 1500 x in a single step. It takes 78 steps and 20 rejections, where Rodas5P takes 8 steps and no rejections. The first steps also depend on the absolute start time t0, although nothing else in the problem changes. Is this behavior to be expected?

In a larger application DAE (1 500–5000 states) the same start-up behaviour makes runs that differ only by one unit in the last place in the RHS take different step sequences. The sequences part ways within the first ~20 attempts after each (re)start, where the error estimates are close to rounding-noise level. Step counts then vary by 10–20 % between such runs, and some runs fail a downstream accuracy check.

Expected behavior

I would expect the first steps to be sized from the local error and not to depend on the absolute value of t0. For a solution that starts linearly in t at reltol 1e-6, they should be roughly comparable to Rodas5P's first step. Growth after the start should be gradual.

Minimal Reproducible Example 👇

A capacitor discharging into an RL load. The current I is an algebraic unknown:
dV/dt = −I/C, dλ/dt = V − R·I, 0 = λ − L·I, with V(0) = V0, λ(0) = 0, I(0) = 0.
The solution is smooth: I ≈ V0·t/L for small t.

using OrdinaryDiffEq, LinearAlgebra, Printf

const C, L, R, V0 = 2e-3, 1e-5, 0.05, 2000.0
function f!(du, u, p, t)
    V, λ, I = u
    du[1] = -I / C
    du[2] = V - R * I
    du[3] = λ - L * I
    nothing
end
M = Diagonal([1.0, 1.0, 0.0])
prob = ODEProblem(ODEFunction(f!; mass_matrix = M), [V0, 0.0, 0.0], (0.0, 1e-4))

function first_steps(prob, alg; n = 12)
    steps = Tuple{Float64, Float64}[]
    cb = DiscreteCallback((u, t, i) -> (length(steps) < n && push!(steps, (i.t, i.t - i.tprev)); false),
                          i -> nothing; save_positions = (false, false))
    sol = solve(prob, alg; reltol = 1e-6, abstol = [1e-6, 1e-12, 1e-9], callback = cb)
    println(nameof(typeof(alg)), " from t0 = ", prob.tspan[1], ": ", sol.retcode, ", accepted ", sol.stats.naccept,
            ", rejected ", sol.stats.nreject, ", RHS ", sol.stats.nf)
    for (k, (t, dt)) in enumerate(steps)
        @printf("  step %2d  t = %.6e  dt = %.3e\n", k, t, dt)
    end
end

first_steps(prob, FBDF())
first_steps(prob, Rodas5P())
# Same problem, started at t0 = 1e-8 instead of 0:
first_steps(remake(prob; tspan = (1e-8, 1e-4 + 1e-8)), FBDF())

Output

FBDF from t0 = 0.0: Success, accepted 78, rejected 20, RHS 153
  step  1  t = 5.292564e-19  dt = 5.293e-19
  step  2  t = 1.765280e-18  dt = 1.236e-18
  step  3  t = 3.654173e-18  dt = 1.889e-18
  step  4  t = 5.989231e-18  dt = 2.335e-18
  step  5  t = 3.533193e-15  dt = 3.527e-15
  step  6  t = 5.994949e-14  dt = 5.642e-14
  step  7  t = 2.648581e-13  dt = 2.049e-13
  step  8  t = 7.275977e-13  dt = 4.627e-13
  step  9  t = 1.713662e-12  dt = 9.861e-13
  step 10  t = 3.811857e-12  dt = 2.098e-12
  step 11  t = 8.285541e-12  dt = 4.474e-12
  step 12  t = 1.777990e-11  dt = 9.494e-12
Rodas5P from t0 = 0.0: Success, accepted 8, rejected 0, RHS 98
  step  1  t = 1.000000e-06  dt = 1.000e-06
  step  2  t = 5.405816e-06  dt = 4.406e-06
  step  3  t = 1.406950e-05  dt = 8.664e-06
  step  4  t = 2.598128e-05  dt = 1.191e-05
  step  5  t = 4.083992e-05  dt = 1.486e-05
  step  6  t = 5.880102e-05  dt = 1.796e-05
  step  7  t = 7.955813e-05  dt = 2.076e-05
  step  8  t = 1.000000e-04  dt = 2.044e-05
FBDF from t0 = 1.0e-8: Success, accepted 75, rejected 13, RHS 137
  step  1  t = 1.000006e-08  dt = 6.250e-14
  step  2  t = 1.000006e-08  dt = 4.274e-16
  step  3  t = 1.000006e-08  dt = 3.534e-17
  step  4  t = 1.000006e-08  dt = 1.016e-17
  step  5  t = 1.000019e-08  dt = 1.222e-13
  step  6  t = 1.000091e-08  dt = 7.200e-13
  step  7  t = 1.000278e-08  dt = 1.874e-12
  step  8  t = 1.000677e-08  dt = 3.987e-12
  step  9  t = 1.001529e-08  dt = 8.525e-12
  step 10  t = 1.003339e-08  dt = 1.810e-11
  step 11  t = 1.007102e-08  dt = 3.764e-11
  step 12  t = 1.014828e-08  dt = 7.726e-11

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
  [1dea7af3] OrdinaryDiffEq v7.8.1
  [6ad6398a] OrdinaryDiffEqBDF v2.4.14
  [127b3ac7] OrdinaryDiffEqNonlinearSolve v2.9.10
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
  [47edcb42] ADTypes v1.24.0
  [14f7f29c] AMD v0.5.4
  [7d9f7c33] Accessors v0.1.46
  [79e6a3ab] Adapt v4.8.0
  [4fba245c] ArrayInterface v7.30.2
  [b2a6c25c] BinaryHeaps v1.1.0
  [70df07ce] BracketingNonlinearSolve v1.12.8
  [38540f10] CommonSolve v0.2.14
  [bbf7d656] CommonSubexpressions v0.3.1
  [34da2185] Compat v4.18.1
  [a33af91c] CompositionsBase v0.1.2
  [2569d6c7] ConcreteStructs v0.2.8
  [187b0558] ConstructionBase v1.6.1
  [a8cc5b0e] Crayons v4.2.0
  [9a962f9c] DataAPI v1.16.0
  [e2d170a0] DataValueInterfaces v1.0.0
  [8bb1440f] DelimitedFiles v1.9.1
  [2b5f629d] DiffEqBase v7.21.6
  [163ba53b] DiffResults v1.1.0
  [b552c78f] DiffRules v1.18.0
  [a0c0ee7d] DifferentiationInterface v0.7.22
⌅ [ffbed154] DocStringExtensions v0.9.5
  [4e289a0a] EnumX v1.0.7
  [f151be2c] EnzymeCore v0.8.27
  [e2ba6199] ExprTools v0.1.11
  [21656369] ExpressionExplorer v1.1.6
  [7034ab61] FastBroadcast v1.5.1
  [9aa1b823] FastClosures v0.3.2
  [a4df4552] FastPower v1.5.1
  [64ca27bc] FindFirstFunctions v3.4.1
  [6a86dc24] FiniteDiff v2.33.0
  [f6369f11] ForwardDiff v1.5.0
  [069b7b12] FunctionWrappers v1.1.3
  [77dc65aa] FunctionWrappersWrappers v1.13.0
  [46192b85] GPUArraysCore v0.2.2
  [3587e190] InverseFunctions v0.1.18
  [92d709cd] IrrationalConstants v0.2.7
  [82899510] IteratorInterfaceExtensions v1.0.0
  [692b3bcd] JLLWrappers v1.8.0
  [ba0b0d4f] Krylov v0.10.12
  [2faa5264] LHLFactorization v2.2.2
  [b964fa9f] LaTeXStrings v1.4.1
  [87fe0de2] LineSearch v0.1.20
  [7ed4a6bd] LinearSolve v5.18.3
  [2ab3a3ac] LogExpFunctions v1.0.6
  [e6f89c97] LoggingExtras v1.2.0
  [1914dd2f] MacroTools v0.5.16
  [bb5d69b7] MaybeInplace v0.1.8
  [46d2c3a1] MuladdMacro v0.2.7
  [77ba4419] NaNMath v1.1.5
  [8913a72c] NonlinearSolve v4.32.0
  [be0214bd] NonlinearSolveBase v2.55.1
  [5959db7a] NonlinearSolveFirstOrder v2.10.0
  [9a2c21bd] NonlinearSolveQuasiNewton v1.15.3
  [26075421] NonlinearSolveSpectralMethods v1.8.3
  [bac558e1] OrderedCollections v2.0.3
  [1dea7af3] OrdinaryDiffEq v7.8.1
  [6ad6398a] OrdinaryDiffEqBDF v2.4.14
  [bbf590c4] OrdinaryDiffEqCore v4.19.1
  [50262376] OrdinaryDiffEqDefault v2.6.2
  [4302a76b] OrdinaryDiffEqDifferentiation v3.12.5
  [127b3ac7] OrdinaryDiffEqNonlinearSolve v2.9.10
  [43230ef6] OrdinaryDiffEqRosenbrock v2.7.5
  [b4bd8bb3] OrdinaryDiffEqRosenbrockTableaus v2.4.2
  [2d112036] OrdinaryDiffEqSDIRK v2.9.8
  [b1df2697] OrdinaryDiffEqTsit5 v2.1.5
  [79d7bb75] OrdinaryDiffEqVerner v2.4.2
  [d236fae5] PreallocationTools v1.7.1
  [aea7be01] PrecompileTools v1.4.0
  [21216c6a] Preferences v1.6.1
  [08abe8d2] PrettyTables v3.5.1
  [0c0d3e7f] PureKLU v1.6.0
  [a3311ec8] ReactantCore v0.1.26
  [3cdcf5f2] RecipesBase v1.4.0
  [731186ca] RecursiveArrayTools v4.5.6
  [189a3867] Reexport v1.2.2
  [9fe22ead] RespecializeParams v1.3.0
  [7e49a35a] RuntimeGeneratedFunctions v0.5.27
  [0bca4576] SciMLBase v3.58.0
  [19f34311] SciMLJacobianOperators v0.1.20
  [a6db7da4] SciMLLogging v2.1.0
  [c0aeaf25] SciMLOperators v1.30.4
  [431bcebd] SciMLPublic v1.3.0
  [53ae85a6] SciMLStructures v1.10.6
  [efcf1570] Setfield v1.2.0
  [727e6d20] SimpleNonlinearSolve v2.14.6
  [ed01d8cd] Sobol v1.5.0
  [a57abbd0] SparseColumnPivotedQR v2.1.8
  [0a514795] SparseMatrixColorings v0.4.29
  [276daf66] SpecialFunctions v2.9.2
  [1e83bf80] StaticArraysCore v1.4.5
  [10745b16] Statistics v1.11.5
  [892a3eda] StringManipulation v0.6.1
  [2efcf032] SymbolicIndexingInterface v0.3.56
  [3783bdb8] TableTraits v1.0.1
  [bd369af6] Tables v1.14.0
  [a759f4b9] TimerOutputs v1.2.3
  [781d530d] TruncatedStacktraces v1.4.0
  [1d5cc7b8] IntelOpenMP_jll v2025.2.0+0
  [856f044c] MKL_jll v2025.2.0+0
  [efe28fd5] OpenSpecFun_jll v0.5.6+0
  [1317d2d5] oneTBB_jll v2023.1.0+0
  [0dad84c5] ArgTools v1.1.2
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [ade2ca70] Dates v1.11.0
  [8ba89e20] Distributed v1.11.0
  [f43a241f] Downloads v1.7.0
  [7b1f6079] FileWatching v1.11.0
  [9fa8497b] Future v1.11.0
  [b77e0a4c] InteractiveUtils v1.11.0
  [ac6e5ff7] JuliaSyntaxHighlighting v1.12.0
  [4af54fe1] LazyArtifacts v1.11.0
  [b27032c2] LibCURL v1.0.0
  [76f85450] LibGit2 v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.13.0
  [56ddb016] Logging v1.11.0
  [d6f4376e] Markdown v1.11.0
  [a63ad114] Mmap v1.11.0
  [ca575930] NetworkOptions v1.3.0
  [44cfe95a] Pkg v1.13.0
  [de0858da] Printf v1.11.0
  [3fa0cd96] REPL v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v1.0.0
  [9e88b42a] Serialization v1.11.0
  [6462fe0b] Sockets v1.11.0
  [2f01184e] SparseArrays v1.13.0
  [f489334b] StyledStrings v1.11.0
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [cf7118a7] UUIDs v1.11.0
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.5.5+2
  [deac9b47] LibCURL_jll v8.22.0+0
  [e37daf67] LibGit2_jll v1.9.7+0
  [29816b5a] LibSSH2_jll v1.11.104+0
  [14a3606d] MozillaCACerts_jll v2026.10.20
  [4536629a] OpenBLAS_jll v0.3.30+0
  [05823500] OpenLibm_jll v0.8.7+0
  [458c3c95] OpenSSL_jll v3.5.8+0
  [efcefdf7] PCRE2_jll v10.47.0+0
  [bea87d4a] SuiteSparse_jll v7.10.1+0
  [83775a58] Zlib_jll v1.3.2+0
  [3161d3a3] Zstd_jll v1.5.7+1
  [8e850b90] libblastrampoline_jll v5.15.0+0
  [8e850ede] nghttp2_jll v1.70.0+0
  [3f19e933] p7zip_jll v17.8.3+0
  • Output of versioninfo()
Julia Version 1.13.3
Commit 67ac47b9cd (2026-10-25 15:28 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 20 × 13th Gen Intel(R) Core(TM) i9-13900H
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.8 (ORCJIT, raptorlake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 20 virtual cores)

Additional context

This is what I found in the source:

Line numbers are for OrdinaryDiffEqBDF 2.4.14 and OrdinaryDiffEqCore 4.19.1.

  1. Order-1 step size comes from ‖h·y′‖, not from the error estimate. At order 1, stepsize_controller! for
    FBDF (src/controllers.jl, from line 396) sizes the next step from terk returned by estimate_terk!
    (src/bdf_utils.jl:391). At order 1 that is ‖u − uprev‖ in the weighted norm, i.e. ‖h·y′‖, not the local error
    estimate EEst (an h²·y″ quantity). Each step is therefore cut until the state moves by only a fraction of a
    tolerance, even when EEst is many orders of magnitude below 1.
  2. The first step's error estimate uses a zero-filled history time. reinitFBDF! (src/bdf_utils.jl:196) leaves
    ts zero-filled. The first step's error estimate in perform_step! (src/bdf_perform_step.jl, around line 1569,
    the terkp1_tmp *= j * dt / (tdt - ts[j]) loop) then uses ts[2] = 0. It scales with dt/(t + dt) and so depends on
    the absolute time; at t = 0 it is about 2‖u − uprev‖. This explains why starting at t0 = 1e-8 gives different first
    steps.
  3. After a rejected first step, the predictor is the rejected trial. On a reject, integrator.u is not reset
    (OrdinaryDiffEqCore src/integrators/integrator_utils.jl, the else # Reject branch around line 651). The retry
    therefore predicts from the rejected trial u instead of uprev, which inflated EEst 20–80× on the retries in
    our logs.
  4. No effective growth limit right after the start. After the collapse, dt grows 300–1700× in one step from a
    noise-level estimate (step 4 → 5 above: ×1510), although the FBDF constructor default is qmax = 10
    (src/algorithms.jl:555).

Possible solution

  • Size order-1 steps from EEst, as CVODE does. In FBDF's convention (dtnew = dt/q) that is q = (2·EEst)^(1/2),
    with a safety factor.
  • Predict the first step (and retries after a first-step rejection) from uprev.
  • Start from an h²·y″ estimate instead of a zero-filled history time. For example, use u − uprev − dt·f(uprev) on the
    differential rows, as CVODE's Nordsieck start does.
  • Cap step growth at about 5–10× per step during the start-up.

A local replacement of stepsize_controller!(integrator, ::FBDF) that does the first and last of these (error-based order-1 sizing and a 5× growth cap) made step counts identical across rounding-perturbed runs of our application DAE and cut RHS evaluations by 15–25 %, at equal or better accuracy. I could open a PR with this implementation if you think it would be useful.

Activity

  1. bobby404-K commented on Nov 17, 2026

    @bobby404-K

    Hi @johanandberger, this looks like a real issue. Let me try to reproduce it on my side. If you're opening the PR, I'm happy to help with a small piece, like testing or benchmarking, if you need it.

  2. johanandberger commented on Nov 17, 2026

    @johanandberger
    Author

    Hi @bobby404-K , thank you for the quick response. I have created a PR (with the help of Claude) that addresses the issue that you can look at, tests pass locally but I am not sure about next steps.

  3. bobby404-K commented on Nov 17, 2026

    @bobby404-K

    Thanks johan @johanandberger, I will run your reproducer plus a few other DAEs.

    yeah next step is CI, it's currently unapproved by maintainers should wait to run yet, so wait for it to finish, most probably a maintainer will review once it's green. It would help to say in the PR description that growth limiting (qmax) is left for a follow-up, which you already noted, and to mention the out-of-place mass-matrix and non-Newton cases that keep the old estimate. I'll also try those two cases and share what I find.

  4. johanandberger commented on Nov 17, 2026

    @johanandberger
    Author

    Thanks @bobby404-K, that would be very helpful, and agreed on waiting for CI.

    One update since my first description: I have since added the qmax growth limit to the PR itself, rather than
    leaving it for a follow-up. On some ODEs that start from a tiny initial dt, the second step could otherwise grow by
    up to 1e10. The updated description has the measurements.

    What is left for follow-ups is now listed under "Scope / known limitations":

    • the same growth limit for DFBDF;
    • FBDF(qmax = 5) with an Int failing in the constructor.

    The same section names the two cases that keep the old history-based first-step estimate: out-of-place problems with a
    mass matrix, and in-place mass-matrix problems with a non-Newton nonlinear solver. Your results on those would be very
    welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions