# md.update¶

Overview

 md.update.constraint_ellipsoid Constrain particles to the surface of a ellipsoid. md.update.enforce2d Enforces 2D simulation. md.update.rescale_temp Rescales particle velocities. md.update.zero_momentum Zeroes system momentum. md.update.mueller_plathe_flow Updater class for a shear flow according to an algorithm published by Mueller Plathe.:

Details

Update particle properties.

When an updater is specified, it acts on the particle system each time step to change it in some way. See the documentation of specific updaters to find out what they do.

class hoomd.md.update.constraint_ellipsoid(group, r=None, rx=None, ry=None, rz=None, P=0, 0, 0)

Constrain particles to the surface of a ellipsoid.

Parameters
• group (hoomd.group) – Group for which the update will be set

• P (tuple) – (x,y,z) tuple indicating the position of the center of the ellipsoid (in distance units).

• rx (float) – radius of an ellipsoid in the X direction (in distance units).

• ry (float) – radius of an ellipsoid in the Y direction (in distance units).

• rz (float) – radius of an ellipsoid in the Z direction (in distance units).

• r (float) – radius of a sphere (in distance units), such that r=rx=ry=rz.

constraint_ellipsoid specifies that all particles are constrained to the surface of an ellipsoid. Each time step particles are projected onto the surface of the ellipsoid. Method from: http://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf

Attention

For the algorithm to work, we must have $$rx >= rz,~ry >= rz,~rz > 0$$.

Note

This method does not properly conserve virial coefficients.

Note

random thermal forces from the integrator are applied in 3D not 2D, therefore they aren’t fully accurate. Suggested use is therefore only for T=0.

Examples:

update.constraint_ellipsoid(P=(-1,5,0), r=9)
update.constraint_ellipsoid(rx=7, ry=5, rz=3)

disable()

Disables the updater.

Examples:

updater.disable()


Executing the disable command will remove the updater from the system. Any hoomd.run() command executed after disabling an updater will not use that updater during the simulation. A disabled updater can be re-enabled with enable()

enable()

Enables the updater.

Examples:

updater.enable()

restore_state()

Restore the state information from the file used to initialize the simulations

set_period(period)

Changes the updater period.

Parameters

period (int) – New period to set.

Examples:

updater.set_period(100);
updater.set_period(1);


While the simulation is running, the action of each updater is executed every period time steps. Changing the period does not change the phase set when the analyzer was first created.

class hoomd.md.update.enforce2d

Enforces 2D simulation.

Every time step, particle velocities and accelerations are modified so that their z components are 0: forcing 2D simulations when other calculations may cause particles to drift out of the plane. Using enforce2d is only allowed when the system is specified as having only 2 dimensions.

Examples:

update.enforce2d()

disable()

Disables the updater.

Examples:

updater.disable()


Executing the disable command will remove the updater from the system. Any hoomd.run() command executed after disabling an updater will not use that updater during the simulation. A disabled updater can be re-enabled with enable()

enable()

Enables the updater.

Examples:

updater.enable()

restore_state()

Restore the state information from the file used to initialize the simulations

set_period(period)

Changes the updater period.

Parameters

period (int) – New period to set.

Examples:

updater.set_period(100);
updater.set_period(1);


While the simulation is running, the action of each updater is executed every period time steps. Changing the period does not change the phase set when the analyzer was first created.

class hoomd.md.update.mueller_plathe_flow(group, flow_target, slab_direction, flow_direction, n_slabs, max_slab=- 1, min_slab=- 1)

Updater class for a shear flow according to an algorithm published by Mueller Plathe.:

“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 searched for the max. velocity component in flow direction, the “min” is searched for the min. velocity component. Afterward, both velocity components are swapped.

This introduces a momentum flow, which drives the flow. The strength of this flow, can be controlled by the flow_target variant, which defines the integrated target momentum flow. The searching and swapping is repeated until the target is reached. Depending on the target sign, the “max” and “min” slap might be swapped.

Parameters
• group (hoomd.group) – Group for which the update will be set

• flow_target (hoomd.variant) – Integrated target flow. The unit is the in the natural units of the simulation: [flow_target] = [timesteps] x $$\mathcal{M}$$ x $$\frac{\mathcal{D}}{\tau}$$. The unit of [timesteps] is your discretization dt x $$\mathcal{\tau}$$.

• slab_direction (X, Y, or Z) – Direction perpendicular to the slabs..

• flow_direction (X, Y, or Z) – Direction of the flow..

• n_slabs (int) – Number of slabs. You want as many as possible for small disturbed volume, where the unphysical swapping is done. But each slab has to contain a sufficient number of particle.

• 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 has to be always applied every timestep.

• This updater works currently only with orthorhombic boxes.

