This model creates 8 cells at each corner of a cube, and one in the middle. The cell in the middle secretes a substance. The cells are modeled to move according to the extracellular gradient; in this case to the middle.
%jsroot on
gROOT->LoadMacro("${BDMSYS}/etc/rootlogon.C");
INFO: Created simulation object 'simulation' with UniqueName='simulation'.
#include "biodynamo.h"
List the extracellular substances
enum Substances { kKalium };
Initialize biodynamo
Simulation simulation("diffusion");
Define the substances that cells may secrete
ModelInitializer::DefineSubstance(kKalium, "Kalium", 0.4, 0, 25);
auto* rm = simulation.GetResourceManager();
auto* dgrid = rm->GetDiffusionGrid(kKalium);
auto construct = [&](const Double3& position) {
Cell* cell = new Cell(position);
cell->SetDiameter(30);
cell->SetMass(1.0);
Double3 secretion_position = {{50, 50, 50}};
if (position == secretion_position) {
cell->AddBehavior(new Secretion(dgrid, 4));
} else {
cell->AddBehavior(new Chemotaxis(dgrid, 0.5));
}
return cell;
};
std::vector<Double3> positions;
positions.push_back({0, 0, 0});
positions.push_back({100, 0, 0});
positions.push_back({0, 100, 0});
positions.push_back({0, 0, 100});
positions.push_back({0, 100, 100});
positions.push_back({100, 0, 100});
positions.push_back({100, 100, 0});
positions.push_back({100, 100, 100});
The cell responsible for secretion
positions.push_back({50, 50, 50});
ModelInitializer::CreateAgents(positions, construct);
Run simulation for n timesteps
simulation.GetScheduler()->Simulate(300);
std::cout << "Simulation completed successfully!\n";
Simulation completed successfully!
Let's visualize the output!
VisualizeInNotebook();