Skip to content

Conversation

ChrisRackauckas
Copy link
Member

Summary

This PR removes the ModelingToolkit dependency from ODEProblemLibrary by rewriting all ModelingToolkit-dependent example problems to use direct ODE function definitions instead of symbolic computation. This significantly improves compilation speed and eliminates circular dependency issues.

Motivation

  • Circular dependency issue: ModelingToolkit → DiffEqCallbacks → ODEProblemLibrary → ModelingToolkit was causing precompilation failures
  • Slow compilation: Symbolic computation overhead was making package loading slow
  • Dependency bloat: ModelingToolkit added significant dependency footprint for simple ODE examples

Changes Made

Dependencies

  • Removed ModelingToolkit from [deps] in Project.toml
  • Removed Latexify dependency (was only used for ModelingToolkit documentation)
  • Removed RuntimeGeneratedFunctions dependency (not needed for direct ODE functions)

Rewritten Problems

ode_simple_nonlinear_prob.jl:

  • Van der Pol equations (prob_ode_vanderpol, prob_ode_vanderpol_stiff)
  • ROBER biochemical reactions (prob_ode_rober)
  • Rigid body equations (prob_ode_rigidbody)
  • Hires problem (prob_ode_hires)
  • Orego problem (prob_ode_orego)

strange_attractors.jl:

  • Thomas cyclically symmetric attractor (prob_ode_thomas)
  • Lorenz equations (prob_ode_lorenz)
  • Aizawa equations (prob_ode_aizawa)
  • Dadras equations (prob_ode_dadras)
  • Chen equations (prob_ode_chen)
  • Rössler equations (prob_ode_rossler)
  • Rabinovich-Fabrikant equations (prob_ode_rabinovich_fabrikant)
  • Sprott equations (prob_ode_sprott)
  • Hindmarsh-Rose equations (prob_ode_hindmarsh_rose)

Benefits

Faster compilation: No symbolic computation overhead
Eliminated circular dependencies: Resolves ModelingToolkit circular dependency
Reduced dependency footprint: Fewer dependencies to install and manage
Better test reliability: No more precompilation failures
Maintained API compatibility: All exports remain the same
Preserved accuracy: Same mathematical formulations, initial conditions, and parameters

Testing

  • All Aqua.jl quality assurance tests pass
  • All rewritten problems maintain correct dimensions, initial conditions, and parameters
  • ODE functions are callable and produce finite derivatives
  • Backward compatibility maintained with existing code
  • No breaking changes to the public API

Example: Van der Pol Before/After

Before (ModelingToolkit):

@parameters μ
@variables x(t) y(t)
eqs = [D(y) ~ μ * ((1 - x^2) * y - x), D(x) ~ y]
van = System(eqs, t; name = :van_der_pol) |> mtkcompile
prob_ode_vanderpol = ODEProblem(van, [y => 0, x => sqrt(3), μ => 1.0], (0.0, 1.0))

After (Direct ODE):

function vanderpol(du, u, p, t)
    x, y = u
    μ = p[1]
    du[1] = y
    du[2] = μ * ((1 - x^2) * y - x)
end
prob_ode_vanderpol = ODEProblem(vanderpol, [sqrt(3), 0.0], (0.0, 1.0), [1.0])

Test Plan

  • All Aqua.jl tests pass
  • Package loads without ModelingToolkit dependency
  • All problem exports are available
  • ODE functions produce correct derivatives
  • Initial conditions and parameters are preserved
  • No circular dependency warnings

🤖 Generated with Claude Code

…ompilation

This PR rewrites the ModelingToolkit-dependent example problems to use direct ODE function definitions instead of symbolic computation, which significantly improves compilation speed and eliminates circular dependency issues.

## Changes Made

- **Removed ModelingToolkit dependency**: Eliminated ModelingToolkit from dependencies in Project.toml
- **Rewritten ODE problems**: Converted all symbolic ODE definitions to direct function definitions
- **Maintained API compatibility**: All problem exports remain the same
- **Preserved problem accuracy**: Same initial conditions, parameters, and mathematical formulations

## Problems Rewritten

### ode_simple_nonlinear_prob.jl
- Van der Pol equations (prob_ode_vanderpol, prob_ode_vanderpol_stiff)
- ROBER biochemical reactions (prob_ode_rober)
- Rigid body equations (prob_ode_rigidbody)
- Hires problem (prob_ode_hires)
- Orego problem (prob_ode_orego)

### strange_attractors.jl
- Thomas cyclically symmetric attractor (prob_ode_thomas)
- Lorenz equations (prob_ode_lorenz)
- Aizawa equations (prob_ode_aizawa)
- Dadras equations (prob_ode_dadras)
- Chen equations (prob_ode_chen)
- Rössler equations (prob_ode_rossler)
- Rabinovich-Fabrikant equations (prob_ode_rabinovich_fabrikant)
- Sprott equations (prob_ode_sprott)
- Hindmarsh-Rose equations (prob_ode_hindmarsh_rose)

## Benefits

- **Faster compilation**: No symbolic computation overhead
- **Eliminated circular dependencies**: No more ModelingToolkit → DiffEqCallbacks → ODEProblemLibrary → ModelingToolkit cycle
- **Reduced dependency footprint**: Fewer dependencies to install and manage
- **Better test reliability**: No more precompilation failures due to circular dependencies

## Testing

- All tests pass (Aqua.jl quality assurance)
- All rewritten problems maintain correct dimensions, initial conditions, and parameters
- ODE functions are callable and produce finite derivatives
- Maintains backward compatibility with existing code

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

Co-Authored-By: Claude <[email protected]>
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