Repository navigation
Minimal SCCNonlinearProblem support for SSRootfind and DynamicSS - #166
ChrisRackauckas merged 5 commits into
Conversation
An SCCNonlinearProblem has no top-level u0/kwargs fields, so the generic AbstractNonlinearProblem solve preprocessing cannot handle it. solve(prob::SCCNonlinearProblem, alg::SSRootfind) now bypasses that path and forwards the problem directly to the wrapped algorithm, where SCCNonlinearSolve.jl's dispatches solve it in SCC order while preserving the linear/nonlinear block decomposition. The returned solution wraps the inner solve as `original`, matching the SteadyStateProblem path. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
A second `solve` specialization: `solve(prob::SCCNonlinearProblem, alg::DynamicSS)` bypasses the generic nonlinear solve path and integrates the pseudo-transient system `u' = g(u)`, where `g` is the concatenated residual of the SCC blocks evaluated at the trial state. Upstream trial values reach each block's parameter cache through `explicitfuns!`, exactly as in the SCC solve. Linear blocks contribute `b - A*u` (ModelingToolkit's `calculate_A_b` encodes `A*u - b = -expr`); homotopy blocks are evaluated at `λ = 1`. The problem is deep-copied since `explicitfuns!` mutate the block caches on every residual call, and the result is wrapped on the original problem with the inner steady-state solve as `original`. ModelingToolkit needs no integration change: its generated SCCNonlinearProblems solve through this path, and MTK SteadyStateProblems whose `initialization_data.initializeprob` is an SCCNonlinearProblem already work through the ODE initialization machinery. Both directions are covered by the new tests. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
|
Companion MTK PR: SciML/ModelingToolkit.jl#5155 — |
Replace the monolithic-residual integration with the SCC solve protocol: each block's parameter cache is updated from upstream solutions through explicitfuns!, LinearProblem blocks are solved directly, and nonlinear blocks are integrated to steady state by DynamicSS on the block residual. Direct linear solves no longer require b - A*u to be attracting, and convergence only needs each nonlinear block to be attracting under its own pseudo-transient dynamics rather than a globally attracting concatenated field. HomotopyProblem blocks evaluate the residual at the lambda endpoint of lambda_span, which is the actual system. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_f9264d4995564dac.md (local transcript; no shareable URL)
A SteadyStateProblem carrying lowered_problem now does an SCC-style solve: DynamicSS delegates to the sequential block solve and SSRootfind's NonlinearProblem(prob) conversion already returns the lowering. The inner solution is expressed on the lowered problem since its block ordering need not match the steady-state problem's u0. The alias/verbose specifiers injected by the nonlinear solve pipeline are stripped when forwarding to an SCCNonlinearProblem because LinearProblem block solves reject the nonlinear specifier types. Requires SciMLBase 3.55 for the lowered_problem field. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
|
Done —
Two subtleties handled:
Verified end-to-end against the MTK branch (SciML/ModelingToolkit.jl#5155): One behavioral note: per-block pseudo-transient solves can converge to a different root of a multi-rooted nonlinear block than the monolithic field would — same basin-dependence as per-block Newton. |
MTK 11.44 ships the lowered_problem storage (SciML/ModelingToolkit.jl#5155), so MTK-built SteadyStateProblems always carry the SCC builder and the tests can assert the delegation unconditionally. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
Ships SCCNonlinearProblem support: minimal handling for SSRootfind and DynamicSS (#166) and sequential solving of SCC blocks under SICNM (#167). Minor because it adds problem-type support. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude <[email protected]> Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
Ships SCCNonlinearProblem support: minimal handling for SSRootfind and DynamicSS (#166) and sequential solving of SCC blocks under SICNM (#167). Minor because it adds problem-type support. Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL) Co-authored-by: Claude <[email protected]>
Summary
Minimal version of #165:
SCCNonlinearProblemcan be pushed straight at the steady-state algorithms.SSRootfind—solve(prob::SCCNonlinearProblem, alg::SSRootfind)forwards the problem directly to the wrapped algorithm (alg.alg), where SCCNonlinearSolve.jl's dispatches solve it in SCC order. This works becauseSSRootfind's only job is to route a problem to a nonlinear solver — and anSCCNonlinearProblemis the nonlinear problem, just pre-decomposed:alg === nothing→SCCAlg()defaultalg isa AbstractNonlinearAlgorithm(e.g.NewtonRaphson()) → wrapped inSCCAlg(nlalg = alg)alg isa SCCAlg→ separate linear/nonlinear block solver configurationDynamicSS—solve(prob::SCCNonlinearProblem, alg::DynamicSS)solves the blocks sequentially in SCC order, following theSCCNonlinearSolveprotocol: each block's parameter cache is updated from the upstream solutions throughexplicitfuns!, then:LinearProblemblocks are solved directly (remake(block; A, b)recomputesA/bthroughSymbolicLinearInterfacefor MTK-generated blocks, then a plain linear solve). This needs no stability assumption — a negative-definiteAstill solves correctly, whereas integratingb - A*uwould repel.DynamicSSon the block residual through the existing__solvepath — convergence only requires each block to be attracting under its own pseudo-transient dynamics, not a globally attracting concatenated field. (Note the per-block field can converge to a different root of a multi-rooted block than the monolithic field would — that is inherent to blockwise pseudo-transient solves, same as per-block Newton.)HomotopyProblemblocks take aDynamicSSbranch evaluating the residual atλ = λspan[2](the actual system end). They bypasssolve's preprocessing, which has noget_concrete_problemforHomotopyProblem, and go through__solvedirectly.The per-block solutions are aggregated by concatenating
u/resid(block order =state_values(prob)order) and stored onsol.original, so each block's innerDynamicSSsolve — and itsODESolution— remains recoverable. A failing block's retcode propagates.An
SCCNonlinearProblemhas no top-levelu0/kwargs/f, so it cannot go through the genericAbstractNonlinearProblemsolve preprocessing in NonlinearSolveBase — both areSciMLBase.solveoverrides for that reason.A
SteadyStateProblemcarrying SCC information does an SCC-style solve. With SciMLBase 3.55'sSteadyStateProblem.lowered_problemfield (SciML/SciMLBase.jl#1603, merged),DynamicSSchecks the materialized lowering and delegates to the sequential block solve when it is anSCCNonlinearProblemrather than running one monolithic integration.SSRootfindgets the same routing for free throughNonlinearProblem(prob), which now prefers the stored lowering. Two consequences handled here:sol.probis theSCCNonlinearProblem), because the lowering defines its own state ordering — MTK's torn SCC order differs fromprob.u0's, and may even have a different length (eliminated unknowns). Wrapping it as the outer problem would silently break symbolic indexing.alias/verbosespecifiers injected by the nonlinear solve pipeline are stripped when forwarding to anSCCNonlinearProblem: they arrive asNonlinearAliasSpecifier/NonlinearVerbosity, whichLinearProblemblock solves insideSCCNonlinearSolvereject (LinearSolvewantsLinearAliasSpecifier/LinearVerbosity).Compat:
SciMLBase = "3.55", test depModelingToolkit = "11.44"(the release carrying thelowered_problemstorage, SciML/ModelingToolkit.jl#5155).SymbolicIndexingInterfaceis added as a direct dep (parameter_values, already transitive via SciMLBase; MIT-licensed like the rest of the dep set).SCCNonlinearSolvestays a test-only dependency.This drops the rest of #165's scope (the
SCCalgorithm type, thescale/unscalenonlinear scaling machinery, and the ModelingToolkit extension), which the PR author also noted should live elsewhere.Companion work: SciML/SciMLBase.jl#1603 (merged, released in 3.55.0) adds the
SteadyStateProblem.lowered_problemslot with remake-correctprob -> problembuilders, and SciML/ModelingToolkit.jl#5155 (merged, released in MTK 11.44.0) stores the SCC lowering there — verified end-to-end against the released MTK: an MTK-builtSteadyStateProblemroutes through the sequential SCC solve underDynamicSSand the decomposition underSSRootfind, withsol[states]symbolic indexing intact.Test plan
test/scc.jl— 336 tests: allSSRootfindvariants on a manual coupledSCCNonlinearProblem(iip × oop, tuple × vector), failure propagation, sequentialDynamicSS(Tsit5())on manual + MTK-built decompositions exercisingLinearProblem/NonlinearProblem/HomotopyProblemblocks (iip × oop), a direct-solve discrimination case (A = -1, repelling under residual dynamics), a non-converging-residual failure case, andSteadyStateProblems with stored SCC lowerings (verbatim + callable builder) solved through the lowering by bothDynamicSSandSSRootfindSteadyStateProblem(sys, op)+DynamicSS→ sequential SCC solve (sol.prob isa SCCNonlinearProblem, per-blockoriginal), +SSRootfind→ decomposition solve;remake(prob; u0)lowering reflects new valuesA = -1linear block diverges toe^10 ≈ 22026, andsol.originalhas the old shape); it passes with this changeGROUP=Core julia --project -e 'using Pkg; Pkg.test()'— all pass locallytest/qa) — 21 pass + reexport surface 16 (Aqua / ExplicitImports / JET)typosover the diffChecklist
🤖 Generated with Devin CLI (model: SWE-2 Max). Session: local transcript at
/home/crackauc/.local/share/devin/cli/summaries/history_45335a77847a4532.md(no shareable URL for this harness).