hoomd.lattice

Overview

hoomd.lattice.bcc Create a body centered cubic lattice (3D).
hoomd.lattice.fcc Create a face centered cubic lattice (3D).
hoomd.lattice.hex Create a hexagonal lattice (2D).
hoomd.lattice.sc Create a simple cubic lattice (3D).
hoomd.lattice.sq Create a square lattice (2D).
hoomd.lattice.unitcell Define a unit cell.

Details

Define lattices.

hoomd.lattice provides a general interface to define lattices to initialize systems.

hoomd.lattice.bcc(a, type_name=’A’)

Create a body centered cubic lattice (3D).

Parameters:
  • a (float) – Lattice constant.
  • type_name (str) – Particle type name.

The body centered cubic unit cell has 2 particles:

\begin{eqnarray*} \vec{r}& =& \left(\begin{array}{ccc} 0 & 0 & 0 \\ \frac{a}{2} & \frac{a}{2} & \frac{a}{2} \\ \end{array}\right) \end{eqnarray*}

And the box matrix:

\begin{eqnarray*} \mathbf{h}& =& \left(\begin{array}{ccc} a & 0 & 0 \\ 0 & a & 0 \\ 0 & 0 & a \\ \end{array}\right) \end{eqnarray*}
hoomd.lattice.fcc(a, type_name=’A’)

Create a face centered cubic lattice (3D).

Parameters:
  • a (float) – Lattice constant.
  • type_name (str) – Particle type name.

The face centered cubic unit cell has 4 particles:

\begin{eqnarray*} \vec{r}& =& \left(\begin{array}{ccc} 0 & 0 & 0 \\ 0 & \frac{a}{2} & \frac{a}{2} \\ \frac{a}{2} & 0 & \frac{a}{2} \\ \frac{a}{2} & \frac{a}{2} & 0\\ \end{array}\right) \end{eqnarray*}

And the box matrix:

\begin{eqnarray*} \mathbf{h}& =& \left(\begin{array}{ccc} a & 0 & 0 \\ 0 & a & 0 \\ 0 & 0 & a \\ \end{array}\right) \end{eqnarray*}
hoomd.lattice.hex(a, type_name=’A’)

Create a hexagonal lattice (2D).

Parameters:
  • a (float) – Lattice constant.
  • type_name (str) – Particle type name.

hex creates a hexagonal lattice in a rectangular box. It has 2 particles, one at the corner and one at the center of the rectangle. This is not the primitive unit cell, but is more convenient to work with because of its shape.

\begin{eqnarray*} \vec{r}& =& \left(\begin{array}{ccc} 0 & 0 \\ \frac{a}{2} & \sqrt{3} \frac{a}{2} \\ \end{array}\right) \end{eqnarray*}

And the box matrix:

\begin{eqnarray*} \mathbf{h}& =& \left(\begin{array}{ccc} a & 0 \\ 0 & \sqrt{3} a \\ 0 & 0 \\ \end{array}\right) \end{eqnarray*}
hoomd.lattice.sc(a, type_name=’A’)

Create a simple cubic lattice (3D).

Parameters:
  • a (float) – Lattice constant.
  • type_name (str) – Particle type name.

The simple cubic unit cell has 1 particle:

\begin{eqnarray*} \vec{r}& =& \left(\begin{array}{ccc} 0 & 0 & 0 \\ \end{array}\right) \end{eqnarray*}

And the box matrix:

\begin{eqnarray*} \mathbf{h}& =& \left(\begin{array}{ccc} a & 0 & 0 \\ 0 & a & 0 \\ 0 & 0 & a \\ \end{array}\right) \end{eqnarray*}
hoomd.lattice.sq(a, type_name=’A’)

Create a square lattice (2D).

Parameters:
  • a (float) – Lattice constant.
  • type_name (str) – Particle type name.

The simple square unit cell has 1 particle:

\begin{eqnarray*} \vec{r}& =& \left(\begin{array}{ccc} 0 & 0 \\ \end{array}\right) \end{eqnarray*}

And the box matrix:

\begin{eqnarray*} \mathbf{h}& =& \left(\begin{array}{ccc} a & 0 \\ 0 & a \\ \end{array}\right) \end{eqnarray*}
class hoomd.lattice.unitcell(N, a1, a2, a3, dimensions=3, position=None, type_name=None, mass=None, charge=None, diameter=None, moment_inertia=None, orientation=None)

Define a unit cell.

Parameters:
  • N (int) – Number of particles in the unit cell.
  • a1 (list) – Lattice vector (3-vector).
  • a2 (list) – Lattice vector (3-vector).
  • a3 (list) – Lattice vector (3-vector). Set to [0,0,1] in 2D lattices.
  • dimensions (int) – Dimensionality of the lattice (2 or 3).
  • position (list) – List of particle positions.
  • type_name (list) – List of particle type names.
  • mass (list) – List of particle masses.
  • charge (list) – List of particle charges.
  • diameter (list) – List of particle diameters.
  • moment_inertia (list) – List of particle moments of inertia.
  • orientation (list) – List of particle orientations.

A unit cell is a box definition (a1, a2, a3, dimensions), and particle properties for N particles. You do not need to specify all particle properties. Any property omitted will be initialized to defaults (see hoomd.data.make_snapshot()). hoomd.init.create_lattice initializes the system with many copies of a unit cell.

unitcell is a completely generic unit cell representation. See other classes in the hoomd.lattice module for convenience wrappers for common lattices.

Example:

uc = hoomd.lattice.unitcell(N = 2,
                            a1 = [1,0,0],
                            a2 = [0.2,1.2,0],
                            a3 = [-0.2,0, 1.0],
                            dimensions = 3,
                            position = [[0,0,0], [0.5, 0.5, 0.5]],
                            type_name = ['A', 'B'],
                            mass = [1.0, 2.0],
                            charge = [0.0, 0.0],
                            diameter = [1.0, 1.3],
                            moment_inertia = [[1.0, 1.0, 1.0], [0.0, 0.0, 0.0]],
                            orientation = [[0.707, 0, 0, 0.707], [1.0, 0, 0, 0]]);

Note

a1, a2, a3 must define a right handed coordinate system.

get_snapshot()

Get a snapshot.

Returns:A snapshot representing the lattice.

Attention

HOOMD-blue requires upper-triangular box matrices. The general box matrix (a1, a2, a3) set for this unitcell and the particle positions and orientations will be rotated from provided values into upper triangular form.

get_type_list()

Get a list of the unique type names in the unit cell.

Returns:A list of the unique type names present in the unit cell.
get_typeid_mapping()

Get a type name to typeid mapping.

Returns:A dict that maps type names to integer type ids.