Diffusion


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.

In [1]:
%jsroot on
gROOT->LoadMacro("${BDMSYS}/etc/rootlogon.C");
In [2]:
#include <vector>
#include "biodynamo.h"
#include "diffusion_biology_modules.h"

Initialize biodynamo

In [3]:
Simulation simulation("diffusion");

auto construct = [](const Double3& position) {
  Cell* cell = new Cell(position);
  cell->SetDiameter(30);
  cell->SetMass(1.0);
  cell->AddBiologyModule(new Chemotaxis());
  Double3 secretion_position = {{50, 50, 50}};
  if (position == secretion_position) {
    cell->AddBiologyModule(new KaliumSecretion());
  }
  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

In [4]:
positions.push_back({50, 50, 50});
ModelInitializer::CreateCells(positions, construct);

Define the substances that cells may secrete

In [5]:
ModelInitializer::DefineSubstance(kKalium, "Kalium", 0.4, 0, 25);

Run simulation for n timesteps

In [6]:
simulation.GetScheduler()->Simulate(300);
std::cout << "Simulation completed successfully!\n";
Simulation completed successfully!

Let's visualize the output!

In [7]:
VisualizeInNotebook();