pub struct Simulation { /* private fields */ }Expand description
Owned REBOUND simulation. Freed on drop.
Not Send/Sync — each thread must create its own simulation.
Implementations§
Source§impl Simulation
impl Simulation
Sourcepub fn new() -> Result<Simulation, Error>
pub fn new() -> Result<Simulation, Error>
Create a new, empty REBOUND simulation.
Sourcepub fn as_ptr(&self) -> *const reb_simulation
pub fn as_ptr(&self) -> *const reb_simulation
Raw const pointer to the underlying REBOUND simulation. Downstream
-sys crates layered on top of REBOUND use this to call ASSIST /
other C APIs that take *const reb_simulation.
Sourcepub fn as_mut_ptr(&mut self) -> *mut reb_simulation
pub fn as_mut_ptr(&mut self) -> *mut reb_simulation
Raw mutable pointer to the underlying REBOUND simulation. Required by
C APIs that take *mut reb_simulation (assist_attach, assist_detach,
etc.) and by benchmark probes.
pub fn t(&self) -> f64
pub fn set_t(&mut self, t: f64)
pub fn dt(&self) -> f64
pub fn set_dt(&mut self, dt: f64)
pub fn n_particles(&self) -> usize
Sourcepub fn steps_done(&self) -> u64
pub fn steps_done(&self) -> u64
Total IAS15 steps (accepted + rejected) since this simulation was created. Useful for diagnosing adaptive-timestep behavior.
pub fn n_var(&self) -> i32
pub fn status(&self) -> i32
pub fn set_exact_finish_time(&mut self, v: bool)
Sourcepub fn ias15_epsilon(&self) -> f64
pub fn ias15_epsilon(&self) -> f64
IAS15 precision parameter (REBOUND r->ri_ias15.epsilon). Default 1e-9.
Larger values are looser but faster.
pub fn set_ias15_epsilon(&mut self, eps: f64)
Sourcepub fn ias15_min_dt(&self) -> f64
pub fn ias15_min_dt(&self) -> f64
IAS15 minimum timestep floor (REBOUND r->ri_ias15.min_dt). When the
adaptive step would shrink below this, it clamps instead of grinding.
Default 0 = no floor.
pub fn set_ias15_min_dt(&mut self, min_dt: f64)
Sourcepub fn ias15_adaptive_mode(&self) -> Ias15AdaptiveMode
pub fn ias15_adaptive_mode(&self) -> Ias15AdaptiveMode
IAS15 adaptive-timestep selector. Default Prs23 (REBOUND default
since 2024-01).
pub fn set_ias15_adaptive_mode(&mut self, mode: Ias15AdaptiveMode)
Sourcepub fn ias15_iterations_max_exceeded(&self) -> u64
pub fn ias15_iterations_max_exceeded(&self) -> u64
Diagnostic counter: how many IAS15 steps hit the predictor-corrector
iteration cap without converging. Monotone-increasing across the
simulation lifetime; nonzero indicates the integrator was working
at the edge of convergence (typically a hint to tighten epsilon or
raise min_dt).
Sourcepub fn add_particle(&mut self, p: reb_particle)
pub fn add_particle(&mut self, p: reb_particle)
Add a particle to the simulation.
Sourcepub fn add_test_particle(
&mut self,
x: f64,
y: f64,
z: f64,
vx: f64,
vy: f64,
vz: f64,
)
pub fn add_test_particle( &mut self, x: f64, y: f64, z: f64, vx: f64, vy: f64, vz: f64, )
Add a test particle with given position and velocity (mass = 0).
Sourcepub fn particles(&self) -> &[reb_particle]
pub fn particles(&self) -> &[reb_particle]
Read-only access to the particle array.
Sourcepub fn integrate(&mut self, tmax: f64) -> Result<(), Error>
pub fn integrate(&mut self, tmax: f64) -> Result<(), Error>
Integrate to target time. Returns the status code.
Sourcepub fn add_variation_1st_order(&mut self, testparticle: i32) -> i32
pub fn add_variation_1st_order(&mut self, testparticle: i32) -> i32
Add first-order variational particles for a test particle. Returns the index of the first variational particle.