Simulation

Trait Simulation 

Source
pub trait Simulation {
Show 17 methods // Required methods fn system_name(&self) -> &str; fn particles(&self) -> &[Particle]; fn particles_mut(&mut self) -> &mut [Particle]; fn for_each_particle_pairs_mut( &mut self, f: &mut dyn FnMut(&mut Particle, &mut Particle), ); fn particle_count(&self) -> usize; fn add_particles(&mut self, particles: Vec<Particle>); fn get_force(&self) -> Arc<dyn Force>; fn set_force(&mut self, force: Arc<dyn Force>); fn args(&self) -> SimulationArgs; fn set_args(&mut self, args: SimulationArgs); // Provided methods fn for_each_particles(&self, f: &mut dyn FnMut(&Particle)) { ... } fn for_each_particles_mut(&mut self, f: &mut dyn FnMut(&mut Particle)) { ... } fn update_position(&mut self, delta_t: f64) { ... } fn delay_force(&mut self) { ... } fn update_force(&mut self) { ... } fn update_velocity(&mut self, delta_t: f64) { ... } fn step(&mut self, delta_t: f64) { ... }
}
Expand description

An interface-level abstraction of a molecular dynamics simulation. A Simulation is a method of organizing the particles and forces in a way that allows for efficient computation.

Required Methods§

Source

fn system_name(&self) -> &str

§Returns

Name of the simulation system, which is used for serialization and deserialization. The characters are expected to be in lowercase.

Source

fn particles(&self) -> &[Particle]

Source

fn particles_mut(&mut self) -> &mut [Particle]

Source

fn for_each_particle_pairs_mut( &mut self, f: &mut dyn FnMut(&mut Particle, &mut Particle), )

The core method of the trait. Different implementations of Simulation vary in performance as this is the heaviest part of the simulation. Invokes a lambda callback for pair of particles in the simulation, with the following limitations:

  • An iterator over distinct pairs of particles, accounting for symmetry.
  • If you receive a pair (a, b) it is guaranteed that you will not receive (b, a).
  • There is no guarantee you will receive all pairs.
Source

fn particle_count(&self) -> usize

The number of particles in the simulation.

Source

fn add_particles(&mut self, particles: Vec<Particle>)

Set the particles in the simulation.

Source

fn get_force(&self) -> Arc<dyn Force>

Get the force calculation method.

Source

fn set_force(&mut self, force: Arc<dyn Force>)

Set the force calculation method.

Source

fn args(&self) -> SimulationArgs

Get the simulation arguments.

Source

fn set_args(&mut self, args: SimulationArgs)

Set the simulation arguments.

Provided Methods§

Source

fn for_each_particles(&self, f: &mut dyn FnMut(&Particle))

Invokes a lambda callback for each particle in the simulation.

Source

fn for_each_particles_mut(&mut self, f: &mut dyn FnMut(&mut Particle))

Invokes a lambda callback for each particle (mutable) in the simulation.

Source

fn update_position(&mut self, delta_t: f64)

Updates the position of all particles.

Source

fn delay_force(&mut self)

Delays the force.

Source

fn update_force(&mut self)

Updates the velocity of all particles.

Source

fn update_velocity(&mut self, delta_t: f64)

Updates the velocity of all particles.

Source

fn step(&mut self, delta_t: f64)

TODO document

Trait Implementations§

Source§

impl Default for Box<dyn Simulation>

Source§

fn default() -> Self

The default simulation system for this project is the direct sum.

Source§

impl<'de> Deserialize<'de> for Box<dyn Simulation>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> Serialize for dyn Simulation + 'a

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Implementors§