Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove features deprecated in v3.x. #1496

Merged
merged 7 commits into from Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 0 additions & 21 deletions hoomd/device.py
Expand Up @@ -20,8 +20,6 @@
`hoomd.Simulation`
"""

import warnings

import contextlib
import hoomd
from hoomd import _hoomd
Expand Down Expand Up @@ -256,25 +254,6 @@ def __init__(self,
if num_cpu_threads is not None:
self.num_cpu_threads = num_cpu_threads

@property
def memory_traceback(self):
"""bool: Whether GPU memory tracebacks should be enabled.

Memory tracebacks are useful for developers when debugging GPU code.

.. deprecated:: v3.4.0
`memory_traceback` has no effect.
"""
warnings.warn("memory_traceback will be removed in hoomd 4.0.",
FutureWarning)
return self._cpp_exec_conf.memoryTracingEnabled()

@memory_traceback.setter
def memory_traceback(self, mem_traceback):
warnings.warn("memory_traceback will be removed in hoomd 4.0.",
FutureWarning)
self._cpp_exec_conf.setMemoryTracing(mem_traceback)

@property
def gpu_error_checking(self):
"""bool: Whether to check for GPU error conditions after every call.
Expand Down
59 changes: 12 additions & 47 deletions hoomd/md/constrain.py
Expand Up @@ -19,8 +19,6 @@
instance solves for its constraints independently.
"""

import warnings

from hoomd.md import _md
from hoomd.data.parameterdicts import ParameterDict, TypeParameterDict
from hoomd.data.typeparam import TypeParameter
Expand All @@ -29,22 +27,6 @@
import hoomd


class _DeprecateKey:

def __init__(self, name, version="4.0", alt=""):
self.name = name
self.version = version
self.alt = alt

def __call__(self, value):
msg = f"The {self.name} key is deprecated and will be removed in hoomd "
msg += f"{self.version}."
if self.alt:
msg += f" Use {self.alt} in version {self.version} instead."
warnings.warn(msg, FutureWarning)
return value

tommy-waltmann marked this conversation as resolved.
Show resolved Hide resolved

class Constraint(Force):
"""Constraint force base class.

Expand Down Expand Up @@ -144,8 +126,8 @@ class Rigid(Constraint):
.. rubric:: Constituent particles

Select one or more particle types in the simulation to use as the central
particles. For each rigid body particle type, ou specify the constituent
particle position and orientations in body coordinates (see `body`). Then,
particles. For each rigid body particle type, set the constituent particle
type, position and orientations in body coordinates (see `body`). Then,
`Rigid` takes control of the constituent particles and sets their position
and orientation in the simulation box relative to the position and
orientation of the central particle:
Expand All @@ -164,11 +146,10 @@ class Rigid(Constraint):
of the central particle of that rigid body. `Rigid` also sets the
constituent particle image consistent with the image of the central particle
and the location of the constituent particle wrapped back into the
box. `Rigid` does not modify the constituent particle type ids, charge,
or diameter.
box.

Warning:
`Rigid` **overwrites** the constituent particle positions and
`Rigid` **overwrites** the constituent particle type ids, positions and
orientations. To change the position and orientation of a body, set the
desired position and orientation of the central particle and call
`run(0) <Simulation.run>` to trigger `Rigid` to update the particles.
Expand Down Expand Up @@ -241,9 +222,9 @@ class Rigid(Constraint):
`hoomd.write.GSD` and initialize the new `Simulation <hoomd.Simulation>`
using `create_state_from_gsd <Simulation.create_state_from_gsd>`. GSD stores
all the particle data fields needed to reconstruct the state of the system,
including the body, angular momentum, and orientation of the body. You must
specify the same local body space environment to `body` as you did in the
earlier simulation - GSD does not store this information.
including the body, angular momentum, and orientation of the body. Set the
same local body space environment to `body` as in the earlier simulation -
GSD does not store this information.

Example::

Expand All @@ -252,15 +233,11 @@ class Rigid(Constraint):
"constituent_types": ['A_const', 'A_const'],
"positions": [(0,0,1),(0,0,-1)],
"orientations": [(1.0, 0.0, 0.0, 0.0), (1.0, 0.0, 0.0, 0.0)],
"charges": [0.0, 0.0],
"diameters": [1.0, 1.0]
}
rigid.body['B'] = {
"constituent_types": ['B_const', 'B_const'],
"positions": [(0,0,.5),(0,0,-.5)],
"orientations": [(1.0, 0.0, 0.0, 0.0), (1.0, 0.0, 0.0, 0.0)],
"charges": [0.0, 1.0],
"diameters": [1.5, 1.0]
}

