Operations¶
- class hoomd.Operations¶
A mutable collection of operations which act on a
Simulation
.An
Operations
class instance contains all the operations acting on a simulation. These operations are classes that perform various actions on ahoomd.Simulation
. Operations can be added and removed at any point from ahoomd.Operations
instance. The class provides the interface defined bycollections.abc.Collection
. Other methods for manipulating instances mimic Python objects where possible, but the class is not simply a mutable list or set.Operations
objects manage multiple independent sequences described below.The types of operations which can be added to an
Operations
object are tuners, updaters, integrators, writers, and computes. AnOperations
instance can have zero or one integrator and any number of tuners, updaters, writers, or computes. To see examples of these types of operations seehoomd.tune
(tuners),hoomd.update
(updaters),hoomd.hpmc.integrate
orhoomd.md.Integrator
(integrators),hoomd.write
(writers), andhoomd.md.compute.ThermodynamicQuantities
(computes).A given instance of an operation class can only be added to a single
Operations
container. Likewise, a single instance cannot be added to the sameOperations
container more than once.All
Operations
instances start with ahoomd.tune.ParticleSorter
instance in theirtuners
attribute. This increases simulation performance. However, users can choose to modify or remove this tuner if desired.Note
An
Operations
object is created by default when a new simulation is created.- __contains__(operation)¶
Whether an operation is contained in this container.
- Parameters:
operation – Returns whether this exact operation is contained in the collection.
Example:
operation in simulation.operations
- __getstate__()¶
Get the current state of the operations container for pickling.
- __iadd__(operation)¶
Works the same as
Operations.add
.- Parameters:
operation (hoomd.operation.Operation) – A HOOMD-blue tuner, updater, integrator, writer, or compute to add to the object.
Example:
simulation.operations += operation
- __isub__(operation)¶
Works the same as
Operations.remove
.- Parameters:
operation (hoomd.operation.Operation) – A HOOMD-blue integrator, tuner, updater, integrator, analyzer, or compute to remove from the collection.
Example:
simulation.operations -= operation
- __iter__()¶
Iterates through all contained operations.
Example:
for operation in simulation.operations: pass
- __len__()¶
Return the number of operations contained in this collection.
Example:
len(simulation.operations)
- add(operation)¶
Add an operation to this container.
Adds the provided operation to the appropriate attribute of the
Operations
instance.- Parameters:
operation (hoomd.operation.Operation) – A HOOMD-blue tuner, updater, integrator, writer, or compute to add to the collection.
- Raises:
TypeError – If
operation
is not of a valid type.
Note
Since only one integrator can be associated with an
Operations
object at a time, this removes the current integrator when called with an integrator operation. Also, theintegrator
property cannot be set toNone
using this function. Useoperations.integrator = None
explicitly for this.Example:
simulation.operations.add(operation)
- property computes¶
A list of compute operations.
Holds the list of computes associated with this collection. The list can be modified as a standard Python list.
- Type:
list[
hoomd.operation.Compute
]
- property integrator¶
An MD or HPMC integrator object.
Operations
objects have an initialintegrator
property ofNone
. Can be set to MD or HPMC integrators. The property can also be set toNone
.Examples:
simulation.operations.integrator = hoomd.md.Integrator(dt=0.001)
simulation.operations.integrator = None
- property is_tuning_complete¶
Check whether all children have completed tuning.
True
whenis_tuning_complete
isTrue
for all children.Note
In MPI parallel execution,
is_tuning_complete
isTrue
only when all children on all ranks have completed tuning.Example:
while not simulation.operations.is_tuning_complete: simulation.run(1000)
- Type:
- remove(operation)¶
Remove an operation from the
Operations
object.Remove the item from the collection whose Python object
id
is the same asoperation
.- Parameters:
operation (hoomd.operation.Operation) – A HOOMD-blue integrator, tuner, updater, integrator, or compute to remove from the container.
- Raises:
ValueError – If
operation
is not found in this container.TypeError – If
operation
is not of a valid type.
Example:
simulation.operations.remove(operation)
- tune_kernel_parameters()¶
Start tuning kernel parameters in all children.
Example:
simulation.operations.tune_kernel_parameters()
- property tuners¶
A list of tuner operations.
Holds the list of tuners associated with this collection. The list can be modified as a standard Python list.
- Type:
list[
hoomd.operation.Tuner
]
- property updaters¶
A list of updater operations.
Holds the list of updaters associated with this collection. The list can be modified as a standard Python list.
- Type:
list[
hoomd.operation.Updater
]
- property writers¶
A list of writer operations.
Holds the list of writers associated with this collection. The list can be modified as a standard Python list.
- Type:
list[
hoomd.operation.Writer
]