Skip to content

Conversation

ChrisRackauckas-Claude
Copy link

Summary

  • Fixed stack overflow errors in ND1-ND5 problems in the Enright-Pryce benchmark suite
  • Simplified symbolic expressions to avoid ModelingToolkit compilation issues
  • Maintained mathematical correctness while improving compilation stability

Problem

The ND problems (orbital mechanics/Kepler orbit benchmarks) were causing stack overflow errors during compilation. The root cause was the complex symbolic expression:

r = sqrt(y[1]^2 + y[2]^2)^3

When used in the gravitational force equations (-y[1]) / r and (-y[2]) / r, this created overly complex symbolic manipulations that caused ModelingToolkit's symbolic engine to exceed stack limits during compilation.

Solution

Replaced the complex expression with mathematically equivalent intermediate variables:

# Before (causes stack overflow):
r = sqrt(y[1]^2 + y[2]^2)^3

# After (compiles successfully):
r_squared = y[1]^2 + y[2]^2
r_cubed = r_squared * sqrt(r_squared)  

This represents the same physics (gravitational force law F ∝ 1/r³) but breaks down the symbolic computation into manageable steps.

Test Plan

  • Verified ND problems compile without stack overflow
  • Confirmed mathematical equivalence of the expressions
  • All five ND problems (ND1-ND5) with different eccentricities should now work
  • Run full benchmark suite to verify performance characteristics unchanged

The fix specifically addresses the compilation issue reported in the Enright-Pryce benchmarks documentation where all ND problems showed "StackOverflowError".

🤖 Generated with Claude Code

The ND problems (ND1-ND5) in the Enright-Pryce benchmark suite were causing
stack overflow errors during ModelingToolkit compilation. The issue was caused
by the complex symbolic expression `r = sqrt(y[1]^2 + y[2]^2)^3` which created
overly complex symbolic manipulations when used in the gravitational force equations.

This fix breaks down the calculation into intermediate variables:
- r_squared = y[1]^2 + y[2]^2
- r_cubed = r_squared * sqrt(r_squared)

This mathematically equivalent formulation is much simpler for the symbolic
system to handle, resolving the compilation stack overflow while maintaining
the same physics (Kepler orbital dynamics).

Fixes the stack overflow issues reported in the ND benchmark suite.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit 4a6e8c1 into SciML:master Aug 29, 2025
1 of 2 checks passed
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.

2 participants