meld.runner.transform.TransformerBase
- class meld.runner.transform.TransformerBase(param_manager, mapper, density_manager, builder_info, options, always_active_restraints, selectively_active_restraints)[source]
Bases:
object
Base class to document how transformers work.
The transformation process proceeds in several stages.
The transformer is initialized with the run options and lists of restraints. The transformer must store any relevant information, as these parameters will not be given again. The __init__ method must also delete any restraints that are handled by this transformer from always_active_restraints and selectively_active_restraints.
Next, add_interactions is called. This provides an opportunity for the transformer to add new forces, or to modify or replace existing forces.
Next finalize is called. All changes to particles and forces are completed before this call, which can be useful when we have to, e.g. store parameters.
Finally, update is called every stage. This provides an opportunity to update parameters like force constants depending on alpha or on the time step.
The number of particles cannot be changed by a transformer, instead additional particles should be added using a patcher.
- __init__(param_manager, mapper, density_manager, builder_info, options, always_active_restraints, selectively_active_restraints)[source]
Initialize a Transformer
- Parameters
param_manager (
ParameterManager
) – parameter manager to handle sampling of paramtersbuilder_info (
dict
) – information from the system builder / patcheroptions (
RunOptions
) – the options for the runneralways_active_restraints (
List
[Restraint
]) – these restraints are always activeselectively_active_collections – these restraints are selected by the MELD algorithm
Methods
__init__
(param_manager, mapper, ...)Initialize a Transformer
add_interactions
(state, system, topology)Add new interactions to the system.
finalize
(state, system, topology)Finalize the transformer.
update
(state, simulation, alpha, timestep)Update the system according to alpha and timestep.
- add_interactions(state, system, topology)[source]
Add new interactions to the system.
This may involve:
Adding new forces, e.g. for restraints
Replacing an existing force with another, e.g. softcore interactions
This method must return the modified system. If the transformer does not add interactions, it may simply return the passed values.
- Parameters
state (
IState
) – the state of the systemsystem (
System
) – OpenMM system object to be modifiedtopology (
Topology
) – OpenMM topology object to be modified and/or used for indexing
- Return type
System
- finalize(state, system, topology)[source]
Finalize the transformer.
This method is guaranteed to be called after all forces are added to the system and provides an opportunity to do bookkeeping.
This method should not add any new forces.
- Parameters
state (
IState
) – the state of the systemsystem (
System
) – OpenMM system object to be modifiedtopology (
Topology
) – OpenMM topology object to be modified and/or used for indexing
- Return type
None
- update(state, simulation, alpha, timestep)[source]
Update the system according to alpha and timestep.
This method is called at the beginning of every stage. It should update forces and parameters as necessary.
- Parameters
state (
IState
) – the state of the systemsimulation (
Simulation
) – OpenMM simulation object to be modifiedalpha (
float
) – current value of alpha, ranges from 0 to 1stage – current stage of the simulation, starting from 0
- Return type
None