cellular_raza_concepts/mechanics.rs
1use crate::errors::{CalcError, RngError};
2
3/// Methods for accessing the position of an agent.
4pub trait Position<Pos> {
5 /// Gets the cells current position.
6 fn pos(&self) -> Pos;
7 /// Gets the cells current velocity.
8 fn set_pos(&mut self, position: &Pos);
9}
10
11/// Methods for accessing the velocity of an agent
12pub trait Velocity<Vel> {
13 /// Gets the cells current velocity.
14 fn velocity(&self) -> Vel;
15 /// Sets the cells current velocity.
16 fn set_velocity(&mut self, velocity: &Vel);
17}
18
19/// Describes the position of a cell-agent and allows to calculate increments and set/get
20/// information of the agent.
21pub trait Mechanics<Pos, Vel, For, Float = f64> {
22 /// Define a new random variable in case that the mechanics type contains a random aspect to
23 /// its motion.
24 /// By default this function does nothing.
25 #[allow(unused)]
26 fn get_random_contribution(
27 &self,
28 rng: &mut rand_chacha::ChaCha8Rng,
29 dt: Float,
30 ) -> Result<(Pos, Vel), RngError>;
31
32 /// Calculate the time-derivative of force and velocity given all the forces that act on the
33 /// cell.
34 /// Simple damping effects should be included in this trait if not explicitly given by the
35 /// [SubDomainForce](super::SubDomainForce) trait.
36 fn calculate_increment(&self, force: For) -> Result<(Pos, Vel), CalcError>;
37}