Integrator Configuration¶
Proper integrator configuration is essential for balancing accuracy, performance, and reliability. This guide explains all configuration parameters and how to choose appropriate values.
IntegratorConfig Class¶
The IntegratorConfig class encapsulates all settings for adaptive-step integrators. Key parameters include:
- Error Tolerances:
abs_tol,rel_tol - Step Size Limits:
min_step,max_step - Step Size Control:
step_safety_factor,min_step_scale_factor,max_step_scale_factor - Maximum Step Attempts:
max_step_attempts
Configuration Parameters¶
Error Tolerances¶
abs_tol (float): Absolute error tolerance
- Controls maximum absolute error allowed per step
- Units match state units (meters for position, m/s for velocity)
- Prevents excessively small steps when state approaches zero
rel_tol (float): Relative error tolerance
- Controls maximum relative error as fraction of state magnitude
- Dimensionless
- Scales with state magnitude
Combined tolerance:
Step Size Limits¶
min_step (float): Minimum allowed step size (seconds)
- Safety limit preventing infinitesimally small steps
- If integrator hits this limit repeatedly, tolerances may be too tight
max_step (float): Maximum allowed step size (seconds)
- Prevents missing important dynamics by taking too-large steps
- Critical for problems with events or discontinuities
Step Size Control¶
step_safety_factor (float): Safety margin for step size adjustment
- Multiplier applied to calculated optimal step size
- Makes step size more conservative
- Default: 0.9 (use 90% of optimal)
- Range: 0.8 to 0.95
Formula:
Decreasing the safety factor results in smaller steps and higher accuracy but more function evaluations. Increasing it yields larger steps and faster performance but risks exceeding error tolerances and more rejections, which in turn results in wasted computation.
min_step_scale_factor (float): Minimum step size change ratio
- Prevents dramatic step size reductions
- Ensures step doesn't shrink too rapidly
- Default: 0.2 (can shrink to 20% of current)
max_step_scale_factor (float): Maximum step size change ratio
- Prevents dramatic step size increases
- Ensures gradual adaptation
- Default: 10.0 (can grow to 10× current)
Why limit step changes: - Prevents oscillating step sizes - Smooths adaptation
Step Attempts¶
max_step_attempts (int): Maximum retry attempts before error
- If step rejected more than this many times, raise error
- Prevents infinite loops with pathological problems
- Default: 10
Typical causes of many rejections: 1. Tolerances too tight for integrator order 2. Stiff differential equations 3. Discontinuity in dynamics 4. Bug in dynamics function
Configuration Examples¶
These examples illustrate different parameter combinations representing different points on the accuracy-performance spectrum:
Conservative Configuration¶
Tight tolerances and restrictive step size controls:
Balanced Configuration¶
Moderate settings suitable for many applications:
Aggressive Configuration¶
Relaxed tolerances for faster computation:
High-Precision Configuration¶
Very tight tolerances for high-accuracy needs:
Tuning Strategy¶
1. Start with Defaults¶
2. Assess Performance¶
Run test integration and monitor: - Number of steps taken - Number of rejected steps (should be < 1%) - Error estimates - Step size variation
3. Adjust Based on Observations¶
If steps too small:
If missing features:
If many rejections:
If hitting min_step:
4. Validate¶
Compare against:
- Analytical solution (if available)
- Same integration with 10× tighter tolerances
- Energy/momentum conservation
- Independent integration software
5. Document¶
Record final configuration with rationale:
See Also¶
- Adaptive-Step Integrators - How adaptive integration works
- Fixed-Step Integrators - Fixed-step integration guide
- Configuration API Reference - Complete API documentation
- Integrators Overview - Comparison of all integrators