Skip to main content

AssistSim

Struct AssistSim 

Source
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

Source

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.

Source

pub fn set_forces(&mut self, flags: i32)

Set the ASSIST force model flags.

Source

pub fn forces(&self) -> i32

Get current force model flags.

Source

pub fn sim(&self) -> &Simulation

Access the underlying simulation.

Source

pub fn sim_mut(&mut self) -> &mut Simulation

Mutable access to the underlying simulation.

Source

pub fn set_alpha(&mut self, v: f64)

Set the g(r) model exponent α. Default: 1.0.

Source

pub fn alpha(&self) -> f64

Source

pub fn set_nk(&mut self, v: f64)

Set the g(r) model exponent k. Default: 0.0 (pure inverse-power law).

Source

pub fn nk(&self) -> f64

Source

pub fn set_nm(&mut self, v: f64)

Set the g(r) model exponent m. Default: 2.0 (inverse-square).

Source

pub fn nm(&self) -> f64

Source

pub fn set_nn(&mut self, v: f64)

Set the g(r) model exponent n. Default: 5.093 (Marsden-Sekanina water ice).

Source

pub fn nn(&self) -> f64

Source

pub fn set_r0(&mut self, v: f64)

Set the g(r) model scale distance r₀ in AU. Default: 1.0.

Source

pub fn r0(&self) -> f64

Source

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.

Source

pub fn integrate(&mut self, tmax: f64) -> Result<()>

Integrate to target time.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for AssistSim

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.