Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
pip list

- name: Run mypy
if: ${{ matrix.openeye == true }}
if: ${{ matrix.openeye == 'foo' }}
run: mypy -p "openff.toolkit"

- name: Run unit tests
Expand Down
1 change: 0 additions & 1 deletion devtools/conda-envs/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies:
- openmm >=7.6
- openff-forcefields >=2025
- openff-amber-ff-ports >=0.0.3
- openff-units
- openff-utilities >=0.1.5
- openff-interchange-base >=0.5
- openff-nagl-base >=0.5.3
Expand Down
1 change: 0 additions & 1 deletion devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dependencies:
- python-constraint
- openmm >=7.6
- openff-forcefields >=2023.05.1
- openff-units
- openff-amber-ff-ports
- openff-utilities >=0.1.5
- openff-interchange-base >=0.5
Expand Down
1 change: 0 additions & 1 deletion devtools/conda-envs/test_env_no_openeye.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dependencies:
- python-constraint
- openmm >=7.6
- openff-forcefields >=2023.05.1
- openff-units
- openff-amber-ff-ports
- openff-utilities >=0.1.5
- openff-interchange-base >=0.5
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"https://docs.openforcefield.org/projects/fragmenter/en/stable/",
None,
),
"openff.units": (
"openff.toolkit.utils.units": (
"https://docs.openforcefield.org/projects/units/en/stable/",
None,
),
Expand Down
1 change: 0 additions & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- rdkit
- ambertools
- packaging
- openff-units
- openff-utilities
- cachetools
- python-constraint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"\n",
"import numpy as np\n",
"from IPython.display import display\n",
"from openff.units import unit\n",
"from openff.toolkit.utils.units import unit\n",
"from rdkit import Chem\n",
"from rdkit.Chem import Draw\n",
"\n",
Expand Down
8 changes: 3 additions & 5 deletions openff/toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
if TYPE_CHECKING:
# These types are imported lazily at runtime, but we need to tell type
# checkers what they are
from openff.units import Quantity, unit

from openff.toolkit.topology import Molecule, Topology
from openff.toolkit.typing.engines.smirnoff import (
ForceField,
Expand All @@ -26,6 +24,7 @@
RDKitToolkitWrapper,
ToolkitRegistry,
)
from openff.toolkit.utils.units import Quantity, unit

__version__ = version("openff.toolkit")

Expand Down Expand Up @@ -58,8 +57,8 @@
"OpenEyeToolkitWrapper": "openff.toolkit.utils.toolkits",
"RDKitToolkitWrapper": "openff.toolkit.utils.toolkits",
"ToolkitRegistry": "openff.toolkit.utils.toolkits",
"Quantity": "openff.units",
"unit": "openff.units",
"Quantity": "openff.toolkit.utils.units",
"unit": "openff.toolkit.utils.units",
# Remember to add new lazy imports to __all__ and the if TYPE_CHECKING imports
}

Expand All @@ -68,7 +67,6 @@
"topology": "openff.toolkit.topology",
"typing": "openff.toolkit.typing",
"utils": "openff.toolkit.utils",
"unit": "openff.units.units",
}


Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/mocking.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy

from openff.toolkit import Quantity, unit
from openff.toolkit.topology import Molecule
from openff.toolkit.typing.engines.smirnoff import VirtualSiteHandler
from openff.toolkit.utils.units import Quantity, unit


class VirtualSiteMocking:
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/test_energies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import numpy as np
import openmm
import pytest
from openff.units.openmm import to_openmm
from openmm import unit as openmm_unit

from openff.toolkit._tests.utils import get_data_file_path, requires_rdkit
from openff.toolkit.topology import Molecule, Topology
from openff.toolkit.typing.engines.smirnoff import ForceField
from openff.toolkit.utils.units import to_openmm


@requires_rdkit
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/test_forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import openmm
import pytest
from numpy.testing import assert_almost_equal
from openff.units.openmm import from_openmm, to_openmm
from openmm import NonbondedForce, Platform, XmlSerializer, app
from openmm import unit as openmm_unit
from pydantic import ValidationError
Expand Down Expand Up @@ -61,6 +60,7 @@
SMIRNOFFSpecUnimplementedError,
SMIRNOFFVersionError,
)
from openff.toolkit.utils.units import from_openmm, to_openmm