New in version v2.1.

Examples:

#const integrated flow with 0.1 slope for max 1e8 timesteps
const_flow = hoomd.variant.linear_interp( [(0,0),(1e8,0.1*1e8)] )
#velocity gradient in z direction and shear flow in x direction.
update.mueller_plathe_flow(all,const_flow,md.update.mueller_plathe_flow.Z,md.update.mueller_plathe_flow.X,100)

X = None

Direction Enum X for this class

Y = None

Direction Enum Y for this class

Z = None

Direction Enum Z for this class

disable()

Disables the updater.

Examples:

updater.disable()


Executing the disable command will remove the updater from the system. Any hoomd.run() command executed after disabling an updater will not use that updater during the simulation. A disabled updater can be re-enabled with enable()

enable()

Enables the updater.

Examples:

updater.enable()

get_flow_epsilon()

Get the tolerance between target flow and actual achieved flow.

get_max_slab()

Get the slab id of max velocity search.

get_min_slab()

Get the slab id of min velocity search.

get_n_slabs()

Get the number of slabs.

get_summed_exchanged_momentum()

Returned the summed up exchanged velocity of the full simulation.

has_max_slab()

Returns, whether this MPI instance is part of the max slab.

has_min_slab()

Returns, whether this MPI instance is part of the min slab.

restore_state()

Restore the state information from the file used to initialize the simulations

set_flow_epsilon(epsilon)

Set the tolerance between target flow and actual achieved flow.

Args: epsilon (float): New tolerance for the deviation of actual and achieved flow.

set_period(period)

Changes the updater period.

Parameters

period (int) – New period to set.

Examples:

updater.set_period(100);
updater.set_period(1);


While the simulation is running, the action of each updater is executed every period time steps. Changing the period does not change the phase set when the analyzer was first created.

class hoomd.md.update.rescale_temp(kT, period=1, phase=0)

Rescales particle velocities.

Parameters
• kT (hoomd.variant or float) – Temperature set point (in energy units)

• period (int) – Velocities will be rescaled every period time steps

• phase (int) – When -1, start on the current time step. When >= 0, execute on steps where (step + phase) % period == 0.

Every period time steps, particle velocities and angular momenta are rescaled by equal factors so that they are consistent with a given temperature in the equipartition theorem

\begin{align}\begin{aligned}\langle 1/2 m v^2 \rangle = k_B T\\\langle 1/2 I \omega^2 \rangle = k_B T\end{aligned}\end{align}

Attention

rescale_temp does not run on the GPU, and will significantly slow down simulations.

Examples:

update.rescale_temp(kT=1.2)
rescaler = update.rescale_temp(kT=0.5)
update.rescale_temp(period=100, kT=1.03)
update.rescale_temp(period=100, kT=hoomd.variant.linear_interp([(0, 4.0), (1e6, 1.0)]))

disable()

Disables the updater.

Examples:

updater.disable()


Executing the disable command will remove the updater from the system. Any hoomd.run() command executed after disabling an updater will not use that updater during the simulation. A disabled updater can be re-enabled with enable()

enable()

Enables the updater.

Examples:

updater.enable()

restore_state()

Restore the state information from the file used to initialize the simulations

set_params(kT=None)

Change rescale_temp parameters.

Parameters

kT (hoomd.variant or float) – New temperature set point (in energy units)

Examples:

rescaler.set_params(kT=2.0)

set_period(period)

Changes the updater period.

Parameters

period (int) – New period to set.

Examples:

updater.set_period(100);
updater.set_period(1);


While the simulation is running, the action of each updater is executed every period time steps. Changing the period does not change the phase set when the analyzer was first created.

class hoomd.md.update.zero_momentum(period=1, phase=0)

Zeroes system momentum.

Parameters
• period (int) – Momentum will be zeroed every period time steps

• phase (int) – When -1, start on the current time step. When >= 0, execute on steps where (step + phase) % period == 0.

Every period time steps, particle velocities are modified such that the total linear momentum of the system is set to zero.

Examples:

update.zero_momentum()
zeroer= update.zero_momentum(period=10)

disable()

Disables the updater.

Examples:

updater.disable()


Executing the disable command will remove the updater from the system. Any hoomd.run() command executed after disabling an updater will not use that updater during the simulation. A disabled updater can be re-enabled with enable()

enable()

Enables the updater.

Examples:

updater.enable()

restore_state()

Restore the state information from the file used to initialize the simulations

set_period(period)

Changes the updater period.

Parameters

period (int) – New period to set.

Examples:

updater.set_period(100);
updater.set_period(1);


While the simulation is running, the action of each updater is executed every period time steps. Changing the period does not change the phase set when the analyzer was first created.