hoomd.variant.box¶
Overview
Box-like vector variant base class. |
|
A constant box variant. |
|
Interpolate between two boxes linearly. |
|
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 validhoomd.box.box_like
objects. The return value of the__call__
method is a list of scalar values that represent the quantitiesLx
,Ly
,Lz
,xy
,xz
, andyz
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]
- 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:
initial_box (hoomd.box.box_like) – The initial box.
final_box (hoomd.box.box_like) – The final box.
variant (hoomd.variant.variant_like) – A variant used to interpolate between the two boxes.
Interpolate
returns arrays corresponding to a linear interpolation between the initial and final boxes where the minimum of the variant givesinitial_box
and the maximum givesfinal_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 byvariant
.- variant¶
A variant used to interpolate between the two boxes.
- Type:
- 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. Forinitial_box
with volume \(V_0\) andfinal_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}}}\).