Skip to content

Add automatic initial timestep selection to Simulation#227

Merged
milanofthe merged 1 commit into
masterfrom
feat/auto-initial-step
Jun 23, 2026
Merged

Add automatic initial timestep selection to Simulation#227
milanofthe merged 1 commit into
masterfrom
feat/auto-initial-step

Conversation

@milanofthe

Copy link
Copy Markdown
Member

Adds automatic initial timestep selection following Hairer-Norsett-Wanner.

  • Simulation.estimate_initial_step() forms a first guess from the scaled norms of the state and its derivative, then refines it with a second-derivative estimate from an explicit Euler probe (a pure evaluation, no actual timestep / no events). Scaling uses the engine error tolerances.
  • Blocks expose their state derivative through a new Block.derivative(t) accessor: the base implementation covers blocks with a dynamic operator (ODE, DynamicalSystem, LTI, and the DAE blocks via their reduced operator); Integrator overrides it; stateless blocks return None and are skipped.
  • Passing dt=None to the simulation triggers the estimate at the start of the run; otherwise behaviour is unchanged.

Tests cover the derivative accessor, step scaling with the dynamics, state restoration, and an end-to-end auto-dt run.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.87755% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pathsim/simulation.py 93.02% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@milanofthe milanofthe merged commit 7e8a506 into master Jun 23, 2026
4 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.

1 participant