# hoomd.variant¶

Overview

 hoomd.variant.Constant A constant value. hoomd.variant.Cycle A cycle of linear ramps. hoomd.variant.Power A approach from initial to final value of x ^ (power). hoomd.variant.Ramp A linear ramp. hoomd.variant.Variant Variant base class.

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 NVT.

class hoomd.variant.Constant(value)

A constant value.

Parameters

value (float) – The value.

Constant returns value at all time steps.

value

The value.

Type

float

class hoomd.variant.Cycle(A, B, t_start, t_A, t_AB, t_B, t_BA)

A cycle of linear ramps.

Parameters
• A (float) – The first value.

• B (float) – The second value.

• t_start (int) – The start time step.

• t_A (int) – The hold time at the first value.

• t_AB (int) – The time spent ramping from A to B.

• t_B (int) – The hold time at the second value.

• t_BA (int) – The time spent ramping from B to A.

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.

A

The first value.

Type

float

B

The second value.

Type

float

t_start

The start time step.

Type

int

t_A

The holding time at A.

Type

int

t_AB

The time spent ramping from A to B.

Type

int

t_B

The holding time at B.

Type

int

t_BA

The time spent ramping from B to A.

Type

int

class hoomd.variant.Power(A, B, power, t_start, t_ramp)

A approach from initial to final value of x ^ (power).

Parameters
• A (float) – The start value.

• B (float) – The end value.

• power (float) – The power of the approach to B.

• t_start (int) – The start time step.

• t_ramp (int) – The length of the ramp.

Power holds the value A until time t_start. Then it progresses at $$x^{power}$$ from A to B over t_ramp steps and holds the value B after that.

p = Power(2, 8, 1 / 10, 10, 20)

A

The start value.

Type

float

B

The end value.

Type

float

power

The power of the approach to B.

Type

float

t_start

The start time step.

Type

int

t_ramp

The length of the ramp.

Type

int

class hoomd.variant.Ramp(A, B, t_start, t_ramp)

A linear ramp.

Parameters
• A (float) – The start value.

• B (float) – The end value.

• t_start (int) – The start time step.

• t_ramp (int) – The length of the ramp.

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.

A

The start value.

Type

float

B

The end value.

Type

float

t_start

The start time step.

Type

int

t_ramp

The length of the ramp.

Type

int

class hoomd.variant.Variant

Variant base class.

Variants define values as a function of the simulation time step. Use one of the built in types or define your own custom function:

class CustomVariant(hoomd.variant.Variant):
def __init__(self):
hoomd.variant.Variant.__init__(self)

def __call__(self, timestep):
return (float(timestep)**(1 / 2))

__call__(timestep)

Evaluate the function.

Parameters

timestep (int) – The time step.

Returns

The value of the function at the given time step.

Return type

float