SBSimulator#
This class describes a simulator, which combines a dynamical model, an interaction model, and a state updater into a runnable simulation workflow.
Initialize and add simulator in the active document
To add a simulator in SAMSON you need to create and add a dynamical model, an interaction model, and a state updater. In the following example we will apply a simulator to a molecular system in the active document using the Brenner interaction model and the Interactive modeling state updater.
# Apply a simulator to a molecule in the active document
# get a node indexer of all structural models in the active document
nodeIndexer = SAMSON.getNodes('n.t sm')
# make an instance of a simulator by providing class names of an interaction model and a state updater
simulator = SAMSON.makeSimulator(
nodeIndexer = nodeIndexer,
# the name of the interaction model class
interactionModelClassName = 'SMMBrennerInteractionModel',
# the UUID of the Brenner SAMSON Extension
interactionModelExtensionUUID = SBUUID('AD608CB6-6971-7CD4-6FCC-34531998E743'),
# no parameters for the Brenner interaction model
interactionModelParameterMap = SBValueMap(),
# the name of the state updater class
stateUpdaterClassName = 'SESInteractiveModelingUpdater',
# the UUID of the State Updater pack SAMSON Extension
stateUpdaterExtensionUUID = SBUUID('F912F119-7CBB-B5BD-972A-0A02DFCF683D')
)
# now we need to create a dynamical model, an interaction model, and a state updater
# get the dynamical model from the simulator
dynamicalModel = simulator.getDynamicalModel()
# create the dynamical model
dynamicalModel.create()
# get the interaction model from the simulator
interactionModel = simulator.getInteractionModel()
# create the interaction model
interactionModel.create()
# show a window with interaction model properties
SAMSON.showProperties(interactionModel)
# initialize interaction model
interactionModel.initializeInteractions()
# get the state updater from the simulator
stateUpdater = simulator.getStateUpdater()
# create the state updater
stateUpdater.create()
# show a window with state updater properties
SAMSON.showProperties(stateUpdater)
# create the simulator
simulator.create()
# get the active document
document = SAMSON.getActiveDocument()
# turn the undo system on
with SAMSON.holding('Add simulator'):
# hold an object for undo/redo
SAMSON.hold(dynamicalModel)
# add the dynamical model to the active document
document.addChild(dynamicalModel)
# hold an object for undo/redo
SAMSON.hold(interactionModel)
# add the interaction model to the active document in SAMSON
document.addChild(interactionModel)
# hold an object for undo/redo
SAMSON.hold(simulator)
# add the simulator to the active document
document.addChild(simulator)
You can start and stop simulation using the SAMSON Facade (samson.SAMSON):
# start simulation
SAMSON.startSimulation()
# check until the simulation is done
# ...
# stop simulation
SAMSON.stopSimulation()
See also
SAMSON SDK: SBSSimulator
- class samson.SBSimulator#
Bases:
SBNodeBase class for simulators.
A simulator orchestrates a dynamical model, an interaction model, and a state updater to advance simulation state.
- getDynamicalModel(self: samson.SBSimulator) samson.SBDynamicalModel#
Returns the associated dynamical model.
- getInteractionModel(self: samson.SBSimulator) samson.SBInteractionModel#
Returns the associated interaction model.
- getNextSimulator(self: samson.SBSimulator) samson.SBSimulator#
Returns the next simulator in document order.
- getPreviousSimulator(self: samson.SBSimulator) samson.SBSimulator#
Returns the previous simulator in document order.
- getStateUpdater(self: samson.SBSimulator) samson.SBStateUpdater#
Returns the associated state updater.
- updateState(self: samson.SBSimulator) None#
Updates simulation state.
- property activityFlag#
Simulation activity flag.
- property simulatorType#
Returns the specific simulator type.