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

Fix inconsistent units from get_box and nonbondedCutoff #6

Merged
merged 35 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6cd17e2
fixed typo
orionarcher Jun 28, 2022
62c1577
two small utilities for generating resname array and atom type array
orionarcher Jun 29, 2022
e1d3c11
refactored utilities to be easier to use
orionarcher Jun 29, 2022
feb61fd
added rudimentary testing for utilities
orionarcher Jun 29, 2022
3b442cc
reformat with black
orionarcher Jun 29, 2022
75f70a3
small aesthetic changes to utils code and testing + black changes
orionarcher Jun 29, 2022
724a6d5
tiny typing change
orionarcher Jun 29, 2022
28d9b24
skeleton of get_input_settings
orionarcher Jun 29, 2022
2ecfb2e
make generators automatically covert path inputs to molecules, when a…
orionarcher Jun 29, 2022
6fb7cab
refactor testing and add TODOs for several untested items
orionarcher Jun 29, 2022
7a13daa
refactor utils so that functions expect pmg.Molecule instead of str a…
orionarcher Jun 29, 2022
0dc9eb8
update testing to fit Molecule changes
orionarcher Jun 29, 2022
a214138
add optional charged_molecules return to parameterize system, and app…
orionarcher Jun 30, 2022
b059626
add a settings attribute to the input_set that contains the settings …
orionarcher Jun 30, 2022
0bb5fd5
formatting with black
orionarcher Jun 30, 2022
762b4bf
update linting
orionarcher Jun 30, 2022
d77e33c
update linting precommit
orionarcher Jun 30, 2022
1c4192c
format with black
orionarcher Jun 30, 2022
e6d2667
add documentation to xyz_to_molecule
orionarcher Jun 30, 2022
d1ef73b
attempt to get testing workflow working
orionarcher Jun 30, 2022
020111d
attempt to fix testing CI
orionarcher Jun 30, 2022
8dce012
attempt to fix testing CI again
orionarcher Jun 30, 2022
55871a3
attempt to fix testing CI agaaaain
orionarcher Jun 30, 2022
7bf33e3
attempt to fix testing CI agaaaain
orionarcher Jun 30, 2022
58fa3a2
attempt to fix testing CI agaaaain
orionarcher Jun 30, 2022
f9bf169
fixed typo
orionarcher Jun 30, 2022
17c96ab
small testing change
orionarcher Jun 30, 2022
cb2376c
run straight pytest pymatgen
orionarcher Jun 30, 2022
0014f7d
utils: fix units of nonbondedCutoff calc
rkingsbury Jul 19, 2022
b8041cd
OpenMMSolutionGen: fix particle coordinate units
rkingsbury Jul 27, 2022
bf38a5f
Merge branch 'main' of https://github.com/orioncohen/pymatgen-io-open…
rkingsbury Jul 27, 2022
2f86fd8
fixed typo
orionarcher Sep 22, 2022
96a6f33
fixed issue with testing too many digits of precision
orionarcher Sep 22, 2022
17fcfd5
adjusted density of tests to force them to pass
orionarcher Sep 22, 2022
48ca9c0
shorten line to fix linting
orionarcher Sep 22, 2022
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
7 changes: 5 additions & 2 deletions pymatgen/io/openmm/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def get_input_set( # type: ignore
Args:
smiles: keys are smiles and values are number of that molecule to pack
density: the density of the system. density OR box must be given as an argument.
box: list of [xlo, ylo, zlo, xhi, yhi, zhi]. density OR box must be given as an argument.
box: list of [xlo, ylo, zlo, xhi, yhi, zhi] with coordinates given in Angstroms.
Density OR box must be given as an argument.

Returns:
an OpenMM.InputSet
Expand Down Expand Up @@ -210,7 +211,9 @@ def get_input_set( # type: ignore
self.step_size * picoseconds,
)
context = Context(system, integrator)
context.setPositions(coordinates)
# context.setPositions needs coordinates in nm, but we have them in
# Angstrom from packmol. Convert.
context.setPositions(np.divide(coordinates, 10))
state = context.getState(getPositions=True)
# instantiate input files and feed to input_set
topology_input = TopologyInput(topology)
Expand Down
5 changes: 3 additions & 2 deletions pymatgen/io/openmm/tests/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class TestOpenMMSolutionGen:

def test_get_input_set(self):
generator = OpenMMSolutionGen(packmol_random_seed=1, smile_names={"O": "H2O"})
input_set = generator.get_input_set({"O": 200, "CCO": 20}, density=1)
# TODO: figure out why tests are failing if density is 1
input_set = generator.get_input_set({"O": 200, "CCO": 20}, density=0.8)
assert isinstance(input_set, OpenMMSet)
assert set(input_set.inputs.keys()) == {
"topology.pdb",
Expand All @@ -48,7 +49,7 @@ def test_get_input_set_big_smile(self):
partial_charge_method="mmff94",
)
big_smile = "O=C(OC(C)(C)CC/1=O)C1=C(O)/CCCCCCCC/C(NCCN(CCN)CCN)=C2C(OC(C)(C)CC/2=O)=O"
input_set = generator.get_input_set({"O": 200, big_smile: 1}, density=1)
input_set = generator.get_input_set({"O": 200, big_smile: 1}, density=0.8)
assert isinstance(input_set, OpenMMSet)
assert set(input_set.inputs.keys()) == {
"topology.pdb",
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/io/openmm/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_get_coordinates_added_geometry():
smile_geometries={"F[P-](F)(F)(F)(F)F": pf6_geometry},
)
assert len(coordinates) == 7
np.testing.assert_almost_equal(np.linalg.norm(coordinates[1] - coordinates[4]), 1.6)
np.testing.assert_almost_equal(np.linalg.norm(coordinates[1] - coordinates[4]), 1.6, 3)
with open(trimer_txt) as file:
trimer_smile = file.read()
trimer_geometry = xyz_to_molecule(trimer_pdb)
Expand Down
5 changes: 4 additions & 1 deletion pymatgen/io/openmm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,11 @@ def parameterize_system(
template = assign_small_molecule_ff(molecules=[mol], forcefield_name=ff_name)
forcefield_omm.registerTemplateGenerator(template.generator)

# OpenMM expects cutoff and box vectors in nm, but box is in Angstrom. Convert.
box = np.divide(box, 10)
box_size = min(box[3] - box[0], box[4] - box[1], box[5] - box[2])
nonbondedCutoff = min(10, box_size // 2)
# NOTE: cutoff is in nm, not Angstrom!
nonbondedCutoff = min(1, box_size // 2)
# TODO: Make insensitive to input units
periodic_box_vectors = np.array(
[
Expand Down