nyx_space/propagators/
mod.rs

1/*
2    Nyx, blazing fast astrodynamics
3    Copyright (C) 2018-onwards Christopher Rabotin <christopher.rabotin@gmail.com>
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU Affero General Public License as published
7    by the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Affero General Public License for more details.
14
15    You should have received a copy of the GNU Affero General Public License
16    along with this program.  If not, see <https://www.gnu.org/licenses/>.
17*/
18
19use anise::errors::MathError;
20use snafu::prelude::*;
21use std::fmt;
22
23/// Provides different methods for controlling the error computation of the integrator.
24pub mod error_ctrl;
25pub use self::error_ctrl::*;
26
27// Re-Export
28mod instance;
29pub use instance::*;
30mod propagator;
31pub use propagator::*;
32mod rk_methods;
33pub use rk_methods::*;
34mod options;
35use crate::{dynamics::DynamicsError, errors::EventError, io::ConfigError, time::Duration};
36pub use options::*;
37use serde::{Deserialize, Serialize};
38
39/// Stores the details of the previous integration step of a given propagator. Access as `my_prop.clone().latest_details()`.
40#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
41pub struct IntegrationDetails {
42    /// step size used
43    pub step: Duration,
44    /// error in the previous integration step
45    pub error: f64,
46    /// number of attempts needed by an adaptive step size to be within the tolerance
47    pub attempts: u8,
48}
49
50impl fmt::Display for IntegrationDetails {
51    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52        write!(
53            f,
54            "IntegrationDetails {{step: {}, error: {:.3e}, attempts: {}}}",
55            self.step, self.error, self.attempts
56        )
57    }
58}
59
60#[derive(Debug, PartialEq, Snafu)]
61pub enum PropagationError {
62    #[snafu(display("encountered a dynamics error {source}"))]
63    Dynamics { source: DynamicsError },
64    #[snafu(display("when propagating until an event: {source}"))]
65    TrajectoryEventError { source: EventError },
66    #[snafu(display("requested propagation until event #{nth} but only {found} found"))]
67    NthEventError { nth: usize, found: usize },
68    #[snafu(display("propagation failed because {source}"))]
69    PropConfigError { source: ConfigError },
70    #[snafu(display("propagation encountered a math error {source}"))]
71    PropMathError { source: MathError },
72}