59 lines
1.8 KiB
Markdown
59 lines
1.8 KiB
Markdown
# DifferentialEquations
|
|
|
|
A library, written in Rust, for integrating ordinary differential equations. For now, this is
|
|
relatively simple, but it does have key features that are needed for orbit propagation, ray tracing,
|
|
and field line tracing:
|
|
|
|
## Features
|
|
|
|
- A relatively efficient Dormand Prince 5th(4th) order integration algorithm, which is effective for
|
|
non-stiff problems
|
|
- A PI-controller for adaptive time stepping
|
|
- The ability to define "callback events" and stop or change the integator or underlying ODE if
|
|
certain conditions are met (zero crossings)
|
|
- A fourth order interpolator for the Domand Prince algorithm
|
|
|
|
|
|
### Future Improvements
|
|
|
|
- More algorithms
|
|
- Rosenbrock
|
|
- Verner
|
|
- Tsit(5)
|
|
- Runge Kutta Cash Karp
|
|
- Parameters in the derivative and callback functions
|
|
- Composite Algorithms
|
|
- Automatic Stiffness Detection
|
|
- Fixed Time Steps
|
|
- Boolean callback eventing
|
|
- Improved solution handling like `DifferentialEquations.jl`
|
|
|
|
## To Use
|
|
|
|
For now, here is a simple example of using the propagator to solve a simple system:
|
|
|
|
```rust
|
|
use nalgebra::Vector3;
|
|
use differential_equations::integrator::dormand_prince::DormandPrince45;
|
|
use differential_equations::controller::PIController;
|
|
use differential_equations::callback::stop;
|
|
use differential_equations::problem::*;
|
|
|
|
// Define the system
|
|
fn derivative(_t: f64, y: Vector3<f64>) -> Vector3<f64> { y }
|
|
let y0 = Vector3::new(1.0, 1.0, 1.0);
|
|
|
|
let ode = ODE::new(&derivative, 0.0, 10.0, y0);
|
|
let dp45 = DormandPrince45::new(1e-12_f64, 1e-5_f64);
|
|
let controller = PIController::default();
|
|
|
|
let value_too_high = Callback {
|
|
event: &|_: f64, y: SVector<f64,3>| { 10.0 - y[0] },
|
|
effect: &stop,
|
|
};
|
|
|
|
let mut problem = Problem::new(ode, dp45, controller).with_callback(value_too_high);
|
|
let solution = problem.solve();
|
|
let interpolated_answer = solution.interpolate(8.2);
|
|
```
|