SBSimulator#

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')

# UUID of the Brenner SAMSON Element
im_uuid = SBUUID('AD608CB6-6971-7CD4-6FCC-34531998E743')

# UUID of the State Updater pack SAMSON Element
su_uuid = SBUUID('F912F119-7CBB-B5BD-972A-0A02DFCF683D')

# make an instance of a simulator by providing class names of an interaction model and a state updater
simulator = SAMSON.makeSimulator(nodeIndexer, 'SMMBrennerInteractionModel', im_uuid, 'SESInteractiveModelingUpdater', su_uuid)

# 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
SAMSON.beginHolding('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)

# turn the undo system off
SAMSON.endHolding()

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: SBNode

This class is the base class of simulators.

getNextSimulator(self: samson.SBSimulator) samson.SBSimulator#

Returns the next Simulator

getPreviousSimulator(self: samson.SBSimulator) samson.SBSimulator#

Returns the previous Simulator

getStateUpdater(self: samson.SBSimulator) samson.SBStateUpdater#

Returns the state updater

updateState(self: samson.SBSimulator) None#

Updates state

property activityFlag#

The activity flag

property simulatorType#

The type of the simulator