# Can set rigid body definition to be None explicitly.
Expand Down Expand Up @@ -288,23 +265,11 @@ class Rigid(Constraint):
`float`]]): List of orientations (as quaternions) of constituent
particles.

- ``charges`` (`list` [`float`]): List of charges of constituent
particles.

.. deprecated:: v3.7.0
``charges`` will be removed in v4.

- ``diameters`` (`list` [`float`]): List of diameters of constituent
particles.

.. deprecated:: v3.7.0
``diameters`` will be removed in v4.

Of these, `Rigid` uses ``positions`` and ``orientation`` to set the
constituent particle positions and orientations every time step.
`create_bodies` uses ``constituent_types``, ``charges``, and
``diameters`` to populate those particle properties when creating
constituent particles.
Of these, `Rigid` uses ``constituent_types``, ``positions`` and
``orientations`` to set the constituent particle type ids, positions and
orientations every time step. `create_bodies` uses all these parameters
to populate those particle properties when creating constituent
particles.

Type: `TypeParameter` [``particle_type``, `dict`]
"""
Expand Down
18 changes: 1 addition & 17 deletions hoomd/md/dihedral.py
Expand Up @@ -41,8 +41,6 @@
parallel compact state ( \|_\| ).
"""

import warnings

from hoomd.md import _md
from hoomd.md.force import Force
from hoomd.data.parameterdicts import TypeParameterDict
Expand Down Expand Up @@ -106,7 +104,7 @@ class Periodic(Dihedral):

Examples::

harmonic = dihedral.Harmonic()
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)
"""
Expand All @@ -120,20 +118,6 @@ def __init__(self):
self._add_typeparam(params)


class Harmonic(Periodic):
"""Periodic dihedral force.

.. deprecated:: v3.7.0
Use `Periodic`.
"""

def __init__(self):
warnings.warn(
"Harmonic is deprecated and will be removed in hoomd 4.0. Use "
"Periodic instead.", FutureWarning)
super().__init__()


class Table(Dihedral):
"""Tabulated dihedral force.

Expand Down
35 changes: 4 additions & 31 deletions hoomd/md/pair/aniso.py
Expand Up @@ -19,8 +19,6 @@
parameter.
"""

import warnings

from collections.abc import Sequence
import json
from numbers import Number
Expand Down Expand Up @@ -66,9 +64,6 @@ class Dipole(AnisotropicPair):
Args:
nlist (hoomd.md.nlist.NeighborList): Neighbor list
default_r_cut (float): Default cutoff radius :math:`[\mathrm{length}]`.
mode (str): energy shifting/smoothing mode (ignored).

.. deprecated:: v3.1.0

`Dipole` computes the (screened) interaction between pairs of
particles with dipoles and electrostatic charges:
Expand All @@ -95,10 +90,6 @@ class Dipole(AnisotropicPair):
All units are documented electronic dipole moments. However, `Dipole`
can also be used to represent magnetic dipoles.

Note:
`Dipole` accepts the ``mode`` parameter, but computes the same energy
regardless of the value of ``mode`` (starting with v3.0.0).

Example::

nl = nlist.Cell()
Expand Down Expand Up @@ -132,22 +123,15 @@ class Dipole(AnisotropicPair):
"""
_cpp_class_name = "AnisoPotentialPairDipole"

def __init__(self, nlist, default_r_cut=None, mode='none'):
super().__init__(nlist, default_r_cut, mode)
def __init__(self, nlist, default_r_cut=None):
super().__init__(nlist, default_r_cut, 'none')
params = TypeParameter(
'params', 'particle_types',
TypeParameterDict(A=float, kappa=float, len_keys=2))
mu = TypeParameter('mu', 'particle_types',
TypeParameterDict((float, float, float), len_keys=1))
self._extend_typeparam((params, mu))

def _setattr_param(self, attr, value):
if attr == "mode":
warnings.warn(
"'mode' key is deprectated and will be removed in hoomd 4.0.",
FutureWarning)
super()._setattr_param(attr, value)


