md.update#

Overview

ActiveRotationalDiffusion

Updater to introduce rotational diffusion with an active force.

ReversePerturbationFlow

Reverse Perturbation method to establish shear flow.

ZeroMomentum

Zeroes system momentum.

Details

MD updaters.

class hoomd.md.update.ActiveRotationalDiffusion(trigger, active_force, rotational_diffusion)#

Bases: Updater

Updater to introduce rotational diffusion with an active force.

Parameters:

ActiveRotationalDiffusion works directly with hoomd.md.force.Active or hoomd.md.force.ActiveOnManifold to apply rotational diffusion to the particle quaternions \(\mathbf{q}_i\) in simulations with active forces. The persistence length of an active particle’s path is \(v_0 / D_r\).

In 2D, the diffusion follows \(\delta \theta / \delta t = \Gamma \sqrt{2 D_r / \delta t}\), where \(D_r\) is the rotational diffusion constant and the \(\Gamma\) unit-variance random variable.

In 3D, \(\hat{p}_i\) is a unit vector in 3D space, and the diffusion follows \(\delta \hat{p}_i / \delta t = \Gamma \sqrt{2 D_r / \delta t} (\hat{p}_i (\cos \theta - 1) + \hat{p}_r \sin \theta)\), where \(\hat{p}_r\) is an uncorrelated random unit vector.

When used with hoomd.md.force.ActiveOnManifold, rotational diffusion is performed in the tangent plane of the manifold.

trigger#

Select the timesteps to update rotational diffusion.

Type:

hoomd.trigger.Trigger

active_force#

The active force associated with the updater. This is not settable after construction.

Type:

hoomd.md.force.Active

rotational_diffusion#

The rotational diffusion as a function of time.

Type:

hoomd.variant.Variant

class hoomd.md.update.ReversePerturbationFlow(filter, flow_target, slab_direction, flow_direction, n_slabs, max_slab=-1, min_slab=-1)#

Bases: Updater

Reverse Perturbation method to establish shear flow.

“Florian Mueller-Plathe. Reversing the perturbation in nonequilibrium molecular dynamics: An easy way to calculate the shear viscosity of fluids. Phys. Rev. E, 59:4894-4898, May 1999.”

The simulation box is divided in a number of slabs. Two distinct slabs of those are chosen. The “max” slab searches for the maximum velocity component in flow direction while the “min” slab searches for the minimum velocity component. Afterward, both velocity components are swapped.

This introduces a momentum flow, which drives the flow. The strength of this flow is set through the flow_target argument, which defines a target value for the time-integrated momentum flux. The searching and swapping is repeated until the target is reached. Depending on the target sign, the “max” and “min” slab might be swapped.

Parameters:
  • filter (hoomd.filter.filter_like) – Subset of particles on which to apply this updater.

  • flow_target (hoomd.variant.variant_like) – Target value of the time-integrated momentum flux. \([\delta t \cdot \mathrm{mass} \cdot \mathrm{length} \cdot \mathrm{time}^{-1}]\) - where \(\delta t\) is the integrator step size.

  • slab_direction (str) – Direction perpendicular to the slabs. Can be “x”, “y”, or “z”

  • flow_direction (str) – Direction of the flow. Can be “x”, “y”, or “z”

  • n_slabs (int) – Number of slabs used to divide the simulation box along the shear gradient. Using too few slabs will lead to a larger volume being disturbed by the momentum exchange, while using too many slabs may mean that there are not enough particles to exchange the target momentum.

  • max_slab (int) – Id < n_slabs where the max velocity component is search for. If set < 0 the value is set to its default n_slabs/2.

  • min_slab (int) – Id < n_slabs where the min velocity component is search for. If set < 0 the value is set to its default 0.

Attention

  • This updater uses hoomd.trigger.Periodic(1) as a trigger, meaning it is applied every timestep.

  • This updater works currently only with orthorhombic boxes.

Note

The attributes of this updater are immutable once the updater is attached to a simulation.

Examples:

# const integrated flow with 0.1 slope for max 1e8 timesteps
ramp = hoomd.variant.Ramp(0.0, 0.1e8, 0, int(1e8))
# velocity gradient in z direction and shear flow in x direction.
mpf = hoomd.md.update.ReversePerturbationFlow(filter=hoomd.filter.All(),
                                              flow_target=ramp,
                                              slab_direction="Z",
                                              flow_direction="X",
                                              n_slabs=20)
filter#

Subset of particles on which to apply this updater.

Type:

hoomd.filter.filter_like

flow_target#

Target value of the time-integrated momentum flux.

Type:

hoomd.variant.Variant

slab_direction#

Direction perpendicular to the slabs.

Type:

str

flow_direction#

Direction of the flow.

Type:

str

n_slabs#

Number of slabs.

Type:

int

max_slab#

Id < n_slabs where the max velocity component is searched for.

Type:

int

min_slab#

Id < n_slabs where the min velocity component is searched for.

Type:

int

property summed_exchanged_momentum#

Returns the summed up exchanged velocity of the full simulation.

(Loggable: category=”scalar”)

class hoomd.md.update.ZeroMomentum(trigger)#

Bases: Updater

Zeroes system momentum.

Parameters:

trigger (hoomd.trigger.trigger_like) – Select the timesteps to zero momentum.

ZeroMomentum computes the center of mass linear momentum of the system:

\[\vec{p} = \frac{1}{N_\mathrm{free,central}} \sum_{i \in \mathrm{free,central}} m_i \vec{v}_i\]

and removes it:

\[\vec{v}_i' = \vec{v}_i - \frac{\vec{p}}{m_i}\]

where the index \(i\) includes only free and central particles (and excludes consitutent particles of rigid bodies).

Note

ZeroMomentum executes on the CPU even when using a GPU device.

Examples:

zero_momentum = hoomd.md.update.ZeroMomentum(
    hoomd.trigger.Periodic(100))