XML_FF_GENERICS = """<?xml version='1.0' encoding='ASCII'?>
<SMIRNOFF version="0.3" aromaticity_model="OEAroModel_MDL">
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import numpy as np
import pytest
from openff.units.elements import MASSES, SYMBOLS

from openff.toolkit import unit
from openff.toolkit._tests.create_molecules import (
Expand Down Expand Up @@ -57,6 +56,7 @@
_networkx_graph_to_hill_formula,
)
from openff.toolkit.utils import get_data_file_path
from openff.toolkit.utils._elements import MASSES, SYMBOLS
from openff.toolkit.utils.exceptions import (
AtomMappingWarning,
BadMoleculeAssumptionError,
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/test_toolkit_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pytest
from numpy.testing import assert_allclose

from openff.toolkit import Quantity, unit
from openff.toolkit._tests import create_molecules
from openff.toolkit._tests.utils import requires_openeye, requires_rdkit
from openff.toolkit.topology.molecule import Molecule
Expand All @@ -21,6 +20,7 @@
SMILESParseError,
UndefinedStereochemistryError,
)
from openff.toolkit.utils.units import Quantity, unit

ETHANOL = create_molecules.create_ethanol()
ETHANOL.name = "ethanol"
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/test_toolkits.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from numpy.testing import assert_almost_equal
from packaging.version import Version

from openff.toolkit import Quantity, unit
from openff.toolkit._tests.create_molecules import (
create_acetaldehyde,
create_acetate,
Expand Down Expand Up @@ -56,6 +55,7 @@
ToolkitRegistry,
ToolkitWrapper,
)
from openff.toolkit.utils.units import Quantity, unit

_rng = np.random.default_rng()

Expand Down
6 changes: 3 additions & 3 deletions openff/toolkit/_tests/test_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import openmm.app
import openmm.unit
import pytest
from openff.units.openmm import from_openmm
from openff.utilities import skip_if_missing

from openff.toolkit import Molecule, Quantity, Topology, unit
Expand Down Expand Up @@ -76,6 +75,7 @@
VirtualSitesUnsupportedError,
WrongShapeError,
)
from openff.toolkit.utils.units import from_openmm


def assert_tuple_of_atoms_equal(atom_tuples1, atom_tuples2, transformed_dict_cls=ValenceDict):
Expand Down Expand Up @@ -946,8 +946,8 @@ def test_from_mdtraj(self):
def test_to_file_units_check(self):
"""
Checks that writing a PDB file with different coordinate representations results in the same output.
- Angstrom "openff units" (default behavior if using Molecule.conformers[0])
- nanometer "openff units"
- Angstrom "openff.toolkit.utils.units" (default behavior if using Molecule.conformers[0])
- nanometer "openff.toolkit.utils.units"
- unitless NumPy array
- converted OpenMM quantity
"""
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import numpy as np
import openmm
import pytest
from openff.units.openmm import to_openmm
from openmm import unit as openmm_unit

from openff.toolkit import unit
Expand All @@ -27,6 +26,7 @@
RDKitToolkitWrapper,
get_data_file_path,
)
from openff.toolkit.utils.units import to_openmm

requires_ambertools = pytest.mark.skipif(
not AmberToolsToolkitWrapper.is_available(),
Expand Down
3 changes: 3 additions & 0 deletions openff/toolkit/data/units/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Unit definitions

The unit definitions are currently sourced from the NIST 2018 [CODATA](https://physics.nist.gov/cuu/Constants/), but may be updated in future versions as new CODATA updates are made.
44 changes: 44 additions & 0 deletions openff/toolkit/data/units/constants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Based on the default Pint constants definition file (0.16.1)
# https://github.com/hgrecco/pint/tree/master/pint
#
# Based on the International System of Units
# Language: english
# Source: https://physics.nist.gov/cuu/Constants/
# https://physics.nist.gov/PhysRefData/XrayTrans/Html/search.html
# :copyright: 2013,2019 by Pint Authors, see https://github.com/hgrecco/pint/blob/0.16.1/AUTHORS for more details.

#### MATHEMATICAL CONSTANTS ####
# As computed by Maxima with fpprec:50

pi = 3.1415926535897932384626433832795028841971693993751 = π # pi

#### DEFINED EXACT CONSTANTS ####
# Recommended CODATA-2018 values

speed_of_light = 299792458 m/s = c = c_0 # since 1983
planck_constant = 6.62607015e-34 J s = h # since May 2019
elementary_charge = 1.602176634e-19 C = e # since May 2019
avogadro_number = 6.02214076e23 # since May 2019
boltzmann_constant = 1.380649e-23 J K^-1 = k = k_B # since May 2019
standard_atmosphere = 1.01325e5 Pa = atm = atmosphere # since 1954

#### DERIVED EXACT CONSTANTS ####
# Floating-point conversion may introduce inaccuracies

zeta = c / (cm/s) = ζ
dirac_constant = h / (2 * π) = ħ = hbar = atomic_unit_of_action = a_u_action
avogadro_constant = avogadro_number * mol^-1 = N_A
molar_gas_constant = k * N_A = R

#### MEASURED CONSTANTS ####
# Recommended CODATA-2018 values

rydberg_constant = 1.0973731568160e7 * m^-1 = R_∞ = R_inf # (21)
atomic_mass_constant = 1.66053906660e-27 kg = m_u # (50)
electron_mass = 9.1093837015e-31 kg = m_e = atomic_unit_of_mass = a_u_mass # (28)

#### DERIVED CONSTANTS ####

fine_structure_constant = (2 * h * R_inf / (m_e * c)) ** 0.5 = α = alpha
vacuum_permeability = 2 * α * h / (e ** 2 * c) = µ_0 = mu_0 = mu0 = magnetic_constant
vacuum_permittivity = e ** 2 / (2 * α * h * c) = ε_0 = epsilon_0 = eps_0 = eps0 = electric_constant
Loading
Loading