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:
TriggerTrigger on all steps after a given step.
- Parameters:
timestep (int) – The step before the trigger will start.
AfterreturnsTruefor all time steps greater thantimestep:return t > timestep
Example:
trigger = hoomd.trigger.After(1000)
- class hoomd.trigger.And(triggers)#
Bases:
TriggerBoolean and operation.
AndreturnsTruewhen 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:
TriggerTrigger on all steps before a given step.
- Parameters:
timestep (int) – The step after the trigger ends.
BeforeevaluatesTruefor all time steps less than thetimestep:return t < timestep
Example:
trigger = hoomd.trigger.Before(5000)
- class hoomd.trigger.Not(trigger)#
Bases:
TriggerNegate a trigger.
- Parameters:
trigger (hoomd.trigger.Trigger) – The trigger object to negate.
Notreturns 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:
TriggerTrigger on a specific timestep.
- Parameters:
timestep (int) – The timestep to trigger on.
OnreturnsTruefor steps equal totimestep:return t == timestep
Example:
trigger = hoomd.trigger.On(1000)
- class hoomd.trigger.Or(triggers)#
Bases:
TriggerBoolean or operation.
OrreturnsTruewhen 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:
TriggerTrigger periodically.
PeriodicevaluatesTrueeveryperiodsteps 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.computemethod 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
Triggersubclass is allowed, as well as an int instance or any object convertible to an int. The integer is converted to aPeriodictrigger viaPeriodic(period=int(a))whereais the passed integer.Note
Attributes that are
Triggerobjects can be set via atrigger_likeobject.