Trait CellularReactions

Source
pub trait CellularReactions<ConcVecIntracellular, ConcVecExtracellular = ConcVecIntracellular> {
    // Required methods
    fn get_intracellular(&self) -> ConcVecIntracellular;
    fn set_intracellular(&mut self, concentration_vector: ConcVecIntracellular);
    fn calculate_intra_and_extracellular_reaction_increment(
        &self,
        internal_concentration_vector: &ConcVecIntracellular,
        external_concentration_vector: &ConcVecExtracellular,
    ) -> Result<(ConcVecIntracellular, ConcVecExtracellular), CalcError>;
}
Expand description

Specify how cellular reactions are taking place.

This trait can also be derived with the CellAgent derive macro.

use cellular_raza_concepts::{reactions_old::CellularReactions, CellAgent, CalcError};
struct MyReactions {
    intracellular: f64,
    half_time: f64,
}

impl CellularReactions<f64> for MyReactions {
    fn get_intracellular(&self) -> f64 {
        self.intracellular
    }

    fn set_intracellular(&mut self, intracellular: f64) {
        self.intracellular = intracellular;
    }

    fn calculate_intra_and_extracellular_reaction_increment(
        &self,
        internal_concentration_vector: &f64,
        external_concentration_vector: &f64,
    ) -> Result<(f64, f64), CalcError> {
        Ok((-self.half_time * self.intracellular, self.half_time * self.intracellular))
    }
}

Required Methods§

Source

fn get_intracellular(&self) -> ConcVecIntracellular

Retrieves the current intracellular concentration.

Source

fn set_intracellular(&mut self, concentration_vector: ConcVecIntracellular)

Sets the intracellular concentration. This is used by the backend after values have been updated.

Source

fn calculate_intra_and_extracellular_reaction_increment( &self, internal_concentration_vector: &ConcVecIntracellular, external_concentration_vector: &ConcVecExtracellular, ) -> Result<(ConcVecIntracellular, ConcVecExtracellular), CalcError>

Calculate the time-related change of the intracellular and extracellular concentrations. This is not the increment itself (thus no parameter dt was specified) but rather the time-derivative. Such an approach can be useful when designing addaptive solvers.

Implementors§