Skip to content
Open
20 changes: 12 additions & 8 deletions hoomd/md/angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ class Harmonic(Angle):

U(\theta) = \frac{1}{2} k \left( \theta - \theta_0 \right)^2

Examples::
.. rubric:: Example:

harmonic = angle.Harmonic()
harmonic.params["A-A-A"] = dict(k=3.0, t0=0.7851)
harmonic.params["A-B-A"] = dict(k=100.0, t0=1.0)
.. code-block:: python

harmonic = angle.Harmonic()
harmonic.params["A-A-A"] = dict(k=3.0, t0=0.7851)
harmonic.params["A-B-A"] = dict(k=100.0, t0=1.0)

{inherited}

Expand Down Expand Up @@ -132,11 +134,13 @@ class CosineSquared(Angle):

`CosineSquared` is used in the gromos96 and MARTINI force fields.

Examples::
.. rubric:: Example:

.. code-block:: python

cosinesq = angle.CosineSquared()
cosinesq.params["A-A-A"] = dict(k=3.0, t0=0.7851)
cosinesq.params["A-B-A"] = dict(k=100.0, t0=1.0)
cosinesq = angle.CosineSquared()
cosinesq.params["A-A-A"] = dict(k=3.0, t0=0.7851)
cosinesq.params["A-B-A"] = dict(k=100.0, t0=1.0)

{inherited}

Expand Down
34 changes: 20 additions & 14 deletions hoomd/md/bond.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ class Harmonic(Bond):

U(r) = \frac{1}{2} k \left( r - r_0 \right)^2

Examples::
.. rubric:: Example:

harmonic = bond.Harmonic()
harmonic.params["A-A"] = dict(k=3.0, r0=2.38)
harmonic.params["A-B"] = dict(k=10.0, r0=1.0)
.. code-block:: python

harmonic = bond.Harmonic()
harmonic.params["A-A"] = dict(k=3.0, r0=2.38)
harmonic.params["A-B"] = dict(k=10.0, r0=1.0)

{inherited}

Expand Down Expand Up @@ -143,13 +145,15 @@ class FENEWCA(Bond):
bond, :math:`\varepsilon` is the repulsive interaction energy, and
:math:`\sigma` is the repulsive interaction width.

Examples::
.. rubric:: Example:

.. code-block:: python

fenewca = bond.FENEWCA()
fenewca.params['A-A'] = dict(k=3.0, r0=2.38, epsilon=1.0, sigma=1.0,
delta=0.0)
fenewca.params['A-B'] = dict(k=10.0, r0=1.0, epsilon=0.8, sigma=1.2,
delta=0.0)
fenewca = bond.FENEWCA()
fenewca.params['A-A'] = dict(k=3.0, r0=2.38, epsilon=1.0, sigma=1.0,
delta=0.0)
fenewca.params['A-B'] = dict(k=10.0, r0=1.0, epsilon=0.8, sigma=1.2,
delta=0.0)

{inherited}

Expand Down Expand Up @@ -342,11 +346,13 @@ class Tether(Bond):
.. math::
l_{min} < l_{c1} < l_{c0} < l_{max}

Examples::
.. rubric:: Example:

.. code-block:: python

bond_potential = bond.Tether()
bond_potential.params['A-A'] = dict(k_b=10.0, l_min=0.9, l_c1=1.2,
l_c0=1.8, l_max=2.1)
bond_potential = bond.Tether()
bond_potential.params['A-A'] = dict(k_b=10.0, l_min=0.9, l_c1=1.2,
l_c0=1.8, l_max=2.1)

{inherited}

Expand Down
18 changes: 11 additions & 7 deletions hoomd/md/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ class ThermodynamicQuantities(Compute):
rigid body centers - ignoring constituent particles to avoid double
counting.

Examples::
.. rubric:: Example:

f = filter.Type("A")
compute.ThermodynamicQuantities(filter=f)
.. code-block:: python

f = filter.Type("A")
compute.ThermodynamicQuantities(filter=f)

{inherited}

Expand Down Expand Up @@ -342,11 +344,13 @@ class HarmonicAveragedThermodynamicQuantities(Compute):
by molecular simulation". Phys. Rev. E 92, 043303
doi:10.1103/PhysRevE.92.043303

Examples::
.. rubric:: Example:

hma = hoomd.compute.HarmonicAveragedThermodynamicQuantities(
filter=hoomd.filter.Type("A"), kT=1.0
)
.. code-block:: python

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

{inherited}

Expand Down
18 changes: 11 additions & 7 deletions hoomd/md/dihedral.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ class Periodic(Dihedral):
U(\phi) = \frac{1}{2}k \left( 1 + d \cos\left(n \phi - \phi_0 \right)
\right)

Examples::
.. rubric:: Example:

harmonic = dihedral.Periodic()
harmonic.params["A-A-A-A"] = dict(k=3.0, d=-1, n=3, phi0=0)
harmonic.params["A-B-C-D"] = dict(k=100.0, d=1, n=4, phi0=math.pi / 2)
.. code-block:: python

harmonic = dihedral.Periodic()
harmonic.params["A-A-A-A"] = dict(k=3.0, d=-1, n=3, phi0=0)
harmonic.params["A-B-C-D"] = dict(k=100.0, d=1, n=4, phi0=math.pi / 2)

{inherited}

Expand Down Expand Up @@ -226,10 +228,12 @@ class OPLS(Dihedral):

:math:`k_n` are the force coefficients in the Fourier series.

Examples::
.. rubric:: Example:

.. code-block:: python

