Skip to main content

Simulation

Struct Simulation 

Source
pub struct Simulation {
    pub model: Model,
    pub lattice: Lattice,
    pub volume: Vec<u32>,
    pub surface: Vec<i64>,
    pub cell_type: Vec<u8>,
    pub moments: Vec<Moments>,
    pub activity: Activity,
    pub fields: Fields,
    pub exchange: Vec<Exchange>,
    pub mcs: u64,
    pub accepted: u64,
    pub attempted: u64,
    /* private fields */
}
Expand description

A running simulation: the lattice, one volume and one type per cell, and the random stream.

Fields§

§model: Model

The model this run realises.

§lattice: Lattice

The site labels.

§volume: Vec<u32>

Volume per label. Index 0 is the medium, counted like any other so the total over the vector is the lattice, and never constrained.

§surface: Vec<i64>

Surface per label, counted as bonds from a cell’s sites to sites of any other label, over the model’s own neighbour order.

§cell_type: Vec<u8>

Type per label.

§moments: Vec<Moments>

Second moments per label, for the length constraint.

§activity: Activity

How recently each site was taken, for the types that keep a memory.

§fields: Fields

Diffusing species on the same lattice.

§exchange: Vec<Exchange>

Secretion and uptake per cell type.

§mcs: u64

Monte Carlo steps completed.

§accepted: u64

Copy attempts accepted since the run started.

§attempted: u64

Copy attempts made since the run started.

Implementations§

Source§

impl Simulation

Source

pub fn tiled(model: Model, side: usize) -> Result<Self, String>

Start a run from a tiled lattice of square cells, all of type 1.

§Errors

Whatever Model::validate reports.

Source

pub fn tiled_grid( model: Model, side: usize, nx: usize, ny: usize, nz: usize, ) -> Result<Self, String>

Start a run from nx by ny square cells, leaving the rest medium.

§Errors

Whatever Model::validate reports.

Source

pub fn set_cell_types(&mut self, types: &[u8])

Set the type of each cell, in label order, from a list one per cell.

Source

pub fn n_cells(&self) -> usize

Number of cells, excluding the medium.

Source

pub fn delta_energy(&self, target: usize, new: u32) -> f64

Energy change if site target took the label new.

The contact term counts only unlike-label bonds, which is the (1 - delta) factor of the Potts Hamiltonian. The volume term is the change in lambda (V - V_target)^2 for the two cells involved.

Source

pub fn move_work(&self, new: u32, old: u32, target: usize, source: usize) -> f64

Work the cell gaining the site does against its own memory and its drift.

Both read the two sites a copy runs between, so both are properties of the move rather than of the configuration and neither appears in Simulation::energy.

Source

pub fn chemotaxis_work(&self, new: u32, target: usize, source: usize) -> f64

Work done against a chemical gradient by the cell gaining the site.

This is a property of the move rather than of the configuration: it reads the field at the two sites the copy runs between, so it has no counterpart in Simulation::energy and cannot be checked by recomputing a total. A positive sensitivity makes a move up the gradient cheaper, which is what makes a cell climb it.

Source

pub fn attempt(&mut self) -> bool

One copy attempt: a random target site takes the label of a random neighbour, accepted by the Metropolis rule.

A copy that would empty a cell is refused, so a cell never vanishes and the label set is fixed for the run.

Source

pub fn step(&mut self)

One Monte Carlo step: as many copy attempts as there are sites, then the fields diffuse, decay and exchange with the cells that own the sites they sit on.

Source

pub fn energy(&self) -> f64

Total energy of the current configuration.

Each unlike-label bond is counted once, so this is comparable between neighbour orders and is what the incremental deltas must reproduce.

Source

pub fn recounted_moments(&self) -> Vec<Moments>

Recompute the moments from the lattice, for checking the bookkeeping.

Source

pub fn recounted_surfaces(&self) -> Vec<i64>

Recount the surfaces from the lattice, for checking the bookkeeping.

Source

pub fn recounted_volumes(&self) -> Vec<u32>

Recount the volumes from the lattice, for checking the bookkeeping.

Source§

impl Simulation

Source

pub fn divide_and_die(&mut self) -> (usize, usize)

Cells that have reached their division volume split, and cells of a type with a death rate die.

A dividing cell is cut by the line through its centroid perpendicular to its major axis, so the halves are the compact ones. A dying cell’s sites become medium. Both change the boundary of every neighbour, so the surfaces are recounted whenever either happens rather than patched.

Source

pub fn live_cells(&self) -> usize

Labels with sites on the lattice.

Trait Implementations§

Source§

impl Clone for Simulation

Source§

fn clone(&self) -> Simulation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Simulation

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.