Skip to content

Unify ODE solution types: DAESolution, RODESolution as ODESolution aliases#1261

Open
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:unify-solution-types
Open

Unify ODE solution types: DAESolution, RODESolution as ODESolution aliases#1261
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:unify-solution-types

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

  • Expands ODESolution to carry the union of all fields from the previously separate types: du (derivatives, from DAESolution), W (noise process, from RODESolution), and seed (random seed, from RODESolution)
  • DAESolution and RODESolution are now const aliases for ODESolution, eliminating redundant struct definitions
  • All build_solution dispatches create ODESolution directly, with problem-type dispatch determining which fields are populated
  • calculate_solution_errors! is unified into a single implementation that branches on problem type (AbstractDAEProblem, AbstractRODEProblem/AbstractSDDEProblem, AbstractDDEProblem, or standard ODE)
  • Removes ~290 lines of duplicated code across dae_solutions.jl and rode_solutions.jl (duplicate getproperty, solution_new_retcode, solution_new_tslocation, solution_slice, ConstructionBase methods, callable methods, etc.)
  • isdenseplot now checks sol.prob type instead of sol isa AbstractRODESolution

Breaking changes

  • ODESolution struct has new fields (du, W, seed) which changes its type parameters
  • Code dispatching on the concrete types DAESolution or RODESolution will now match any ODESolution (since they are aliases)
  • Code dispatching on AbstractDAESolution or AbstractRODESolution with concrete solution values will no longer match (since the concrete type is always ODESolution <: AbstractODESolution)
  • The abstract types AbstractDAESolution, AbstractDDESolution, AbstractRODESolution are unchanged and remain in the hierarchy for interface purposes

Test plan

  • All SciMLBase unit tests pass
  • Downstream solver packages (OrdinaryDiffEq, StochasticDiffEq, DASKR, Sundials) need testing for compatibility

🤖 Generated with Claude Code

…or ODESolution

ODESolution now carries the union of all fields from the previous separate types:
- `du` (from DAESolution) for derivative values
- `W` (from RODESolution) for noise process
- `seed` (from RODESolution) for random seed

DAESolution and RODESolution are now const aliases for ODESolution.
All build_solution dispatches create ODESolution directly.
calculate_solution_errors! is unified with problem-type dispatch.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ChrisRackauckas
Copy link
Copy Markdown
Member

RFC @oscardssmith @TorkelE @isaacsas should we do this with the major v7 coming up? It would improve the autodiff code a lot.

@oscardssmith
Copy link
Copy Markdown
Member

Is the improvement just that there would be less duplication?

@ChrisRackauckas
Copy link
Copy Markdown
Member

yes

@isaacsas
Copy link
Copy Markdown
Member

isaacsas commented Mar 1, 2026

Seems reasonable to me, but I don't use DAESolution or RODESolution, so don't have a great idea of how disruptive this would be.

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.

4 participants