pub struct AssistSim { /* private fields */ }Expand description
A REBOUND simulation with ASSIST ephemeris forces attached.
Owns the simulation. Borrows the ephemeris (caller must keep it alive). ASSIST extras are freed on drop, then the simulation is freed.
Implementations§
Source§impl AssistSim
impl AssistSim
Sourcepub fn new(sim: Simulation, ephem: &Ephemeris) -> Result<Self>
pub fn new(sim: Simulation, ephem: &Ephemeris) -> Result<Self>
Create a new ASSIST-powered simulation.
The ephem must outlive this AssistSim. ASSIST stores a raw pointer
to the ephemeris data internally.
Sourcepub fn set_forces(&mut self, flags: i32)
pub fn set_forces(&mut self, flags: i32)
Set the ASSIST force model flags.
Sourcepub fn sim(&self) -> &Simulation
pub fn sim(&self) -> &Simulation
Access the underlying simulation.
Sourcepub fn sim_mut(&mut self) -> &mut Simulation
pub fn sim_mut(&mut self) -> &mut Simulation
Mutable access to the underlying simulation.
pub fn alpha(&self) -> f64
Sourcepub fn set_nk(&mut self, v: f64)
pub fn set_nk(&mut self, v: f64)
Set the g(r) model exponent k. Default: 0.0 (pure inverse-power law).
pub fn nk(&self) -> f64
pub fn nm(&self) -> f64
Sourcepub fn set_nn(&mut self, v: f64)
pub fn set_nn(&mut self, v: f64)
Set the g(r) model exponent n. Default: 5.093 (Marsden-Sekanina water ice).
pub fn nn(&self) -> f64
pub fn r0(&self) -> f64
Sourcepub fn set_particle_params(&mut self, params: Vec<f64>)
pub fn set_particle_params(&mut self, params: Vec<f64>)
Install ASSIST’s particle_params array (3 doubles per particle:
[A1, A2, A3], in [real | variational] order).
Takes ownership of the Vec; its heap buffer lives for as long as the
AssistSim, matching the lifetime ASSIST requires for the pointer it
stashes internally. Must be called after all particles (real +
variational) have been added; params.len() must equal
3 * n_particles.
Replacing a previously installed array drops the old storage; the previous pointer ASSIST held is already overwritten at that point.
Sourcepub fn integrate_or_interpolate(&mut self, t: f64) -> Result<()>
pub fn integrate_or_interpolate(&mut self, t: f64) -> Result<()>
Integrate to target time t, with interpolation inside the last
completed IAS15 step when possible.
On first call this behaves like integrate except it sets
exact_finish_time = 0 so IAS15 may overshoot; the final state
is reconstructed at t via polynomial interpolation using the
integrator’s br coefficients. On subsequent calls where t
falls within the last completed step’s interval, no integration
happens at all — pure polynomial evaluation, typically one-to-two
orders of magnitude cheaper than a full step. Intended for
light-time iteration loops where the target shifts by
femtoseconds-to-microseconds per iteration.
After the call, sim.particles[i] holds the state at t
(interpolated), even though sim.t may be past t.
Sourcepub fn reset_integrator(&mut self)
pub fn reset_integrator(&mut self)
Zero IAS15’s compensated-summation and predictor state (csx, csv,
csa0, b, e, br, er, g) in place, leaving the allocations intact.
Also invalidates the ASSIST ephemeris-lookup cache (sets every slot’s
t to a sentinel so matched-t comparisons miss on the first
post-reset call). Required between two unrelated orbits integrated on
the same simulation — otherwise stale b/e predictor state seeds the
new orbit’s first step and causes extra corrector iterations, and a
populated ephem cache causes per-lookup LRU work that adds up across
~7000 lookups per 30-day integrate (≈190 µs regression).
Cheaper than librebound_sys::ffi::reb_integrator_ias15_reset
(no free/malloc), and faster in practice: a pool-style benchmark with
this helper matches or beats the unpooled free-function path.
Sourcepub fn update_nongrav_coeffs(&mut self, a1: f64, a2: f64, a3: f64) -> Result<()>
pub fn update_nongrav_coeffs(&mut self, a1: f64, a2: f64, a3: f64) -> Result<()>
Rewrite the first three slots of the installed particle_params
array (the real test particle’s A1, A2, A3) without reallocating.
Returns Error::Other if set_particle_params was never called —
silently no-op’ing here would let a non-grav orbit keep the previous
orbit’s A1/A2/A3 values without any indication.
The variational-particle parameter columns (indices 3 onward) are orbit-invariant IC perturbations (identity for parameter variationals, zero for state variationals) and are left untouched.