Related Documentation:
SSPy is a framework that combines the various part of GENESIS together into a usable state for performing simulations. This document outlines some of the internal frameworks employed so that a developer can extend SSPy by way of the plugin architecture or even modifications to core code.
Since SSPy is directly compatible with SSP all information present in the section titled ”The SSP Configuration File” apply here.
The plugin structure is designed to play on the strengths of the imp module and Python’s duck typing feature. A plugin is defined as directory with a Python module that contains specific class declarations, and an accompanying configuration file.
There are four different types of plugins, each is defined by a differently named configuration file:
The configuration file is in YAML format with the following keys present:
Here is an example solver.yml file for Heccer:
---
name: heccer label: Heccer Solver version: 0.1 description: This is the SSPy object for driving the Heccer solver file: heccer.py source: heccer.py module: heccer services: - name: heccer_intermediary version: 0.1 - name: model_container version: 0.1 |
Each plugin module that is given in the configuration file options for file, source, or module must have the corresponding classes:
so long as the correct methods are filled in with the appropriate functionality and given the required arguments and return types, the classes can be loaded interchangeably and used to drive any combination of simulations (provided a solver is compatible with the declared service and protocols).
Modeling services must allow users to load a model into memory and allow accessibility to element lists and coordinates. From the plugins API it should also be possible to set model parameters.
A modeling service class must have the following structure:
class Service:
def __init__(self, name="Untitled Model Container", plugin=None, arguments=None, verbose=False) def Load(self, modelfile): def GetCore(self): def GetName(self): def GetPluginName(self): def GetType(self): def GetArguments(self): def GetCoordinates(self): def GetElements(self): def SetParameter(self, path, field, value): |
Solver plugins are simulation objects that are scheduled and perform time steps during a simulation. They have logic to connect to services, set the simulation time step, and report simulation status.
A solver plugin class must have the following structure:
class Solver:
def __init__(self, name="Untitled solver", plugin=None, constructor_settings=None, verbose=False): def Initialize(self): def GetCore(self): def GetName(self): def SetTimeStep(self, time_step): def GetTimeStep(self): def GetType(self): def SetConfiguration(self, config): def New(self, modelname, filename): def Advance(self): def Compile(self): def IsCompiled(self): def Connect(self, service=None): def SetModelName(self, model_name): def SetGranularity(self, granularity): def Deserialize(self, filename): def DeserializeState(self, filename): def Finish(self): def Name(self): def SetSolverField(self, field, value): def GetSolverField(self, field): def Serialize(self, filename): def SerializeState(self, filename): def Output(self, serial, field): def Run(self, time): def Step(self, time=None): def Report(self): def Steps(self, steps): |
An input plugin is a simulation object that is scheduled and performs time steps during a simulation.
An input plugin class must have the following structure:
class Input:
def __init__(self, name="Untitled PerfectClamp", plugin=None, arguments=None, verbose=False): def Format(self): def GetName(self): def Name(self): def GetTimeStep(self): def SetTimeStep(self, time_step): def GetType(self): def AddInput(self, name, field): def SetInputs(self, inputs): def SetCommandVoltage(self, voltage): def Advance(self): def Connect(self, solver): def Finish(self): def Initialize(self): def Compile(self): def New(self): def Step(self, time): def Report(self): |
An output plugin is a simulation object that is scheduled and performs time steps during a simulation. The primary purpose of an output object is to output data during a simulation.
An input plugin class must have the following structure:
class Output:
def __init__(self, name="Untitled Output", plugin=None, filename=None, arguments=None, verbose=False): def Compile(self): def Finish(self): def GetName(self): def Name(self): def SetOutputs(self, outputs): def AddOutput(self, name, field): def GetTimeStep(self): def SetTimeStep(self, time_step): def GetType(self): def Finish(self): def Initialize(self): def Connect(self, solver): def Step(self, time=None): def Report(self): def SetMode(self, mode=None): def SetResolution(self, res=None): def SetFormat(self, strfmt=None): def SetFilename(self, filename=None): def GetFilename(self): |