class GayBerne(AnisotropicPair):
r"""Gay-Berne anisotropic pair force.
Expand Down Expand Up @@ -253,10 +237,6 @@ class ALJ(AnisotropicPair):
Args:
nlist (hoomd.md.nlist.NeighborList): Neighbor list
default_r_cut (float): Default cutoff radius :math:`[length]`.
mode (`str`, optional): the energy shifting mode, defaults to "none".
Computes the same energy regardless of value passed.

.. deprecated:: v3.1.0

`ALJ` computes the Lennard-Jones force between anisotropic particles as
described in `Ramasubramani, V. et al. 2020`_, using the formula:
Expand Down Expand Up @@ -533,8 +513,8 @@ class ALJ(AnisotropicPair):
# parameter in C++, so use an instance level attribute instead that is
# created in _attach based on the dimension of the associated simulation.

def __init__(self, nlist, default_r_cut=None, mode='none'):
super().__init__(nlist, default_r_cut, mode)
def __init__(self, nlist, default_r_cut=None):
super().__init__(nlist, default_r_cut, 'none')
params = TypeParameter(
'params', 'particle_types',
TypeParameterDict(epsilon=float,
Expand Down Expand Up @@ -583,10 +563,3 @@ def type_shapes(self):
log shape for visualization and storage through the GSD file type.
"""
return self._return_type_shapes()

def _setattr_param(self, attr, value):
if attr == "mode":
warnings.warn(
"'mode' key is deprectated and will be removed in hoomd 4.0.",
FutureWarning)
super()._setattr_param(attr, value)
2 changes: 1 addition & 1 deletion hoomd/md/pytest/test_aniso_pair.py
Expand Up @@ -438,7 +438,7 @@ def test_aniso_force_computes(make_two_particle_simulation,

"""
pot = aniso_forces_and_energies.pair_potential(
nlist=md.nlist.Cell(buffer=0.4), default_r_cut=2.5, mode='none')
nlist=md.nlist.Cell(buffer=0.4), default_r_cut=2.5)
for param, value in aniso_forces_and_energies.pair_potential_params.items():
getattr(pot, param)[('A', 'A')] = value
sim = make_two_particle_simulation(types=['A'], d=0.75, force=pot)
Expand Down
32 changes: 5 additions & 27 deletions hoomd/md/pytest/test_dihedral.py
Expand Up @@ -34,27 +34,6 @@
1.9411,
0.0852,
),
(
hoomd.md.dihedral.Harmonic,
dict(),
dict(k=3.0, d=-1, n=2, phi0=numpy.pi / 2),
0,
3,
),
(
hoomd.md.dihedral.Harmonic,
dict(),
dict(k=10.0, d=1, n=1, phi0=numpy.pi / 4),
5.0,
5.0,
),
(
hoomd.md.dihedral.Harmonic,
dict(),
dict(k=5.0, d=1, n=3, phi0=numpy.pi / 6),
1.9411,
0.0852,
),
(
hoomd.md.dihedral.OPLS,
dict(),
Expand Down Expand Up @@ -219,12 +198,11 @@ def test_kernel_parameters(dihedral_snapshot_factory, simulation_factory,


# Test Logging
@pytest.mark.parametrize(
'cls, expected_namespace, expected_loggables',
zip((md.dihedral.Dihedral, md.dihedral.Harmonic, md.dihedral.Periodic,
md.dihedral.Table, md.dihedral.OPLS),
itertools.repeat(('md', 'dihedral')),
itertools.repeat(expected_loggable_params)))
@pytest.mark.parametrize('cls, expected_namespace, expected_loggables',
zip((md.dihedral.Dihedral, md.dihedral.Periodic,
md.dihedral.Table, md.dihedral.OPLS),
itertools.repeat(('md', 'dihedral')),
itertools.repeat(expected_loggable_params)))
def test_logging(cls, expected_namespace, expected_loggables):
logging_check(cls, expected_namespace, expected_loggables)

Expand Down
11 changes: 2 additions & 9 deletions hoomd/pytest/test_device.py
Expand Up @@ -51,21 +51,14 @@ def test_common_properties(device, tmp_path):
num_cpu_threads=10)


def _assert_gpu_properties(dev, mem_traceback, gpu_error_checking):
"""Assert properties specific to GPU objects are correct."""
assert dev.memory_traceback == mem_traceback
assert dev.gpu_error_checking == gpu_error_checking


@pytest.mark.gpu
def test_gpu_specific_properties(device):
# assert the defaults are right
_assert_gpu_properties(device, False, True)
assert device.gpu_error_checking

# make sure we can set the properties
device.memory_traceback = True
device.gpu_error_checking = False
_assert_gpu_properties(device, True, False)
assert not device.gpu_error_checking

# make sure we can give a list of GPU ids to the constructor
hoomd.device.GPU(gpu_ids=[0])
Expand Down
2 changes: 0 additions & 2 deletions sphinx-doc/module-md-dihedral.rst
Expand Up @@ -12,7 +12,6 @@ md.dihedral
:nosignatures:

Dihedral
Harmonic
Periodic
OPLS
Table
Expand All @@ -23,7 +22,6 @@ md.dihedral
:synopsis: Dihedral potentials.
:show-inheritance:
:members: Dihedral,
Harmonic,
Periodic,
OPLS,
Table