md.external.field

Overview

Field

Base class external field force.

Electric

Electric field force.

Periodic

One-dimension periodic force.

Details

External field forces.

class hoomd.md.external.field.Electric

Electric field force.

Electric computes forces, and virials, and energies on all particles in the in the simulation state with consistent with:

\[U_i = - q_i \vec{E} \cdot \vec{r}_i\]

where \(q_i\) is the particle charge and \(\vec{E}\) is the field vector. The field vector \(\vec{E}\) must be set per unique particle type.

E

The electric field vector \(\vec{E}\) as a tuple \((E_x, E_y, E_z)\) \([\mathrm{energy} \cdot \mathrm{charge}^{-1} \cdot \mathrm{length^{-1}}]\).

Type: TypeParameter [particle_type, tuple [float, float, float]]

Example:

# Apply an electric field in the x-direction
e_field = external.field.Electric()
e_field.E['A'] = (1, 0, 0)
class hoomd.md.external.field.Field

Base class external field force.

External potentials represent forces which are applied to all particles in the simulation by an external agent.

Warning

This class should not be instantiated by users. The class can be used for isinstance or issubclass checks.

class hoomd.md.external.field.Periodic

One-dimension periodic force.

Periodic computes forces and energies that induce a periodic modulation in the particle concentration. The modulation is one-dimensional and extends along the lattice vector \(\mathbf{a}_i\) of the simulation cell. This force can, for example, be used to induce an ordered phase in a block-copolymer melt.

The force is computed commensurate with the potential energy:

\[U_i(\vec{r_j}) = A \tanh\left[\frac{1}{2 \pi p w} \cos\left( p \vec{b}_i\cdot\vec{r_j}\right)\right]\]

Periodic results in no virial stress due functional dependence on box scaled coordinates.

params

The Periodic external potential parameters. The dictionary has the following keys:

  • A (float, required) - Ordering parameter \(A\) \([\mathrm{energy}]\).

  • i (int, required) - \(\vec{b}_i\), \(i=0, 1, 2\), is the simulation box’s reciprocal lattice vector in the \(i\) direction \([\mathrm{dimensionless}]\).

  • w (float, required) - The interface width \(w\) relative to the distance \(2\pi/|\mathbf{b_i}|\) between planes in the \(i\)-direction \([\mathrm{dimensionless}]\).

  • p (int, required) - The periodicity \(p\) of the modulation \([\mathrm{dimensionless}]\).

Type: TypeParameter [particle_type, dict]

Example:

# Apply a periodic composition modulation along the first lattice vector
periodic = external.field.Periodic()
periodic.params['A'] = dict(A=1.0, i=0, w=0.02, p=3)
periodic.params['B'] = dict(A=-1.0, i=0, w=0.02, p=3)