opls = dihedral.OPLS()
opls.params["A-A-A-A"] = dict(k1=1.0, k2=1.0, k3=1.0, k4=1.0)
opls = dihedral.OPLS()
opls.params["A-A-A-A"] = dict(k1=1.0, k2=1.0, k3=1.0, k4=1.0)

{inherited}

Expand Down
81 changes: 45 additions & 36 deletions hoomd/md/force.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,14 @@ def cpu_local_force_arrays(self):
The local arrays are read only for built-in forces. Use `Custom` to
implement custom forces.

Examples::
.. rubric:: Example:

with self.cpu_local_force_arrays as arrays:
arrays.force[:] = ...
arrays.potential_energy[:] = ...
arrays.torque[:] = ...
arrays.virial[:] = ...
.. code-block:: python
with self.cpu_local_force_arrays as arrays:
arrays.force[:] = ...
arrays.potential_energy[:] = ...
arrays.torque[:] = ...
arrays.virial[:] = ...
"""
if self._in_context_manager:
raise RuntimeError(
Expand All @@ -275,13 +276,15 @@ def gpu_local_force_arrays(self):
The local arrays are read only for built-in forces. Use `Custom` to
implement custom forces.

Examples::
.. rubric:: Example:

.. code-block:: python

with self.gpu_local_force_arrays as arrays:
arrays.force[:] = ...
arrays.potential_energy[:] = ...
arrays.torque[:] = ...
arrays.virial[:] = ...
with self.gpu_local_force_arrays as arrays:
arrays.force[:] = ...
arrays.potential_energy[:] = ...
arrays.torque[:] = ...
arrays.virial[:] = ...

Note:
GPU local force data is not available if the chosen device for the
Expand Down Expand Up @@ -427,17 +430,19 @@ class Active(Force):

`hoomd.md.update.ActiveRotationalDiffusion`

Examples::
.. rubric:: Example:

all = hoomd.filter.All()
active = hoomd.md.force.Active(
filter=hoomd.filter.All()
)
active.active_force['A','B'] = (1,0,0)
active.active_torque['A','B'] = (0,0,0)
rotational_diffusion_updater = active.create_diffusion_updater(
trigger=10)
sim.operations += rotational_diffusion_updater
.. code-block:: python

all = hoomd.filter.All()
active = hoomd.md.force.Active(
filter=hoomd.filter.All()
)
active.active_force['A','B'] = (1,0,0)
active.active_torque['A','B'] = (0,0,0)
rotational_diffusion_updater = active.create_diffusion_updater(
trigger=10)
sim.operations += rotational_diffusion_updater

Note:
The energy and virial associated with the active force are 0.
Expand Down Expand Up @@ -559,17 +564,19 @@ class ActiveOnManifold(Active):

`hoomd.md.update.ActiveRotationalDiffusion`

Examples::
.. rubric:: Example:

all = filter.All()
sphere = hoomd.md.manifold.Sphere(r=10)
active = hoomd.md.force.ActiveOnManifold(
filter=hoomd.filter.All(),
rotation_diff=0.01,
manifold_constraint=sphere,
)
active.active_force["A", "B"] = (1, 0, 0)
active.active_torque["A", "B"] = (0, 0, 0)
.. code-block:: python

all = filter.All()
sphere = hoomd.md.manifold.Sphere(r=10)
active = hoomd.md.force.ActiveOnManifold(
filter=hoomd.filter.All(),
rotation_diff=0.01,
manifold_constraint=sphere,
)
active.active_force["A", "B"] = (1, 0, 0)
active.active_torque["A", "B"] = (0, 0, 0)

{inherited}

Expand Down Expand Up @@ -648,11 +655,13 @@ class Constant(Force):
particles selected by the filter. `Constant` sets the force and torque
to ``(0,0,0)`` for particles not selected by the filter.

Examples::
.. rubric:: Example:

.. code-block:: python

constant = hoomd.md.force.Constant(filter=hoomd.filter.All())
constant.constant_force["A"] = (1, 0, 0)
constant.constant_torque["A"] = (0, 0, 0)
constant = hoomd.md.force.Constant(filter=hoomd.filter.All())
constant.constant_force["A"] = (1, 0, 0)
constant.constant_torque["A"] = (0, 0, 0)

Note:
The energy and virial associated with the constant force are 0.
Expand Down
26 changes: 17 additions & 9 deletions hoomd/md/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,23 @@ class Integrator(_DynamicIntegrator):

- `hoomd.md.constrain`

Examples::

nlist = hoomd.md.nlist.Cell()
lj = hoomd.md.pair.LJ(nlist=nlist)
lj.params.default = dict(epsilon=1.0, sigma=1.0)
lj.r_cut[('A', 'A')] = 2**(1/6)
nve = hoomd.md.methods.NVE(filter=hoomd.filter.All())
integrator = hoomd.md.Integrator(dt=0.001, methods=[nve], forces=[lj])
sim.operations.integrator = integrator
.. rubric:: Example:

.. code-block:: python

cell = hoomd.md.nlist.Cell(buffer=0.4)
lj = hoomd.md.pair.LJ(nlist=cell)
lj.params[('A', 'A')] = dict(epsilon=1.0, sigma=1.0)
lj.r_cut[('A', 'A')] = 2.5
nve = hoomd.md.methods.ConstantVolume(
filter=hoomd.filter.All(),
thermostat=None,
)
integrator = hoomd.md.Integrator(dt=0.005,
methods=[nve],
forces=[lj],
)


{inherited}

Expand Down
Loading