Skip to content

Commit

Permalink
Merge pull request #959 from openforcefield/revert-nagl-pin
Browse files Browse the repository at this point in the history
Use better NAGL constraints
  • Loading branch information
mattwthompson authored Apr 9, 2024
2 parents e054343 + 18e22e6 commit ee242d5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion devtools/conda-envs/beta_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- openff-toolkit >=0.15.2
- openff-models
- openff-nagl ~=0.3.7
- openff-nagl-models
- openff-nagl-models =0.1
# Optional features
- jax
- unyt
Expand Down
6 changes: 3 additions & 3 deletions devtools/conda-envs/examples_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ dependencies:
- pydantic =2
- openmm
# OpenFF stack
- openff-toolkit ~=0.15.2
- openff-toolkit =0.15.2
- openff-models
- openff-nagl ==0.3.6
- openff-nagl ~=0.3.7
- openff-nagl-models =0.1
- dgl =1
# Optional features
Expand All @@ -25,7 +25,7 @@ dependencies:
- pdbfixer
- nglview
- openeye-toolkits >=2023.2
- pytest =8
- pytest =8.0
- pytest-xdist
- nbval
- openmmforcefields >=0.11.2
Expand Down
13 changes: 13 additions & 0 deletions openff/interchange/_tests/unit_tests/smirnoff/test_nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from packaging.version import Version

from openff.interchange import Interchange
from openff.interchange.exceptions import NonIntegralMoleculeChargeError
from openff.interchange.smirnoff._nonbonded import (
SMIRNOFFElectrostaticsCollection,
_downconvert_vdw_handler,
Expand Down Expand Up @@ -229,6 +230,18 @@ def compare_charges(
compare_charges(reordered, get_charges_from_interchange(reordered))


def test_nonintegral_molecule_charge_error(sage, water):
funky_charges = Quantity([0, 0, -5.5], "elementary_charge")

water.partial_charges = funky_charges

with pytest.raises(
NonIntegralMoleculeChargeError,
match="net charge of -5.5 compared to a total formal charge of 0.0",
):
sage.create_interchange(water.to_topology(), charge_from_molecules=[water])


class TestSMIRNOFFChargeIncrements:
@pytest.fixture
def hydrogen_cyanide_charge_increments(self):
Expand Down
3 changes: 2 additions & 1 deletion openff/interchange/smirnoff/_nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,8 @@ def store_matches(
else:
raise NonIntegralMoleculeChargeError(
f"Molecule {molecule.to_smiles(explicit_hydrogens=False)} has "
f"a net charge of {charge_sum}",
f"a net charge of {charge_sum} compared to a total formal charge of "
f"{formal_sum}.",
)

molecule.partial_charges = Quantity(
Expand Down

0 comments on commit ee242d5

Please sign in to comment.