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. |
|
Details
Define quantities that vary over the simulation.
A Variant
object represents a function of the time step. Some
operations accept Variant
values for certain parameters, such as the
kT
parameter to hoomd.md.methods.thermostats.Bussi
.
See Variant
for details on creating user-defined variants or use one of the
provided subclasses.
- class hoomd.variant.Constant(value)¶
Bases:
Variant
A constant value.
- Parameters:
value (float) – The value.
Constant
returnsvalue
at all time steps.Example:
variant = hoomd.variant.Constant(1.0)
- __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.Example:
variant = hoomd.variant.Cycle(A=1.0, B=2.0, t_start=10_000, t_A=100_000, t_AB=1_000_000, t_B=200_000, t_BA=2_000_000)
- __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.Example:
variant = hoomd.variant.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.Example:
variant = hoomd.variant.Ramp(A=1.0, B=2.0, t_start=10_000, t_ramp=100_000)
- __eq__(other)¶
Return whether two variants are equivalent.
- class hoomd.variant.Variant¶
Variant base class.
Provides methods common to all variants and a base class for user-defined variants.
Subclasses should override the
__call__
,_min
, and_max
methods and must explicitly call the base class constructor in__init__
: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.- __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)\).
Modules