Spartacus User Guide - Writing Models

To define a model, create an empty file with the extension '.py' or copy and adapt one of the example models shipped with the spartacus distribution. Model definitions are merely python modules that are imported by spartacus at runtime.

Required model attributes

__spartacus__
The required version of Spartacus written as a version string,
for example: __spartacus__ = '0.1.0'
space
The space class used for the simulation. Possible values are spartacus.grid.Space2D and spartacus.grid3d.Space3D.
size or size_x, size_y, size_z
Extension of the space (in arbitrary units). The user must define either size_x, size_y (and size_z for 3D simulations), or size for squared/cubic spaces.
physics
An instance of one of the classes defined in the spartacus.physics modules.
initial_condition
A python callable (e.g. python function) that takes a Simulation object and intializes it.
dt
A float specifying the numerical step width in arbitrary units.
t_max
A float specifying the end time of the simulation. This attribute is mandatory in batch mode and is ignored in interactive mode.

Optional model attributes

particles
A list of all Particle classes used in the simulation. If not specified, Spartacus uses all classes in the model's namespace that are directly derived from spartacus.chemistry.Particle.
stop_criterion
solver
reactions
exchange
analyzers
rules
visual_scale