Struct VertexMechanics2D
pub struct VertexMechanics2D<const D: usize> {
pub cell_boundary_lengths: Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>,
pub spring_tensions: Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>,
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: Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>
Boundary lengths of individual edges
spring_tensions: Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>
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§
§impl<const D: usize> VertexMechanics2D<D>
impl<const D: usize> VertexMechanics2D<D>
pub fn new(
middle: Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>,
cell_area: f64,
rotation_angle: f64,
spring_tensions: f64,
central_pressure: f64,
damping_constant: f64,
diffusion_constant: f64,
randomize: Option<(f64, ChaCha8Rng)>,
) -> VertexMechanics2D<D>
Available on crate feature cpu_os_threads
only.
pub fn new( middle: Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>, cell_area: f64, rotation_angle: f64, spring_tensions: f64, central_pressure: f64, damping_constant: f64, diffusion_constant: f64, randomize: Option<(f64, ChaCha8Rng)>, ) -> VertexMechanics2D<D>
cpu_os_threads
only.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.
pub fn calculate_boundary_length(cell_area: f64) -> f64
Available on crate feature cpu_os_threads
only.
pub fn calculate_boundary_length(cell_area: f64) -> f64
cpu_os_threads
only.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.
pub fn calculate_cell_area(boundary_length: f64) -> f64
Available on crate feature cpu_os_threads
only.
pub fn calculate_cell_area(boundary_length: f64) -> f64
cpu_os_threads
only.Calculates the cell area of the regular polygon in equilibrium.
The formula used is identical the the one of Self::calculate_boundary_length.
pub fn get_current_cell_area(&self) -> f64
Available on crate feature cpu_os_threads
only.
pub fn get_current_cell_area(&self) -> f64
cpu_os_threads
only.Calculates the current area of the cell
pub fn calculate_current_boundary_length(&self) -> f64
Available on crate feature cpu_os_threads
only.
pub fn calculate_current_boundary_length(&self) -> f64
cpu_os_threads
only.Calculate the current polygons boundary length
pub fn get_cell_area(&self) -> f64
Available on crate feature cpu_os_threads
only.
pub fn get_cell_area(&self) -> f64
cpu_os_threads
only.Obtain current cell area
pub fn set_cell_area_and_boundary_length(&mut self, cell_area: f64)
Available on crate feature cpu_os_threads
only.
pub fn set_cell_area_and_boundary_length(&mut self, cell_area: f64)
cpu_os_threads
only.Set the current cell area and adjust the length of edges such that the cell is still in equilibrium.
pub fn set_cell_area(&mut self, cell_area: f64)
Available on crate feature cpu_os_threads
only.
pub fn set_cell_area(&mut self, cell_area: f64)
cpu_os_threads
only.Change the internal cell area
§impl VertexMechanics2D<6>
impl VertexMechanics2D<6>
pub fn fill_rectangle_flat_top(
cell_area: f64,
spring_tensions: f64,
central_pressure: f64,
damping_constant: f64,
diffusion_constant: f64,
rectangle: [Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>; 2],
) -> Vec<VertexMechanics2D<6>>
Available on crate feature cpu_os_threads
only.
pub fn fill_rectangle_flat_top( cell_area: f64, spring_tensions: f64, central_pressure: f64, damping_constant: f64, diffusion_constant: f64, rectangle: [Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>; 2], ) -> Vec<VertexMechanics2D<6>>
cpu_os_threads
only.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.
§impl VertexMechanics2D<4>
impl VertexMechanics2D<4>
pub fn fill_rectangle(
cell_area: f64,
spring_tensions: f64,
central_pressure: f64,
damping_constant: f64,
diffusion_constant: f64,
rectangle: [Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>; 2],
) -> Vec<VertexMechanics2D<4>>
Available on crate feature cpu_os_threads
only.
pub fn fill_rectangle( cell_area: f64, spring_tensions: f64, central_pressure: f64, damping_constant: f64, diffusion_constant: f64, rectangle: [Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>; 2], ) -> Vec<VertexMechanics2D<4>>
cpu_os_threads
only.Fill a specified rectangle with cells of 4 vertices
§impl<const D: usize> VertexMechanics2D<D>
impl<const D: usize> VertexMechanics2D<D>
pub fn outer_radius_from_cell_area(cell_area: f64) -> f64
Available on crate feature cpu_os_threads
only.
pub fn outer_radius_from_cell_area(cell_area: f64) -> f64
cpu_os_threads
only.Calculates the outer circle radius of the Regular Polygon given its area.
pub fn outer_radius_from_boundary_length(boundary_length: f64) -> f64
Available on crate feature cpu_os_threads
only.
pub fn outer_radius_from_boundary_length(boundary_length: f64) -> f64
cpu_os_threads
only.Calculates the outer circle radius of the Regular Polygon given its boundary length.
pub fn inner_radius_from_cell_area(cell_area: f64) -> f64
Available on crate feature cpu_os_threads
only.
pub fn inner_radius_from_cell_area(cell_area: f64) -> f64
cpu_os_threads
only.Calculates the inner circle radius of the Regular Polygon given its area.
pub fn inner_radius_from_boundary_length(boundary_length: f64) -> f64
Available on crate feature cpu_os_threads
only.
pub fn inner_radius_from_boundary_length(boundary_length: f64) -> f64
cpu_os_threads
only.Calculates the inner circle radius of the Regular Polygon given its boundary length.
Trait Implementations§
§impl<const D: usize> Clone for VertexMechanics2D<D>
impl<const D: usize> Clone for VertexMechanics2D<D>
§fn clone(&self) -> VertexMechanics2D<D>
fn clone(&self) -> VertexMechanics2D<D>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<const D: usize> Debug for VertexMechanics2D<D>
impl<const D: usize> Debug for VertexMechanics2D<D>
§impl<'de, const D: usize> Deserialize<'de> for VertexMechanics2D<D>
impl<'de, const D: usize> Deserialize<'de> for VertexMechanics2D<D>
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<VertexMechanics2D<D>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<VertexMechanics2D<D>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§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>
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>
§fn calculate_increment(
&self,
force: Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>,
) -> Result<(Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>), CalcError>
fn calculate_increment( &self, force: Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, ) -> Result<(Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>), CalcError>
§fn get_random_contribution(
&self,
rng: &mut ChaCha8Rng,
dt: f64,
) -> Result<(Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>), RngError>
fn get_random_contribution( &self, rng: &mut ChaCha8Rng, dt: f64, ) -> Result<(Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>), RngError>
§impl<const D: usize> PartialEq for VertexMechanics2D<D>
impl<const D: usize> PartialEq for VertexMechanics2D<D>
§impl<const D: usize> Position<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> for VertexMechanics2D<D>
impl<const D: usize> Position<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> for VertexMechanics2D<D>
§impl<const D: usize> Serialize for VertexMechanics2D<D>
impl<const D: usize> Serialize for VertexMechanics2D<D>
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl<const D: usize> Velocity<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> for VertexMechanics2D<D>
impl<const D: usize> Velocity<Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>> for VertexMechanics2D<D>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.