BoxMC

class hoomd.hpmc.update.BoxMC(trigger, P)

Bases: Updater

Apply box updates to sample isobaric and related ensembles.

Parameters:
  • P (hoomd.variant.variant_like) – The pressure PP [energy][length2][\mathrm{energy}] \cdot [\mathrm{length}^{-2}] in 2D or [energy][length3][\mathrm{energy}] \cdot [\mathrm{length}^{-3}] in 3D.

  • trigger (hoomd.trigger.trigger_like) – Select the timesteps to perform box trial moves.

Use BoxMC in conjunction with an HPMC integrator to allow the simulation box to undergo random fluctuations at constant pressure, or random deformations at constant volume. BoxMC supports both isotropic and anisotropic volume change moves as well as shearing of the simulation box. A single BoxMC instance may apply multiple types of box moves during a simulation run.

Box move types

By default, no moves are applied (the weight values for all move types default to 0). In a given timestep, the type of move is selected randomly with probability:

p=wkkwkp = \frac{w_k}{\sum_k w_k}

where wkw_k is the weight of the move type.

A given box move proposes a trial simulation box (Lxt,Lyt,Lzt,xyt,xzt,yzt)(L_x^t, L_y^t, L_z^t, xy^t, xz^t, yz^t) as a change from the current box: (Lx,Ly,Lz,xy,xz,yz)(L_x, L_y, L_z, xy, xz, yz). The form of the change depends on the selected move type:

  • volume (mode='standard'): Change the volume (or area in 2D) of the simulation box while maining fixed aspect ratios Lx/LyLx/Ly, Lx/LzLx/Lz. In 3D:

    Vt=V+uLxt=(LxLyLxLzVt)1/3Lyt=LxtLyLxLzt=LxtLzLxxyt=xyxzt=xzyzt=yz\begin{split} V^t &= V + u \\ L_x^t &= \left( \frac{Lx}{Ly} \frac{Lx}{Lz} V^t \right)^{1/3} \\ L_y^t &= L_x^t \frac{Ly}{Lx} \\ L_z^t &= L_x^t \frac{Lz}{Lx} \\ xy^t &= xy \\ xz^t &= xz \\ yz^t &= yz \\ \end{split}

    where uu is a random value uniformly distributed in the interval [δvolume,δvolume][-\delta_\mathrm{volume}, \delta_\mathrm{volume}].

    In 2D:

    Vt=V+uLxt=(LxLyVt)1/2Lyt=LxtLyLxxyt=xy\begin{split} V^t &= V + u \\ L_x^t &= \left( \frac{Lx}{Ly} V^t \right)^{1/2} \\ L_y^t &= L_x^t \frac{Ly}{Lx} \\ xy^t &= xy \\ \end{split}
  • volume (mode='ln'): Change the volume (or area in 2D) of the simulation box while maining fixed aspect ratios Lx/LyLx/Ly, Lx/LzLx/Lz. In 3D:

    Vt=VeuLxt=(LxLyLxLzVt)1/3Lyt=LxtLyLxLzt=LxtLzLxxyt=xyxzt=xzyzt=yz\begin{split} V^t &= V e^u \\ L_x^t &= \left( \frac{Lx}{Ly} \frac{Lx}{Lz} V^t \right)^{1/3} \\ L_y^t &= L_x^t \frac{Ly}{Lx} \\ L_z^t &= L_x^t \frac{Lz}{Lx} \\ xy^t &= xy \\ xz^t &= xz \\ yz^t &= yz \\ \end{split}

    where uu is a random value uniformly distributed in the interval [δvolume,δvolume][-\delta_\mathrm{volume}, \delta_\mathrm{volume}].

    In 2D:

    Vt=VeuLxt=(LxLyVt)1/2Lyt=LxtLyLxxyt=xy\begin{split} V^t &= V e^u \\ L_x^t &= \left( \frac{Lx}{Ly} V^t \right)^{1/2} \\ L_y^t &= L_x^t \frac{Ly}{Lx} \\ xy^t &= xy \\ \end{split}
  • aspect: Change the aspect ratio of the simulation box while maintaining a fixed volume. In 3D:

    \begin{split} L_k^t & = \begin{cases} L_k(1 + a) & u < 0.5 \\ L_k \frac{1}{1+a} & u \ge 0.5 \end{cases} \\ L_{m \ne k}^t & = L_m \sqrt{\frac{L_k}{L_k^t}} & xy^t &= xy \\ xz^t &= xz \\ yz^t &= yz \\ \end{split}

    where uu is a random value uniformly distributed in the interval [0,1][0, 1], aa is a random value uniformly distributed in the interval [0,δaspect][0, \delta_\mathrm{aspect}] and kk is randomly chosen uniformly from the set {x,y,z}\{x, y, z\}.

    In 2D:

    Lkt={Lk(1+a)u<0.5Lk11+au0.5Lmkt=LmLkLktxyt=xy\begin{split} L_k^t & = \begin{cases} L_k(1 + a) & u < 0.5 \\ L_k \frac{1}{1+a} & u \ge 0.5 \end{cases} \\ L_{m \ne k}^t & = L_m \frac{L_k}{L_k^t} \\ xy^t &= xy \\ \end{split}
  • length: Change the box lengths:

    Lkt=Lk+uL_k^t = L_k + u

    where uu is a random value uniformly distributed in the interval [δlength,k,δlength,k][-\delta_{\mathrm{length},k}, -\delta_{\mathrm{length},k}], and kk is randomly chosen uniformly from the set {a:a{x,y,z},δlength,a0}\{a : a \in \{x, y, z\}, \delta_{\mathrm{length},a} \ne 0 \}.

  • shear: Change the box shear parameters. In 3D:

    (xyt,xzt,yzt)={(xy+sxy,xz,yz)u<13(xyt=xy,xz+sxz,yz)13u<23(xyt=xy,xz,yz+syz)23u1(xy^t, xz^t, yz^t) = \begin{cases} \left(xy + s_{xy}, \enspace xz, \enspace yz \right) & u < \frac{1}{3} \\ \left( xy^t = xy, \enspace xz + s_{xz}, \enspace yz \right) & \frac{1}{3} \le u < \frac{2}{3} \\ \left( xy^t = xy, \enspace xz, \enspace yz + s_{yz} \right) & \frac{2}{3} \le u \le 1 \\ \end{cases} \\

    where uu is a random value uniformly distributed in the interval [0,1][0, 1] and sks_k is a random value uniformly distributed in the interval [δshear,k,δshear,k][-\delta_{\mathrm{shear},k}, \delta_{\mathrm{shear},k}]. BoxMC attempts and records trial moves for shear parameters even when δshear,k=0\delta_{\mathrm{shear},k}=0.

    In 2D:

    xyt=xy+sxyxy^t = xy + s_{xy}

Acceptance

All particle particle positions are scaled into the trial box to form the trial configuration CtC^t:

rit=sxa1t+sya2t+sza3ta1t+a2t+a3t2\vec{r}_i^t = s_x \vec{a}_1^t + s_y \vec{a}_2^t + s_z \vec{a}_3^t - \frac{\vec{a}_1^t + \vec{a}_2^t + \vec{a}_3^t}{2}

where akt\vec{a}_k^t are the new box vectors determined by (Lxt,Lyt,Lzt,xyt,xzt,yzt)(L_x^t, L_y^t, L_z^t, xy^t, xz^t, yz^t) and the scale factors are determined by the current particle position ri\vec{r}_i and the box vectors ak\vec{a}_k:

ri=sxa1+sya2+sza3a1+a2+a32\vec{r}_i = s_x \vec{a}_1 + s_y \vec{a}_2 + s_z \vec{a}_3 - \frac{\vec{a}_1 + \vec{a}_2 + \vec{a}_3}{2}

The trial move is accepted with the probability:

paccept={exp((βΔH+βΔU))βΔH+βΔU>01βΔH+βΔU0p_\mathrm{accept} = \begin{cases} \exp(-(\beta \Delta H + \beta \Delta U)) & \beta \Delta H + \beta \Delta U > 0 \\ 1 & \beta \Delta H + \beta \Delta U \le 0 \\ \end{cases}

where β=1kT\beta = \frac{1}{kT} (set in HPMCIntegrator.kT) and ΔU=UtU\Delta U = U^t - U is the difference in potential energy. ΔH=P(VtV)Nparticlesln(Vt/V)/β\Delta H = P (V^t - V) - N_\mathrm{particles} \cdot \ln(V^t / V) / \beta for most move types. It is P(VtV)(Nparticles+1)ln(Vt/V)/βP (V^t - V) - (N_\mathrm{particles}+1) \cdot \ln(V^t / V) / \beta for ln volume moves.

When the trial move is accepted, the system state is set to the the trial configuration. When it is not accepted, the move is rejected and the state is not modified.

Mixed precision

BoxMC uses reduced precision floating point arithmetic when checking for particle overlaps in the local particle reference frame.


Members inherited from AutotunedObject:

property kernel_parameters

Kernel parameters. Read more...

property is_tuning_complete

Check if kernel parameter tuning is complete. Read more...

tune_kernel_parameters()

Start tuning kernel parameters. Read more...


Members inherited from TriggeredOperation:

trigger

The trigger to activate this operation. Read more...


Members defined in BoxMC:

aspect

Parameters for isovolume aspect ratio moves. The dictionary has the following keys:

  • weight (float) - Relative weight of aspect box moves.

  • delta (float) - Maximum relative change of box aspect ratio δaspect[dimensionless]\delta_\mathrm{aspect} [\mathrm{dimensionless}].

Type:

dict

instance

When using multiple BoxMC updaters in a single simulation, give each a unique value for instance so they generate different streams of random numbers.

Type:

int

length

Parameters for isobaric box length moves that change box lengths independently. The dictionary has the following keys:

  • weight (float) - Maximum change of HOOMD-blue box parameters Lx, Ly, and Lz.

  • delta (tuple[float, float, float]) - Maximum change of the box lengths (δlength,x,δlength,y,δlength,z)[length](\delta_{\mathrm{length},x}, \delta_{\mathrm{length},y}, \delta_{\mathrm{length},z}) [\mathrm{length}].

Type:

dict

P

The pressure PP [energy length2][\mathrm{energy} \ \mathrm{length}^{-2}] in 2D or [energy length3][\mathrm{energy} \ \mathrm{length}^{-3}] in 3D.

Type:

hoomd.variant.Variant

volume

Parameters for isobaric volume moves that scale the box lengths uniformly. The dictionary has the following keys:

  • weight (float) - Relative weight of volume box moves.

  • mode (str) - standard proposes changes to the box volume and ln proposes changes to the logarithm of the volume. Initially starts off in ‘standard’ mode.

  • delta (float) - Maximum change in V or ln(V) where V is box area (2D) or volume (3D) δvolume\delta_\mathrm{volume}.

Type:

dict

shear

Parameters for isovolume box shear moves. The dictionary has the following keys:

  • weight (float) - Relative weight of shear box moves.

  • delta (tuple[float, float, float]) - maximum change of the box tilt factor (δshear,xy,δshear,xz,δshear,yz)[dimensionless](\delta_{\mathrm{shear},xy}, \delta_{\mathrm{shear},xz}, \delta_{\mathrm{shear},yz}) [\mathrm{dimensionless}].

  • reduce (float) - Maximum number of lattice vectors of shear to allow before applying lattice reduction. Values less than 0.5 disable shear reduction.

Type:

dict

property aspect_moves

The accepted and rejected aspect moves.

(0, 0) before the first call to Simulation.run.

(Loggable: category=”sequence”)

Type:

tuple[int, int]

property counter

Trial move counters.

The counter object has the following attributes:

  • volume: tuple [int, int] - Number of accepted and rejected volume and length moves.

  • shear: tuple [int, int] - Number of accepted and rejected shear moves.

  • aspect: tuple [int, int] - Number of accepted and rejected aspect moves.

Note

The counts are reset to 0 at the start of each call to hoomd.Simulation.run. Before the first call to Simulation.run, counter is None.

property shear_moves

The accepted and rejected shear moves.

(0, 0) before the first call to Simulation.run.

(Loggable: category=”sequence”)

Type:

tuple[int, int]

property volume_moves

The accepted and rejected volume and length moves.

(0, 0) before the first call to Simulation.run.

(Loggable: category=”sequence”)

Type:

tuple[int, int]