md.compute

Overview

HarmonicAveragedThermodynamicQuantities

Compute harmonic averaged thermodynamic properties of particles.

ThermodynamicQuantities

Compute thermodynamic properties of a group of particles.

Details

Compute system properties.

class hoomd.md.compute.HarmonicAveragedThermodynamicQuantities(filter, kT, harmonic_pressure=0)

Compute harmonic averaged thermodynamic properties of particles.

Parameters
  • filter (hoomd.filter) – Particle filter to compute thermodynamic properties for.

  • kT (float) – Temperature of the system \([\mathrm{energy}]\).

  • harmonic_pressure (float) – Harmonic contribution to the pressure \([\mathrm{pressure}]\). If ommitted, the HMA pressure can still be computed, but will be similar in precision to the conventional pressure.

HarmonicAveragedThermodynamicQuantities acts on a given group of particles and calculates harmonically mapped average (HMA) properties of those particles when requested. HMA computes properties more precisely (with less variance) for atomic crystals in NVT simulations. The presence of diffusion (vacancy hopping, etc.) will prevent HMA from providing improvement. HMA tracks displacements from the lattice positions, which are saved either during first call to Simulation.run or when the compute is first added to the simulation, whichever occurs last.

Note

HarmonicAveragedThermodynamicQuantities is an implementation of the methods section of Sabry G. Moustafa, Andrew J. Schultz, and David A. Kofke. (2015). “Very fast averaging of thermal properties of crystals by molecular simulation”. Phys. Rev. E 92, 043303 doi:10.1103/PhysRevE.92.043303

Examples:

hma = hoomd.compute.HarmonicAveragedThermodynamicQuantities(
    filter=hoomd.filter.Type('A'), kT=1.0)
filter

Subset of particles compute thermodynamic properties for.

Type

hoomd.filter.ParticleFilter

kT

Temperature of the system \([\mathrm{energy}]\).

Type

hoomd.variant.Variant

harmonic_pressure

Harmonic contribution to the pressure \([\mathrm{pressure}]\).

Type

float

property potential_energy

Average potential energy \([\mathrm{energy}]\).

(Loggable: category=”scalar”)

property pressure

Average pressure \([\mathrm{pressure}]\).

(Loggable: category=”scalar”)

class hoomd.md.compute.ThermodynamicQuantities(filter)

Compute thermodynamic properties of a group of particles.

Parameters

filter (hoomd.filter) – Particle filter to compute thermodynamic properties for.

ThermodynamicQuantities acts on a given group of particles and calculates thermodynamic properties of those particles when requested. All specified ThermodynamicQuantities objects can be added to a logger for logging during a simulation, see hoomd.logging.Logger for more details.

Examples:

f = filter.Type('A')
compute.ThermodynamicQuantities(filter=f)
property degrees_of_freedom

\(N_{\mathrm{dof}}\).

Number of degrees of freedom given to the group by its integration method.

Calculated as:

\[N_{\mathrm{dof}} = N_{\mathrm{dof, trans}} + N_{\mathrm{dof, rot}}\]

(Loggable: category=”scalar”)

property kinetic_energy

\(K\), total kinetic energy of particles in the group \([\mathrm{energy}]\).

\[K = K_{\mathrm{rot}} + K_{\mathrm{trans}}\]

(Loggable: category=”scalar”)

property kinetic_temperature

\(kT_k\), instantaneous thermal energy of the group \([\mathrm{energy}]\).

Calculated as:

\[kT_k = 2 \cdot \frac{K}{N_{\mathrm{dof}}}\]

(Loggable: category=”scalar”)

property num_particles

\(N\), number of particles in the group.

(Loggable: category=”scalar”)

property potential_energy

\(U\).

Potential energy that the group contributes to the entire system \([\mathrm{energy}]\).

The potential energy is calculated as a sum of per-particle energy contributions:

\[U = \sum_{i \in \mathrm{filter}} U_i,\]

where \(U_i\) is defined as:

\[U_i = U_{\mathrm{pair}, i} + U_{\mathrm{bond}, i} + U_{\mathrm{angle}, i} + U_{\mathrm{dihedral}, i} + U_{\mathrm{improper}, i} + U_{\mathrm{external}, i} + U_{\mathrm{other}, i}\]

and each term on the RHS is calculated as:

