Struct VertexMechanics2D

Source
pub struct VertexMechanics2D<const D: usize> {
    pub cell_boundary_lengths: SVector<f64, D>,
    pub spring_tensions: SVector<f64, D>,
    pub cell_area: f64,
    pub central_pressure: f64,
    pub damping_constant: f64,
    pub diffusion_constant: f64,
    /* private fields */
}
Expand description

Mechanics model which represents cells as vertices with edges between them.

The vertices are attached to each other with springs and a given length between each vertex. Furthermore, we define a central pressure that acts when the total cell area is greater or smaller than the desired one. Each vertex is damped individually by the same constant.

Fields§

§cell_boundary_lengths: SVector<f64, D>

Boundary lengths of individual edges

§spring_tensions: SVector<f64, D>

Spring tensions of individual edges

§cell_area: f64

Total cell area

§central_pressure: f64

Central pressure going from middle of the cell outwards

§damping_constant: f64

Damping constant

§diffusion_constant: f64

Controls the random motion of the entire cell

Implementations§

Source§

impl<const D: usize> VertexMechanics2D<D>

Source

pub fn new( middle: SVector<f64, 2>, cell_area: f64, rotation_angle: f64, spring_tensions: f64, central_pressure: f64, damping_constant: f64, diffusion_constant: f64, randomize: Option<(f64, ChaCha8Rng)>, ) -> Self

Creates a new vertex model in equilibrium conditions.

The specified parameters are then used to carefully calculate relating properties of the model. We outline the formulas used. Given the number of vertices \(N\) in our model (specified by the const generic argument of the VertexMechanics2D struct), the resulting average angle when all nodes are equally distributed is \[ \Delta\varphi = \frac{2\pi}{N} \] Given the total area of the cell (regular polygon) \(A\), we can calculate the distance from the center point to the individual vertices by inverting \[ A = r^2 \sin\left(\frac{\pi}{N}\right)\cos\left(\frac{\pi}{N}\right). \] This formula can be derived by elementary geometric arguments. We can then generate the points \(\vec{p}_i\) which make up the cell-boundary by using \[ \vec{p}_i = \vec{p}_{mid} + r(\cos(i \Delta\varphi), \sin(i\Delta\varphi))^T. \] From these points, their distance is calculated and passed as the individual boundary lengths. When randomization is turned on, these points will be slightly randomized in their radius and angle which might lead to non-equilibrium configurations. Pressure, damping and spring tensions are not impacted by randomization.

Source

pub fn calculate_boundary_length(cell_area: f64) -> f64

Calculates the boundary length of the regular polygon given the total area in equilibrium.

The formula used is $$\begin{align} A &= \frac{L^2}{4n\tan\left(\frac{\pi}{n}\right)}\\ L &= \sqrt{4An\tan\left(\frac{\pi}{n}\right)} \end{align}$$ where $A$ is the total area, $n$ is the number of vertices and $L$ is the total boundary length.

Source

pub fn calculate_cell_area(boundary_length: f64) -> f64

Calculates the cell area of the regular polygon in equilibrium.

The formula used is identical the the one of Self::calculate_boundary_length.

Source

pub fn get_current_cell_area(&self) -> f64

Calculates the current area of the cell

Source

pub fn calculate_current_boundary_length(&self) -> f64

Calculate the current polygons boundary length

Source

pub fn get_cell_area(&self) -> f64

Obtain current cell area

Source

pub fn set_cell_area_and_boundary_length(&mut self, cell_area: f64)

Set the current cell area and adjust the length of edges such that the cell is still in equilibrium.

Source

pub fn set_cell_area(&mut self, cell_area: f64)

Change the internal cell area

Source§

impl VertexMechanics2D<6>

Source

pub fn fill_rectangle_flat_top( cell_area: f64, spring_tensions: f64, central_pressure: f64, damping_constant: f64, diffusion_constant: f64, rectangle: [SVector<f64, 2>; 2], ) -> Vec<Self>

