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§
Sourcefn system_name(&self) -> &str
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.
fn particles(&self) -> &[Particle]
fn particles_mut(&mut self) -> &mut [Particle]
Sourcefn for_each_particle_pairs_mut(
&mut self,
f: &mut dyn FnMut(&mut Particle, &mut Particle),
)
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.
Sourcefn particle_count(&self) -> usize
fn particle_count(&self) -> usize
The number of particles in the simulation.
Sourcefn add_particles(&mut self, particles: Vec<Particle>)
fn add_particles(&mut self, particles: Vec<Particle>)
Set the particles in the simulation.
Sourcefn args(&self) -> SimulationArgs
fn args(&self) -> SimulationArgs
Get the simulation arguments.
Sourcefn set_args(&mut self, args: SimulationArgs)
fn set_args(&mut self, args: SimulationArgs)
Set the simulation arguments.
Provided Methods§
Sourcefn for_each_particles(&self, f: &mut dyn FnMut(&Particle))
fn for_each_particles(&self, f: &mut dyn FnMut(&Particle))
Invokes a lambda callback for each particle in the simulation.
Sourcefn for_each_particles_mut(&mut self, f: &mut dyn FnMut(&mut Particle))
fn for_each_particles_mut(&mut self, f: &mut dyn FnMut(&mut Particle))
Invokes a lambda callback for each particle (mutable) in the simulation.
Sourcefn update_position(&mut self, delta_t: f64)
fn update_position(&mut self, delta_t: f64)
Updates the position of all particles.
Sourcefn delay_force(&mut self)
fn delay_force(&mut self)
Delays the force.
Sourcefn update_force(&mut self)
fn update_force(&mut self)
Updates the velocity of all particles.
Sourcefn update_velocity(&mut self, delta_t: f64)
fn update_velocity(&mut self, delta_t: f64)
Updates the velocity of all particles.