hoomd.variant.box

Overview

BoxVariant

Box-like vector variant base class.

Constant

A constant box variant.

Interpolate

Interpolate between two boxes linearly.

InverseVolumeRamp

Produce box arrays whose inverse volume changes linearly.

Details

Implement variants that return box parameters as a function of time.

class hoomd.variant.box.BoxVariant

Box-like vector variant base class.

hoomd.variant.box.BoxVariant provides an interface to vector variants that are valid hoomd.box.box_like objects. The return value of the __call__ method is a list of scalar values that represent the quantities Lx, Ly, Lz, xy, xz, and yz of a simulation box.

Subclasses should override the __call__ method and must explicitly call the base class constructor in __init__:

class CustomBoxVariant(hoomd.variant.box.BoxVariant):
    def __init__(self):
        hoomd.variant.box.BoxVariant.__init__(self)

    def __call__(self, timestep):
        return [10 + timestep/1e6, 10, 10, 0, 0, 0]
__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, float, float, float, float, float]

class hoomd.variant.box.Constant(box)

Bases: BoxVariant

A constant box variant.

Parameters:

box (hoomd.box.box_like) – The box.

Constant returns [box.Lx, box.Ly, box.Lz, box.xz, box.xz, box.yz] at all time steps.

class hoomd.variant.box.Interpolate(initial_box, final_box, variant)

Bases: BoxVariant

Interpolate between two boxes linearly.

Parameters:

Interpolate returns arrays corresponding to a linear interpolation between the initial and final boxes where the minimum of the variant gives initial_box and the maximum gives final_box:

\[\begin{split}\begin{align*} L_{x}' &= \lambda L_{2x} + (1 - \lambda) L_{1x} \\ L_{y}' &= \lambda L_{2y} + (1 - \lambda) L_{1y} \\ L_{z}' &= \lambda L_{2z} + (1 - \lambda) L_{1z} \\ xy' &= \lambda xy_{2} + (1 - \lambda) xy_{1} \\ xz' &= \lambda xz_{2} + (1 - \lambda) xz_{1} \\ yz' &= \lambda yz_{2} + (1 - \lambda) yz_{1} \\ \end{align*}\end{split}\]

Where initial_box is \((L_{ix}, L_{iy}, L_{iz}, xy_i, xz_i, yz_i)\), final_box is \((L_{fx}, L_{fy}, L_{fz}, xy_f, xz_f, yz_f)\), \(\lambda = \frac{f(t) - \min f}{\max f - \min f}\), \(t\) is the timestep, and \(f(t)\) is given by variant.

variant

A variant used to interpolate between the two boxes.

Type:

hoomd.variant.Variant

class hoomd.variant.box.InverseVolumeRamp(initial_box, final_volume, t_start, t_ramp)

Bases: BoxVariant

Produce box arrays whose inverse volume changes linearly.

Parameters:
  • initial_box (hoomd.box.box_like) – The initial box.

  • final_volume (float) – The final volume of the box.

  • t_start (int) – The time step at the start of the ramp.

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

InverseVolumeRamp produces box arrays that correspond to a box whose inverse volume (i.e., number density for a constant number of particles) varies linearly. The shape of the box remains constant, that is, the ratios of the lengths of the box vectors (\(L_y / L_x\) and \(L_z / L_x\)) and the tilt factors (\(xy\), \(xz\), \(yz\)) remain constant. For initial_box with volume \(V_0\) and final_volume \(V_f\), InverseVolumeRamp returns arrays corresponding to boxes with volume \(V(t)\):

\[\begin{split}V(t) &= \begin{cases} V_0 & t < t_{\mathrm{start}} \\ \left( \lambda V_f^{-1} + (1 - \lambda) V_0^{-1} \right)^{-1} & t_{\mathrm{start}} \leq t < t_{\mathrm{start}} + t_{\mathrm{ramp}} \\ V_f & t \geq t_{\mathrm{start}} + t_{\mathrm{ramp}} \end{cases}\end{split}\]

where \(\lambda = \frac{t - t_{\mathrm{start}}}{t_{\mathrm{ramp}} - t_{\mathrm{start}}}\).

final_volume

The volume of the final box.

Type:

float

t_start

The time step at the start of the ramp.

Type:

int

t_ramp

The length of the ramp.

Type:

int