Fills the area of a given rectangle with hexagonal cells. Their orientation is such that the top border has a flat top.

The produced pattern will like similar to this.

__________________________________
|   ___       ___          ___   |
|  /   \     /   \        /   \  |
| /     \___/     \_ ..._/     \ |
| \     /   \     /      \     / |
|  \___/     \___/        \___/  |
|  /   \     /   \        /   \  |
| .     .   .     .      .     . |

The padding around the generated cells will be determined automatically.

Source§

impl VertexMechanics2D<4>

Source

pub fn fill_rectangle( cell_area: f64, spring_tensions: f64, central_pressure: f64, damping_constant: f64, diffusion_constant: f64, rectangle: [SVector<f64, 2>; 2], ) -> Vec<Self>

Fill a specified rectangle with cells of 4 vertices

Source§

impl<const D: usize> VertexMechanics2D<D>

Source

pub fn outer_radius_from_cell_area(cell_area: f64) -> f64

Calculates the outer circle radius of the Regular Polygon given its area.

Source

pub fn outer_radius_from_boundary_length(boundary_length: f64) -> f64

Calculates the outer circle radius of the Regular Polygon given its boundary length.

Source

pub fn inner_radius_from_cell_area(cell_area: f64) -> f64

Calculates the inner circle radius of the Regular Polygon given its area.

Source

pub fn inner_radius_from_boundary_length(boundary_length: f64) -> f64

Calculates the inner circle radius of the Regular Polygon given its boundary length.

Trait Implementations§

Source§

impl<const D: usize> Clone for VertexMechanics2D<D>

Source§

fn clone(&self) -> VertexMechanics2D<D>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const D: usize> Debug for VertexMechanics2D<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, const D: usize> Deserialize<'de> for VertexMechanics2D<D>

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<const D: usize> Mechanics<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> for VertexMechanics2D<D>

Source§

fn calculate_increment( &self, force: SMatrix<f64, D, 2>, ) -> Result<(SMatrix<f64, D, 2>, SMatrix<f64, D, 2>), CalcError>

Calculate the time-derivative of force and velocity given all the forces that act on the cell. Simple damping effects should be included in this trait if not explicitly given by the SubDomainForce trait.
Source§

fn get_random_contribution( &self, rng: &mut ChaCha8Rng, dt: f64, ) -> Result<(SMatrix<f64, D, 2>, SMatrix<f64, D, 2>), RngError>

Define a new random variable in case that the mechanics type contains a random aspect to its motion. By default this function does nothing.
Source§

impl<const D: usize> PartialEq for VertexMechanics2D<D>

Source§

fn eq(&self, other: &VertexMechanics2D<D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const D: usize> Position<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> for VertexMechanics2D<D>

Source§

fn pos(&self) -> SMatrix<f64, D, 2>

Gets the cells current position.
Source§

fn set_pos(&mut self, pos: &SMatrix<f64, D, 2>)

Gets the cells current velocity.
Source§

impl<const D: usize> Serialize for VertexMechanics2D<D>

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
Source§

impl<const D: usize> Velocity<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> for VertexMechanics2D<D>

Source§

fn velocity(&self) -> SMatrix<f64, D, 2>

Gets the cells current velocity.
Source§

fn set_velocity(&mut self, velocity: &SMatrix<f64, D, 2>)

Sets the cells current velocity.
Source§

impl<const D: usize> StructuralPartialEq for VertexMechanics2D<D>

Auto Trait Implementations§

§

impl<const D: usize> Freeze for VertexMechanics2D<D>

§

impl<const D: usize> RefUnwindSafe for VertexMechanics2D<D>

§

impl<const D: usize> Send for VertexMechanics2D<D>

§

impl<const D: usize> Sync for VertexMechanics2D<D>

§

impl<const D: usize> Unpin for VertexMechanics2D<D>

§

impl<const D: usize> UnwindSafe for VertexMechanics2D<D>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<T> Ungil for T
where T: Send,