BioCMAMC-ST
|
Instead of directly solving hydrodynamics equations, this tool utilizes pre-computed flow fields sourced from various origins and aggregated into a unified compartment formalism.
A compartment represents a coarse mesh element that contains a small volume of fluid or gas where conditions are considered homogeneous. Values are integrated over each volume, preserving spatial heterogeneity while simplifying computations. Both liquid and gas phases are treated as Eulerian scalars transported between compartments using flow field data.
For discrete particles, transport is also based on flow fields but incorporates stochastic methods to handle their movement through the domain.
This documentation focuses on the namespace CmaUtils and the functor MoveFunctor.
The CmaUtils library serves as the interface between CMtool and Kokkos. While CMtool provides lightweight data accessors, it is not optimized for parallel simulation. Many operations require reading flow data efficiently in a parallel context—this is where CmaUtils bridges the gap.
The library wraps CMtool and provides an abstraction layer over Kokkos to handle data reading and processing from flow maps within the simulation. This design ensures that simulation logic remains clean and focused on computations, while CmaUtils manages the complexity of data handling.
Two main operations have to be performed to CMtool Rawdata in order to used them in simulation kernels.
This operations has been already studied in [5]
One can reformulate the mass balance over a scalar field y governed by compartmental flow velocities into matrix form. For each compartment ii, the differential mass balance reads:
\[ \frac{dV_{i}y_{i}}{dt}=\sum_{j}y_{j}F(j,i)-y_{i}\sum_{j}y_{j}F(i,j) \]
Into
\[ \frac{dYV}{dt}=YM \]
Implemented in get_transition_matrix, this function construct the M matrix.
Algorithmic Notes:
The implemented method employs a straightforward sparse matrix assembly via triplet lists:
This step is performed here. The result is important to decide where the discrete particles moves.
The aim is to construct of discrete CDF to have to probability to go in a specific compartment knowning that the cell leaves a compartment. Let L the event to leave current compartment i, and let \(I_{j}\) the event to go the compartment i we have for each neighbors \(P(I_{j}|L)\).
This function construct the CDF using the fact that
\[P(I_{j}|L)=\frac{F(i,j)}{\sum_{k} F(i,k)}\]
Additionally, CmaUtils implements the FlowMapTransitionner—an abstraction designed for managing flow map transitions during the simulation. This component provides seamless access to the correct flow map based on the simulation time, abstracting away the details of data formats and file I/O. The transtionner supports flexible behaviors, such as:
This operations has been already studied in [5] and implementation is here.
This kernel performs the following steps:
The probability of leaving the current compartment follows a discrete Poisson law, where the parameter is the compartment's mean residence time.
\[ p_{out} = 1 − \exp(-\frac{\Delta t}{\tau}) \]
Inverse sampling is used to draw from the discrete Poisson law, allowing a no-branching algorithm. The probability of leaving the compartment is implemented using the regular logarithmic function. For small simulation time steps compared to the mean residence time, approximations may also be applied.
The leaving condition is given by:
\[ \left\{ \begin{array}{l} u \sim \mathcal{U}(0, 1) \\ \Delta t \cdot F > -\ln(u) \cdot V \end{array} \right. \]
where:
This Poisson law formalism, based on the cumulative distribution function (CDF) of the leaving probability, is useful because it doesn't depend on the spatial structure or the number of neighboring compartments. It works the same whether a compartment has one neighbor or many. Leaving the reactor is, therefore, treated like moving to any other compartment.
At each time step, a particle can exit the system through a leaving flow. The total flow out of a compartment is defined as: \(F=F_{circulation}+F_{out}\). Where \(F=F_{circulation}\) comes from transition matrix and flowmap and \(F=F_{out}\)
The probability of leaving the reactor is computed using the same inverse sampling method from the exponential (Poisson) law, replacing the internal flow with the specific flow leaving the reactor.