\[ \begin{align}\begin{aligned}U_{\mathrm{pair}, i} &= \frac{1}{2} \sum_j V_{\mathrm{pair}, ij}\\U_{\mathrm{bond}, i} &= \frac{1}{2} \sum_{(j, k) \in \mathrm{bonds}} V_{\mathrm{bond}, jk}\\U_{\mathrm{angle}, i} &= \frac{1}{3} \sum_{(j, k, l) \in \mathrm{angles}} V_{\mathrm{angle}, jkl}\\U_{\mathrm{dihedral}, i} &= \frac{1}{4} \sum_{(j, k, l, m) \in \mathrm{dihedrals}} V_{\mathrm{dihedral}, jklm}\\U_{\mathrm{improper}, i} &= \frac{1}{4} \sum_{(j, k, l, m) \in \mathrm{impropers}} V_{\mathrm{improper}, jklm}\end{aligned}\end{align} \]

In each summation above, the indices go over all particles and we only use terms where one of the summation indices (\(j\), \(k\), \(l\), or \(m\)) is equal to \(i\). External and other potentials are summed similar to the other terms using per-particle contributions.

(Loggable: category=”scalar”)

property pressure

\(P\), instantaneous pressure of the group \([\mathrm{pressure}]\).

Calculated as:

\[P = \frac{ 2 \cdot K_{\mathrm{trans}} + W }{D \cdot V},\]

where \(D\) is the dimensionality of the system, \(V\) is the total volume of the simulation box (or area in 2D), and \(W\) is calculated as:

\[W = \frac{1}{2} \sum_{i \in \mathrm{filter}} \sum_{j} \vec{F}_{ij} \cdot \vec{r_{ij}} + \sum_{k} \vec{F}_{k} \cdot \vec{r_{k}},\]

where \(i\) and \(j\) are particle tags, \(\vec{F}_{ij}\) are pairwise forces between particles and \(\vec{F}_k\) are forces due to explicit constraints, implicit rigid body constraints, external walls, and fields.

(Loggable: category=”scalar”)

property pressure_tensor

Instantaneous pressure tensor of the group \([\mathrm{pressure}]\).

(\(P_{xx}\), \(P_{xy}\), \(P_{xz}\), \(P_{yy}\), \(P_{yz}\), \(P_{zz}\)). calculated as:

\[P_{ij} = \left[\sum_{k \in \mathrm{filter}} m_k \vec{v}_{k,i} \cdot \vec{v}_{k,j} + \sum_{k \in \mathrm{filter}} \sum_{l} \frac{1}{2} \left(\vec{r}_{kl,i} \cdot \vec{F}_{kl,j} + \vec{r}_{kl,j} \cdot \vec{F}_{kl,i} \right) \right]/V\]

where \(V\) is the total simulation box volume (or area in 2D).

(Loggable: category=”sequence”)

property rotational_degrees_of_freedom

\(N_{\mathrm{dof, rot}}\).

Number of rotational degrees of freedom given to the group by its integration method.

(Loggable: category=”scalar”)

property rotational_kinetic_energy

\(K_{\mathrm{rot}}\).

Rotational kinetic energy of all particles in the group \([\mathrm{energy}]\).

Calculated as:

\[K_{\mathrm{rot}} = \frac{1}{2} \sum_{i \in \mathrm{filter}} \frac{L_{x,i}^2}{I_{x,i}} + \frac{L_{y,i}^2}{I_{y,i}} + \frac{L_{z,i}^2}{I_{z,i}},\]

where \(I\) is the moment of inertia and \(L\) is the angular momentum in the (diagonal) reference frame of the particle.

(Loggable: category=”scalar”)

property translational_degrees_of_freedom

\(N_{\mathrm{dof, trans}}\).

Number of translational degrees of freedom given to the group by its integration method.

When using a single integration method that is momentum conserving and operates on all particles, \(N_{\mathrm{dof, trans}} = DN - D - N_{constraints}\), where \(D\) is the dimensionality of the system.

Note

The removal of \(D\) degrees of freedom accounts for the fixed center of mass in using periodic boundary conditions. When the filter in ThermodynamicQuantities selects a subset of all particles, the removed degrees of freedom are spread proportionately.

(Loggable: category=”scalar”)

property translational_kinetic_energy

\(K_{\mathrm{trans}}\).

Translational kinetic energy of all particles in the group \([\mathrm{energy}]\).

\[K_{\mathrm{trans}} = \frac{1}{2}\sum_{i \in \mathrm{filter}} m_i|\vec{v}_i|^2\]

(Loggable: category=”scalar”)

property volume

\(V\), volume of the simulation box (area in 2D) \([\mathrm{length}^{d}]\).

Where \(d\) is the dimensionality of the system.

(Loggable: category=”scalar”)