hoomd.variant¶
Overview
A constant value. |
|
A cycle of linear ramps. |
|
An approach from initial to final value following |
|
A linear ramp. |
|
Variant base class. |
|
Objects that are like a variant. |
Details
Define quantities that vary over the simulation.
A Variant
object represents a scalar function of the time step. Some
operations accept Variant
values for certain parameters, such as the
kT
parameter to hoomd.md.methods.NVT
.
Use one of the built in variant types, or define your own custom function in Python:
class CustomVariant(hoomd.variant.Variant):
def __init__(self):
hoomd.variant.Variant.__init__(self)
def __call__(self, timestep):
return (float(timestep)**(1 / 2))
def _min(self):
return 0.0
def _max(self):
return float('inf')
Note
Provide the minimum and maximum values in the _min
and _max
methods respectively.
- class hoomd.variant.Constant(value)¶
Bases:
Variant
A constant value.
- Parameters
value (float) – The value.
Constant
returnsvalue
at all time steps.- __eq__(other)¶
Return whether two variants are equivalent.
- class hoomd.variant.Cycle(A, B, t_start, t_A, t_AB, t_B, t_BA)¶
Bases:
Variant
A cycle of linear ramps.
- Parameters
Cycle
holds the value A until time t_start. It continues holding that value until t_start + t_A. Then it ramps linearly from A to B over t_AB steps and holds the value B for t_B steps. After this, it ramps back from B to A over t_BA steps and repeats the cycle starting with t_A.Cycle
repeats this cycle indefinitely.- __eq__(other)¶
Return whether two variants are equivalent.
- class hoomd.variant.Power(A, B, power, t_start, t_ramp)¶
Bases:
Variant
An approach from initial to final value following
t**power
.- Parameters
Power
holds the value A until time t_start. Then it progresses at \(t^{\mathrm{power}}\) from A to B over t_ramp steps and holds the value B after that.p = Power(A=2, B-8, power=1 / 10, t_start=10, t_ramp=20)
- __eq__(other)¶
Return whether two variants are equivalent.
- class hoomd.variant.Ramp(A, B, t_start, t_ramp)¶
Bases:
Variant
A linear ramp.
- Parameters
Ramp
holds the value A until time t_start. Then it ramps linearly from A to B over t_ramp steps and holds the value B.- __eq__(other)¶
Return whether two variants are equivalent.
- class hoomd.variant.Variant¶
Variant base class.
Variants are scalar valued functions of the simulation time step.
- __call__(timestep)¶
Evaluate the function.
- __getstate__()¶
Get the variant’s
__dict__
attribute.
- __setstate__(state)¶
Restore the state of the variant.
- property max¶
The maximum value of this variant for \(t \in [0,\infty)\).
- property min¶
The minimum value of this variant for \(t \in [0,\infty)\).
- hoomd.variant.variant_like¶
Objects that are like a variant.
Any subclass of
Variant
is accepted along with float instances and objects convertible to float. They are internally converted to variants of typeConstant
viaConstant(float(a))
wherea
is the float or float convertible object.Note
Attributes that are
Variant
objects can be set via avariant_like
object.