Operations¶
- class hoomd.Operations¶
A mutable collection of operations which act on a
Simulation.An
Operationsclass 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.Operationsinstance. 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.Operationsobjects manage multiple independent sequences described below.The types of operations which can be added to an
Operationsobject are tuners, updaters, integrators, writers, and computes. AnOperationsinstance 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.integrateorhoomd.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
Operationscontainer. Likewise, a single instance cannot be added to the sameOperationscontainer more than once.All
Operationsinstances start with ahoomd.tune.ParticleSorterinstance in theirtunersattribute. This increases simulation performance. However, users can choose to modify or remove this tuner if desired.Note
An
Operationsobject 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
Operationsinstance.- Parameters:
operation (hoomd.operation.Operation) – A HOOMD-blue tuner, updater, integrator, writer, or compute to add to the collection.
- Raises:
TypeError – If
operationis not of a valid type.
Note
Since only one integrator can be associated with an
Operationsobject at a time, this removes the current integrator when called with an integrator operation. Also, theintegratorproperty cannot be set toNoneusing this function. Useoperations.integrator = Noneexplicitly 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.
Operationsobjects have an initialintegratorproperty 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.
Truewhenis_tuning_completeisTruefor all children.Note
In MPI parallel execution,
is_tuning_completeisTrueonly 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
Operationsobject.Remove the item from the collection whose Python object
idis 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
operationis not found in this container.TypeError – If
operationis 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]