Author: Lukas Breitwieser
In this tutorial we will show how to create a histogram of all agent diameters in the simulation and fit a function to the data.
Let's start by setting up BioDynaMo notebooks.
%jsroot on
gROOT->LoadMacro("${BDMSYS}/etc/rootlogon.C");
INFO: Created simulation object 'simulation' with UniqueName='simulation'.
We want to define a function that creates a cell at a certain position with diameters drawn from a gaussian distribution with $\mu=20$ and $\sigma=5$. The smallest diameter should be larger then $2.0$.
simulation.GetResourceManager()->ClearAgents();
auto rng = simulation.GetRandom()->GetGausRng(20, 5);
auto create_cell = [&](const Real3& position) {
Cell* cell = new Cell(position);
real_t diameter = std::max(2.0, rng.Sample());
cell->SetDiameter(diameter);
return cell;
};
Now that we defined create_cell
we can use it to create 400 cells on a plane with $z = 0$, $xmin = ymin = -200$, $xmax = ymax = 200$, and spacing = 20 in both dimensions.
auto f = [](const real_t* x, const real_t* params) { return 0.0; };
ModelInitializer::CreateAgentsOnSurface(f, {}, -200, 200, 20, -200, 200, 20,
create_cell);
simulation.GetScheduler()->FinalizeInitialization();
VisualizeInNotebook(300, 300);