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>

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.

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.

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.

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.

Calculates the current area of the cell

pub fn calculate_current_boundary_length(&self) -> f64

Available on crate feature 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.

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.

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.

Change the internal cell area

§

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.

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>

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.

Fill a specified rectangle with cells of 4 vertices

§

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.

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.

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.

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.

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

Trait Implementations§

§

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

§

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
§

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

§

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

Formats the value using the given formatter. Read more
§

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>,

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

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>

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

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>

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

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

§

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

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

§

fn pos(&self) -> Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>

Gets the cells current position.
§

fn set_pos( &mut self, pos: &Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, )

Gets the cells current velocity.
§

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,

Serialize this value into the given Serde serializer. Read more
§

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

§

fn velocity(&self) -> Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>

Gets the cells current velocity.
§

fn set_velocity( &mut self, velocity: &Matrix<f64, Const<D>, Const<2>, ArrayStorage<f64, D, 2>>, )

Sets the cells current velocity.
§

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

§

impl<T> InteractionInformation for T
where T: Send + Sync + Clone + Debug,

Source§

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

§

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

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,