hoomd.trigger¶
Overview
Trigger on all steps after a given step. |
|
Boolean and operation. |
|
Trigger on all steps before a given step. |
|
Negate a trigger. |
|
Trigger on a specific timestep. |
|
Boolean or operation. |
|
Trigger periodically. |
|
Base class trigger. |
|
An object that can serve as a trigger for an operation. |
Details
Triggers determine when most hoomd.operation.Operation
instances activate.
A Trigger
is a boolean valued function of the timestep. The operation will
perform its action when Trigger returns True
. A single trigger object
may be assigned to multiple operations.
See Trigger
for details on creating user-defined triggers or use one of the
provided subclasses.
- class hoomd.trigger.After(timestep)¶
Bases:
Trigger
Trigger on all steps after a given step.
- Parameters:
timestep (int) – The step before the trigger will start.
After
returnsTrue
for all time steps greater thantimestep
:return t > timestep
Example:
trigger = hoomd.trigger.After(1000)
- class hoomd.trigger.And(triggers)¶
Bases:
Trigger
Boolean and operation.
And
returnsTrue
when all the input triggers returnsTrue
:return all([f(t) for f in triggers])
Example:
trigger = hoomd.trigger.And([other_trigger1, other_trigger2])
- triggers¶
List of triggers.
- Type:
- class hoomd.trigger.Before(timestep)¶
Bases:
Trigger
Trigger on all steps before a given step.
- Parameters:
timestep (int) – The step after the trigger ends.
Before
evaluatesTrue
for all time steps less than thetimestep
:return t < timestep
Example:
trigger = hoomd.trigger.Before(5000)
- class hoomd.trigger.Not(trigger)¶
Bases:
Trigger
Negate a trigger.
- Parameters:
trigger (hoomd.trigger.Trigger) – The trigger object to negate.
Not
returns the boolean negation oftrigger
:return not trigger(t)
Example:
trigger = hoomd.trigger.Not(other_trigger)
- trigger¶
The trigger object to negate.
- Type:
- class hoomd.trigger.On(timestep)¶
Bases:
Trigger
Trigger on a specific timestep.
- Parameters:
timestep (int) – The timestep to trigger on.
On
returnsTrue
for steps equal totimestep
:return t == timestep
Example:
trigger = hoomd.trigger.On(1000)
- class hoomd.trigger.Or(triggers)¶
Bases:
Trigger
Boolean or operation.
Or
returnsTrue
when any of the input triggers returnsTrue
:return any([f(t) for f in triggers])
Example:
trig = hoomd.trigger.Or([other_trigger1, other_trigger2])
- class hoomd.trigger.Periodic(period, phase)¶
Bases:
Trigger
Trigger periodically.
Periodic
evaluatesTrue
everyperiod
steps offset by phase:return (t - phase) % period == 0
Example:
trigger = hoomd.trigger.Periodic(period=100)
- class hoomd.trigger.Trigger¶
Base class trigger.
Provides methods common to all triggers and a base class for user-defined triggers.
Subclasses should override the
Trigger.compute
method and must explicitly call the base class constructor in__init__
:class CustomTrigger(hoomd.trigger.Trigger): def __init__(self): hoomd.trigger.Trigger.__init__(self) def compute(self, timestep): return (timestep**(1 / 2)).is_integer()
- hoomd.trigger.trigger_like¶
An object that can serve as a trigger for an operation.
Any instance of a
Trigger
subclass is allowed, as well as an int instance or any object convertible to an int. The integer is converted to aPeriodic
trigger viaPeriodic(period=int(a))
wherea
is the passed integer.Note
Attributes that are
Trigger
objects can be set via atrigger_like
object.