Geometry and meshes
A simulation starts from a geometry recipe (a "setup"), which create_geometry turns into a finite element mesh in three steps:
a configuration of cells (positions and radii), random by default (
SpinDoctor.create_cells);the surfaces of the cells and of the extracellular space (ECS) (
SpinDoctor.create_surfaces);a mesh of triangles (2D, with Triangle) or tetrahedra (3D, with TetGen), split into compartments (
SpinDoctor.create_mesh,SpinDoctor.split_mesh).
setup = CylinderSetup(; ncell = 3, layersizes = [0.6, 1.0], ecs = BoxECS(; margin = 1.0))
mesh, surfaces, cells = create_geometry(setup; rng = Xoshiro(1))See Geometry recipes for pictures of all of them.
Recipes
| Recipe | Dimension | Cells |
|---|---|---|
PlateSetup | 2D | stacked plates |
SlabSetup | 3D | stacked slabs (extruded plates) |
DiskSetup | 2D | disks, with layers |
CylinderSetup | 3D | cylinders (extruded disks), with layers |
SphereSetup | 3D | spheres, with layers |
VoronoiSetup | 3D | polyhedral cells filling a periodic box |
NeuronSetup | 3D | a neuron from a volume mesh (Gmsh format) |
Disks, cylinders and spheres may have several layers (layersizes, relative radii), for example an axon in a myelin sheath, or a nucleus in a cell. Extruded setups (slabs and cylinders) may be bent and twisted (ExtrusionSetup).
Extracellular space
The cells of disks, cylinders, spheres and neurons may be immersed in an ECS:
NoECS: no ECS;BoxECS: a box around the cells, with a margin;ConvexHullECS: the convex hull of the cells, with a margin;PeriodicBoxECS: a sample of periodic tissue (disks and cylinders).
Samples of periodic tissue
For dense tissue, PeriodicBoxECS and VoronoiSetup fill a box with cells, cut by its faces, with their periodic images entering on the opposite faces:
periodic_packingpacks disks or spheres with gaps between them, up to about 80 % of the area or 60 % of the volume (counting the gaps);VoronoiSetupcreates polyhedral cells for any volume fraction.
The meshes are periodic (the opposite faces of the box have the same points), so that the solvers can use periodic boundary conditions (see Solvers). Then the sample represents a larger piece of tissue, without walls.
Cell configurations
The cell configuration cells returned by create_geometry may be given back to create the same cells with other parameters (e.g. a finer mesh), or replaced by a configuration of your own, for example from another packing algorithm:
mesh, = create_geometry(setup; cells)The random configurations are drawn from the random number generator rng.
Compartments and boundaries
The mesh is split into compartments, numbered as follows:
plates and slabs: one per plate;
disks, cylinders and spheres: the inner layers of all the cells, then the next layers, ..., then the ECS (e.g. with two layers and three cells: the axons 1-3, the myelin 4-6, the ECS 7);
neurons: the neuron, then the ECS.
The boundaries are the interfaces between pairs of compartments, followed by the outer boundaries of each compartment. The coefficients of the recipes (coefficients) follow this numbering. compartment_mesh extracts one compartment as a mesh of its own, and box_faces finds the facets of a box-shaped compartment on each face.
Files
By default, create_geometry writes no files. With using JLD2, the geometry can be stored in a file and loaded again when it was created for the same setup:
using JLD2
mesh, surfaces, cells = create_geometry(setup; cache = "geometry.jld2")With savedir, the geometry is written as text files in the TetGen format of the MATLAB version of SpinDoctor.