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

Add support for hoomd.md.improper.Periodic in to_hoomd_forcefield #807

Merged
merged 21 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9be2fce
add dict entry for periodic impropers
chrisjonesBSU Mar 7, 2024
cd2ce51
add sign factor (d) to Periodic Improper
chrisjonesBSU Mar 8, 2024
e08f9d5
Change key name to match GAFF, hard code d = 1
chrisjonesBSU Mar 8, 2024
0cd676d
remove d param from template
chrisjonesBSU Mar 8, 2024
8965e68
Remove d from expression
chrisjonesBSU Mar 8, 2024
75aba93
change d from int to float
chrisjonesBSU Mar 8, 2024
d865f79
Merge branch 'main' of github.com:mosdef-hub/gmso into hoomd-dihedrals
chrisjonesBSU Mar 28, 2024
8678d12
Merge branch 'hoomd-dihedrals' of github.com:chrisjonesBSU/gmso into …
chrisjonesBSU Mar 28, 2024
200ddc4
Merge branch 'main' of github.com:mosdef-hub/gmso into hoomd-dihedrals
chrisjonesBSU Apr 3, 2024
d987099
update python version, remove ethanol from unit test
chrisjonesBSU Apr 3, 2024
8533746
if wild card in member classes, use member types instead
chrisjonesBSU Apr 5, 2024
3f17683
use wildcard check for all forcefield writers
chrisjonesBSU Apr 5, 2024
fea5640
fix typo in env files
chrisjonesBSU Apr 5, 2024
a42748e
Fix variable name.
chrisjonesBSU Apr 5, 2024
4497a3c
use .get() for d parameter
chrisjonesBSU Apr 15, 2024
81212ec
Merge branch 'main' of github.com:mosdef-hub/gmso into hoomd-dihedrals
chrisjonesBSU Apr 29, 2024
8564317
fix conflicts
chrisjonesBSU May 6, 2024
c8cc00d
Merge branch 'main' into hoomd-dihedrals
daico007 May 6, 2024
9268768
Merge branch 'main' into hoomd-dihedrals
chrisjonesBSU May 7, 2024
44bc437
Merge branch 'main' into hoomd-dihedrals
daico007 May 16, 2024
62f1e9f
change box size and seed for packing in test
chrisjonesBSU May 16, 2024
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
4 changes: 2 additions & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: gmso-dev
channels:
- conda-forge
dependencies:
- python>=3.8
- python<3.12
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
- boltons
- numpy
- sympy
Expand All @@ -12,7 +12,7 @@ dependencies:
- pydantic>=2
- networkx
- pytest
- mbuild>=0.11.0
- mbuild>=0.17.0
- openbabel>=3.0.0
- foyer>=0.11.3
- forcefield-utilities>=0.2.1
Expand Down
44 changes: 37 additions & 7 deletions gmso/external/convert_hoomd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"mass": u.g / u.mol, # aka amu
}

hoomd_version = hoomd.version.version.split(".")


def to_gsd_snapshot(
top,
Expand Down Expand Up @@ -678,13 +680,15 @@ def _validate_compatibility(top):
harmonic_bond_potential = templates["HarmonicBondPotential"]
harmonic_angle_potential = templates["HarmonicAnglePotential"]
periodic_torsion_potential = templates["PeriodicTorsionPotential"]
harmonic_torsion_potential = templates["HarmonicTorsionPotential"]
opls_torsion_potential = templates["OPLSTorsionPotential"]
rb_torsion_potential = templates["RyckaertBellemansTorsionPotential"]
accepted_potentials = (
lennard_jones_potential,
harmonic_bond_potential,
harmonic_angle_potential,
periodic_torsion_potential,
harmonic_torsion_potential,
opls_torsion_potential,
rb_torsion_potential,
)
Expand Down Expand Up @@ -1120,7 +1124,6 @@ def _parse_dihedral_forces(
},
}

hoomd_version = hoomd.version.version.split(".")
if int(hoomd_version[0]) >= 4 or (
int(hoomd_version[0]) == 3 and int(hoomd_version[1]) >= 8
):
Expand Down Expand Up @@ -1307,12 +1310,24 @@ def _parse_improper_forces(
base_units,
)

itype_group_map = {
"HarmonicImproperPotenial": {
"container": hoomd.md.improper.Harmonic,
"parser": _parse_harmonic_improper,
},
}
if int(hoomd_version[0]) >= 4 and int(hoomd_version[1]) >= 5:
itype_group_map = {
"HarmonicImproperPotential": {
"container": hoomd.md.improper.Harmonic,
"parser": _parse_harmonic_improper,
},
"PeriodicTorsionPotential": {
"container": hoomd.md.improper.Periodic,
"parser": _parse_periodic_improper,
},
}
else:
itype_group_map = {
"HarmonicImproperPotential": {
"container": hoomd.md.improper.Harmonic,
"parser": _parse_harmonic_improper,
},
}

improper_forces = list()
for group in groups:
Expand All @@ -1338,6 +1353,21 @@ def _parse_harmonic_improper(
return container


def _parse_periodic_improper(
daico007 marked this conversation as resolved.
Show resolved Hide resolved
container,
itypes,
):
for itype in itypes:
member_types = sort_by_classes(itype)
container.params["-".join(member_types)] = {
"k": itype.parameters["k"],
"chi0": itype.parameters["phi_eq"],
"n": itype.parameters["n"],
"d": 1.0,
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
}
return container


def _validate_base_units(base_units, top, auto_scale, potential_types=None):
"""Validate the provided base units, infer units (based on top's positions and masses) if none is provided."""
if base_units and auto_scale:
Expand Down
5 changes: 3 additions & 2 deletions gmso/tests/test_hoomd.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,9 @@ def test_gaff_sim(self, gaff_forcefield):
"energy": u.kJ / u.mol,
}
ethanol = mb.load("CCO", smiles=True)
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
ethanol.box = mb.Box([5, 5, 5])
top = ethanol.to_gmso()
benzene = mb.load("c1ccccc1", smiles=True)
benzene.box = mb.Box([5, 5, 5])
top = benzene.to_gmso()
parameterized_top = apply(
top, gaff_forcefield, identify_connections=True
)
Expand Down
Loading