OpenMMSimulation
- class openff.evaluator.protocols.openmm.OpenMMSimulation(protocol_id)[source]
Performs a molecular dynamics simulation in a given ensemble using an OpenMM backend.
This protocol employs the Langevin integrator implemented in the
openmmtools
package to propagate the state of the system using the default BAOAB splitting [1]_. Further, simulations which are run in the NPT simulation will have a Monte Carlo barostat (openmm.MonteCarloBarostat) applied every 25 steps (the OpenMM default).References
- [1] Leimkuhler, Ben, and Charles Matthews. “Numerical methods for stochastic
molecular dynamics.” Molecular Dynamics. Springer, Cham, 2015. 261-328.
- __init__(protocol_id)[source]
Methods
__init__
(protocol_id)apply_replicator
(replicator, template_values)Applies a ProtocolReplicator to this protocol.
can_merge
(other[, path_replacements])Determines whether this protocol can be merged with another.
execute
([directory, available_resources])Execute the protocol.
from_json
(file_path)Create this object from a JSON file.
from_schema
(schema)Initializes a protocol from it's schema definition.
get_attributes
([attribute_type])Returns all attributes of a specific attribute_type.
get_class_attribute
(reference_path)Returns one of this protocols, or any of its children's, attributes directly (rather than its value).
get_value
(reference_path)Returns the value of one of this protocols inputs / outputs.
get_value_references
(input_path)Returns a dictionary of references to the protocols which one of this protocols inputs (specified by input_path) takes its value from.
json
([file_path, format])Creates a JSON representation of this class.
merge
(other)Merges another Protocol with this one.
parse_json
(string_contents)Parses a typed json string into the corresponding class structure.
replace_protocol
(old_id, new_id)Finds each input which came from a given protocol
set_uuid
(value)Prepend a unique identifier to this protocols id.
set_value
(reference_path, value)Sets the value of one of this protocols inputs.
validate
([attribute_type])Validate the values of the attributes.
Attributes
Input - If true, the simulation will be performed using a GPU if available, otherwise it will be constrained to only using CPUs.
Input - Defines whether this protocols is allowed to merge with other protocols.
Input - The frequency (in multiples of output_frequency) with which to write to a checkpoint file, e.g.
A list of pointers to the protocols which this protocol takes input from.
Input - If true, periodic boundary conditions will be enabled.
Input - The thermodynamic ensemble to simulate in.
Input - An optional list of parameters to differentiate the evaluated energies with respect to.
Input - If true, the simulation will be run using double precision.
The unique id of this protocol.
Input - The file path to the starting coordinates.
Output - The observables collected during the simulation.
Output - The file path to the coordinates of the final system configuration.
Input - The frequency (in number of steps) with which to write to the output statistics and trajectory files.
A dictionary of the outputs of this property.
Input - The parameterized system object which encodes the systems potential energy function.
The inputs which must be set on this protocol.
A serializable schema for this object.
Input - The number of steps to propogate the system by at each iteration.
Input - The thermodynamic conditions to simulate under The default value of this attribute is not set and must be set by the user..
Input - The thermostat friction coefficient.
Input - The timestep to evolve the system by at each step.
Input - The number of times to propogate the system forward by the steps_per_iteration number of steps.
Output - The file path to the trajectory sampled during the simulation.
- allow_gpu_platforms
Input - If true, the simulation will be performed using a GPU if available, otherwise it will be constrained to only using CPUs. The default value of this attribute is
True
.- Type
- allow_merging
Input - Defines whether this protocols is allowed to merge with other protocols. The default value of this attribute is
True
.- Type
- apply_replicator(replicator, template_values, template_index=- 1, template_value=None, update_input_references=False)
Applies a ProtocolReplicator to this protocol. This method should clone any protocols whose id contains the id of the replicator (in the format $(replicator.id)).
- Parameters
replicator (ProtocolReplicator) – The replicator to apply.
template_values (list of Any) –
A list of the values which will be inserted into the newly replicated protocols.
This parameter is mutually exclusive with template_index and template_value
template_index (int, optional) –
A specific value which should be used for any protocols flagged as to be replicated by the replicator. This option is mainly used when replicating children of an already replicated protocol.
This parameter is mutually exclusive with template_values and must be set along with a template_value.
template_value (Any, optional) –
A specific index which should be used for any protocols flagged as to be replicated by the replicator. This option is mainly used when replicating children of an already replicated protocol.
This parameter is mutually exclusive with template_values and must be set along with a template_index.
update_input_references (bool) –
If true, any protocols which take their input from a protocol which was flagged for replication will be updated to take input from the actually replicated protocol. This should only be set to true if this protocol is not nested within a workflow or a protocol group.
This option cannot be used when a specific template_index or template_value is providied.
- Returns
A dictionary of references to all of the protocols which have been replicated, with keys of original protocol ids. Each value is comprised of a list of the replicated protocol ids, and their index into the template_values array.
- Return type
dict of ProtocolPath and list of tuple of ProtocolPath and int
- can_merge(other, path_replacements=None)
Determines whether this protocol can be merged with another.
- Parameters
other (
Protocol
) – The protocol to compare against.path_replacements (list of tuple of str, optional) – Replacements to make in any value reference protocol paths before comparing for equality.
- Returns
True if the two protocols are safe to merge.
- Return type
- checkpoint_frequency
Input - The frequency (in multiples of output_frequency) with which to write to a checkpoint file, e.g. if output_frequency=100 and checkpoint_frequency==2, a checkpoint file would be saved every 200 steps. When two protocols are merged, the largest value of this attribute from either protocol is retained. The default value of this attribute is
10
. This attribute is optional.- Type
- property dependencies
A list of pointers to the protocols which this protocol takes input from.
- Type
list of ProtocolPath
- enable_pbc
Input - If true, periodic boundary conditions will be enabled. The default value of this attribute is
True
.- Type
- ensemble
Input - The thermodynamic ensemble to simulate in. The default value of this attribute is
Ensemble.NPT
.- Type
Ensemble
- execute(directory='', available_resources=None)
Execute the protocol.
- Parameters
directory (str) – The directory to store output data in.
available_resources (ComputeResources) – The resources available to execute on. If None, the protocol will be executed on a single CPU.
- classmethod from_json(file_path)
Create this object from a JSON file.
- Parameters
file_path (str) – The path to load the JSON from.
- Returns
The parsed class.
- Return type
cls
- classmethod from_schema(schema)
Initializes a protocol from it’s schema definition.
- Parameters
schema (ProtocolSchema) – The schema to initialize the protocol using.
- Returns
The initialized protocol.
- Return type
cls
- classmethod get_attributes(attribute_type=None)
Returns all attributes of a specific attribute_type.
- Parameters
attribute_type (type of Attribute, optional) – The type of attribute to search for.
- Returns
The names of the attributes of the specified type.
- Return type
list of str
- get_class_attribute(reference_path)
Returns one of this protocols, or any of its children’s, attributes directly (rather than its value).
- Parameters
reference_path (ProtocolPath) – The path pointing to the attribute to return.
- Returns
The class attribute.
- Return type
- get_value(reference_path)
Returns the value of one of this protocols inputs / outputs.
- Parameters
reference_path (ProtocolPath) – The path pointing to the value to return.
- Returns
The value of the input / output
- Return type
Any
- get_value_references(input_path)
Returns a dictionary of references to the protocols which one of this protocols inputs (specified by input_path) takes its value from.
Notes
Currently this method only functions correctly for an input value which is either currently a
ProtocolPath
, or a list / dict which contains at least oneProtocolPath
.- Parameters
input_path (ProtocolPath) – The input value to check.
- Returns
A dictionary of the protocol paths that the input targeted by input_path depends upon.
- Return type
dict of ProtocolPath and ProtocolPath
- gradient_parameters
Input - An optional list of parameters to differentiate the evaluated energies with respect to.
- Type
- high_precision
Input - If true, the simulation will be run using double precision. The default value of this attribute is
False
.- Type
- id
The unique id of this protocol. The default value of this attribute is not set and must be set by the user..
- Type
- input_coordinate_file
Input - The file path to the starting coordinates. The default value of this attribute is not set and must be set by the user..
- Type
- observables
Output - The observables collected during the simulation. The default value of this attribute is not set and must be set by the user..
- Type
- output_coordinate_file
Output - The file path to the coordinates of the final system configuration. The default value of this attribute is not set and must be set by the user..
- Type
- output_frequency
Input - The frequency (in number of steps) with which to write to the output statistics and trajectory files. When two protocols are merged, the largest value of this attribute from either protocol is retained. The default value of this attribute is
3000
.- Type
- parameterized_system
Input - The parameterized system object which encodes the systems potential energy function. The default value of this attribute is not set and must be set by the user..
- Type
ParameterizedSystem
- classmethod parse_json(string_contents)
Parses a typed json string into the corresponding class structure.
- replace_protocol(old_id, new_id)
- Finds each input which came from a given protocol
and redirects it to instead take input from a new one.
Notes
This method is mainly intended to be used only when merging multiple protocols into one.
- set_uuid(value)
Prepend a unique identifier to this protocols id. If the id already has a prepended uuid, it will be overwritten by this value.
- Parameters
value (str) – The uuid to prepend.
- set_value(reference_path, value)
Sets the value of one of this protocols inputs.
- Parameters
reference_path (ProtocolPath) – The path pointing to the value to return.
value (Any) – The value to set.
- steps_per_iteration
Input - The number of steps to propogate the system by at each iteration. The total number of steps performed by this protocol will be total_number_of_iterations * steps_per_iteration. The default value of this attribute is
1000000
.- Type
- thermodynamic_state
Input - The thermodynamic conditions to simulate under The default value of this attribute is not set and must be set by the user..
- Type
- thermostat_friction
Input - The thermostat friction coefficient. When two protocols are merged, the largest value of this attribute from either protocol is retained. The default value of this attribute is
1.0 / picosecond
.- Type
Quantity
- timestep
Input - The timestep to evolve the system by at each step. When two protocols are merged, the largest value of this attribute from either protocol is retained. The default value of this attribute is
2.0 femtosecond
.- Type
Quantity
- total_number_of_iterations
Input - The number of times to propogate the system forward by the steps_per_iteration number of steps. The total number of steps performed by this protocol will be total_number_of_iterations * steps_per_iteration. The default value of this attribute is
1
.- Type
- trajectory_file_path
Output - The file path to the trajectory sampled during the simulation. The default value of this attribute is not set and must be set by the user..
- Type
- validate(attribute_type=None)
Validate the values of the attributes. If attribute_type is set, only attributes of that type will be validated.
- Parameters
attribute_type (type of Attribute, optional) – The type of attribute to validate.
- Raises
ValueError or AssertionError –