Skip to content

Avoid dummy-derivative selections that are singular at the initial point - #5236

Draft
pankgeorg wants to merge 1 commit into
SciML:masterfrom
pankgeorg:dd-initial-point-selection
Draft

pankgeorg wants to merge 1 commit into
SciML:masterfrom
pankgeorg:dd-initial-point-selection

Conversation

@pankgeorg

Copy link
Copy Markdown
Contributor

Fixes #5212. Index reduction could pick states, or tearing a solve direction, that are singular at t0 (car axis: λ1 eliminated by dividing by 0.1 sin(10t); slider crank and Andrews' squeezer: the coordinate made algebraic has a vanishing or parallel constraint-Jacobian column at the initial configuration), with NaN in u0 or Unstable at the first step as the only signal.

  • dummy_derivative passes a numeric Jacobian at the initial point to StateSelection.dummy_derivative_graph!, which only re-selects when the structural choice is rank-deficient there (Use the initial point to avoid singular dummy-derivative selections and solve directions JuliaComputing/StateSelection.jl#164). The initial point comes from initial_conditions, bindings and the system's tspan; the new mtkcompile(sys; initial_point = ...) keyword supplies it explicitly (e.g. the u0 map or guesses(sys)). Guesses are not used implicitly.
  • Problem construction warns when u0 contains non-finite values, distinguishing values given by the caller from values derived by initialization (the symptom of a selection that is singular at t0).

Tested: test/structural_transformation/initial_point_selection.jl (fails before, passes after; includes cases asserting the selection is unchanged when the structural choice is non-singular or the initial point is unknown). Requires StateSelection 1.12 and ModelingToolkitTearing 1.21.

🤖 Generated with Claude Code

`dummy_derivative` now passes a numeric Jacobian evaluated at the initial
point of the system to `StateSelection.dummy_derivative_graph!`, which
re-selects only when the structural choice is rank-deficient there. Only
structurally incident pairs are differentiated. The initial point comes
from the initial conditions, bindings and `tspan` of the system, or from
the new `initial_point` keyword of `mtkcompile`.

Problem construction warns when `u0` contains non-finite values, telling
values given by the caller apart from values derived by initialization,
the symptom of a selection or solve direction that is singular at `t0`.

Requires StateSelection 1.12 and ModelingToolkitTearing 1.21.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@baggepinnen

Copy link
Copy Markdown
Contributor

To the AI bot, please run the tests of MultibodyComponents.jl with this PR before merging.

@pankgeorg

Copy link
Copy Markdown
Contributor Author

To the AI bot, please run the tests of MultibodyComponents.jl with this PR before merging.

My bot (too scared to talk to you) says it did:

@baggepinnen ran the MultibodyComponents.jl tests against this PR (MultibodyComponents main c3a777b, with StateSelection 1.12.0 + MTKTearing 1.21.0 from #164 and the MTK branch of #5236, Julia 1.12.7, TEST_RENDERING=false so no GLMakie): all pass.

test_spherical 630/630, test_planar_mechanics 240/240, test_suspension 22 pass + 2 already marked broken, test_traj 59/59, test_urdf 11/11, test_render_analysis 18/18, manual_tests 465/465 — 1445 pass, 0 fail. Only the rendering tests were skipped.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tearing picks a pivot that vanishes at t0 (time-dependent constraint coefficient): NaN initial value, no warning

2 participants