Repository navigation
EXPERIMENTAL: Adding probabalistic mass conversion to the PDE, no longer a hard boolean.
Updated Continuous → Discrete (CD) Conversion Logic
The CD conversion logic in apply_event has been revised to relax the previous strict admissibility condition that prevented conversion when any PDE grid point in a compartment had concentration below
Previously, conversion required all fine-grid PDE cells within a compartment to satisfy
in order to safely remove one particle of mass uniformly across the compartment. This restriction was enforced through the sufficient_pde_concentration_mask.
New behaviour
Conversion events are now allowed whenever the stochastic event fires. The removal of PDE mass is handled dynamically inside apply_event.
Let
denote the integrated PDE mass in compartment
Two cases are considered:
1. Sub–unit mass: $Y_k(t) < 1$
If the compartment contains less than one particle of mass:
- All PDE mass in the compartment is cleared:
- A discrete particle is added probabilistically:
Otherwise no discrete particle is added.
2. At least one particle: $Y_k(t) \geq 1$
If the compartment contains at least one particle of mass:
Uniform removal attempt
If
then one particle is removed uniformly from the PDE profile:
and
Redistribution removal
If uniform removal would make some cells negative, the algorithm removes one particle of mass using an equal redistribution scheme:
- Cells that cannot support an equal mass share are set to zero.
- The remaining mass to be removed is redistributed equally across the remaining active cells.
- This process repeats until exactly one particle of mass has been removed.
This guarantees:
- exactly one unit of mass removed
- no negative PDE concentrations
- symmetric redistribution across the remaining PDE cells
Result
This update removes the need for the sufficient_pde_concentration_mask gating condition while preserving physical constraints on the PDE profile. Conversion events can now occur more naturally even when the fine-grid concentration profile is heterogeneous.