Modelling#
Modelling is a central part of of the OPynSim API. At a high-level, the API is designed around three classes with distinct roles:
opynsim.ModelSpecification: A high-level specification of the model. This is what Python code manipulates before callingopynsim.ModelSpecification.compile()to yield…opynsim.Model: A compiled read-only physics model, which can create/read/manipulate…opynsim.ModelState: A single state of anopynsim.Model, which can be modified by Python code to modify the state of the model.
When modelling with OPynSim, it’s important to understand this relationship, because the rest of the modelling API is built around it.
Typical Modelling Workflow#
Typical modelling workflows follow some combination of these steps:
Import or create a
opynsim.ModelSpecification.If required, modify the
opynsim.ModelSpecification.Compile the
opynsim.ModelSpecificationto aopynsim.Model.Generate an initial
opynsim.ModelStatewithopynsim.Model.initial_state().If required, modify the
opynsim.ModelState.Use, or extract data from, the resulting
opynsim.Model+opynsim.ModelStatepair.
See Plot Model Output vs. Property for an example of this pattern.