[][src]Module nyx_space::dynamics

Provides several dynamics used for orbital mechanics and attitude dynamics, which can be elegantly combined.

Simple two body propagation

extern crate nalgebra as na;
extern crate hifitime;
extern crate nyx_space as nyx;
use hifitime::julian::ModifiedJulian;
use hifitime::SECONDS_PER_DAY;
use nyx::celestia::{Cosm, Geoid, State};
use nyx::dynamics::celestial::TwoBody;
use nyx::dynamics::Dynamics;
use nyx::propagators::error_ctrl::RSSStepPV;
use nyx::propagators::{PropOpts, Propagator, RK89};

fn main() {
    let cosm = Cosm::from_xb("./de438s");
    let earth_geoid = cosm.geoid_from_id(3).unwrap();

    let dt = ModifiedJulian { days: 21545.0 };
    let initial_state = State::<Geoid>::from_cartesian(-2436.45, -2436.45, 6891.037, 5.088611, -5.088611, 0.0, dt, earth_geoid);

    println!("Initial state:\n{0}\n{0:o}\n", initial_state);

    let prop_time = 24.0 * 3_600.0;
    let accuracy = 1e-12;
    let min_step = 0.1;
    let max_step = 60.0;

    let rslt = State::<Geoid>::from_cartesian(
            -5_971.194_376_784_884,
            3_945.517_912_191_541,
            2_864.620_958_267_658_4,
            0.049_083_102_073_914_83,
            -4.185_084_126_130_087_5,
            5.848_947_462_252_259_5,
            ModifiedJulian { days: 21546.0 },
            earth_geoid,
    );

    let mut dyn = TwoBody::from_state_vec(initial_state.to_cartesian_vec(), earth_geoid);
    let mut prop = Propagator::new::<RK89>(
        &mut dyn,
        &PropOpts::with_adaptive_step(min_step, max_step, accuracy, RSSStepPV {}),
    );
    let (final_t, final_state0) = prop.until_time_elapsed(prop_time);

    let final_dt = ModifiedJulian {
        days: dt.days + final_t / SECONDS_PER_DAY,
    };
    let final_state = State::from_cartesian_vec(&prop.state(), final_dt, earth_geoid);
    assert_eq!(final_state, rslt, "two body prop failed");
    assert_eq!(prop.state(), final_state0, "until_time_elapsed returns the wrong value");

    println!("Final state:\n{0}\n{0:o}", final_state);
}

Modules

celestial

The celestial module handles all Cartesian based dynamics.

drag

The drag module handles drag in a very basic fashion. Do not use for high fidelity dynamics.

gravity

The gravity module handles spherical harmonics only. It must be combined with a TwoBody dynamics

momentum

The angular momentum module handles all angular momentum dynamics.

Traits

Dynamics

The Dynamics trait handles and stores any equation of motion and the state is integrated.