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

Write out rigid water for GROMACS top file #771

Merged
merged 35 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
82f3c05
support to write out settles section for gromacs
daico007 Oct 9, 2023
982a04d
Merge branch 'main' of https://github.com/mosdef-hub/gmso into writin…
daico007 Oct 16, 2023
904750f
add isrigid to molecule
daico007 Oct 16, 2023
a4a429b
Merge branch 'main' into writing_out_settles
daico007 Oct 30, 2023
7197b27
add default val for moleculeType isrigid
daico007 Nov 14, 2023
19f7b71
revert change to moleculetype
daico007 Nov 14, 2023
ff2e8c0
Merge branch 'writing_out_settles' of https://github.com/daico007/gms…
daico007 Nov 14, 2023
9738d3a
Merge branch 'main' into writing_out_settles
daico007 Feb 20, 2024
287e81b
Merge branch 'main' into writing_out_settles
daico007 Mar 17, 2024
70268bd
Merge branch 'main' into writing_out_settles
daico007 May 7, 2024
b0bb7c6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 7, 2024
a4721ce
update molecule and residue class, fix unit tests
daico007 May 13, 2024
023ebd6
Merge branch 'main' into writing_out_settles
daico007 May 16, 2024
ce04232
use site.name if no element info is found
daico007 May 16, 2024
47a2ec2
Merge branch 'writing_out_settles' of https://github.com/daico007/gms…
daico007 May 16, 2024
d667404
add patch for getting non-element site
daico007 May 16, 2024
427bf51
let element.py handle non-element issue
daico007 May 20, 2024
e2b838f
Merge branch 'main' into writing_out_settles
daico007 Jun 3, 2024
c271be1
Merge branch 'main' into writing_out_settles
daico007 Jun 3, 2024
720ece1
Merge branch 'main' into writing_out_settles
daico007 Jun 17, 2024
e45ffdf
Merge branch 'main' of https://github.com/mosdef-hub/gmso into writin…
daico007 Jun 17, 2024
3f09d08
minor fix
daico007 Jun 17, 2024
d7529a6
Merge branch 'writing_out_settles' of https://github.com/daico007/gms…
daico007 Jun 17, 2024
927fd6c
add set_rigid method
daico007 Jun 17, 2024
3894c04
add rigid water fixture for settles tests, update mcf test
daico007 Jun 17, 2024
862db26
update test for water settles section in gromacs top
daico007 Jun 17, 2024
d861811
Update gmso/abc/abstract_site.py
daico007 Jun 17, 2024
92cba15
Update gmso/abc/abstract_site.py
daico007 Jun 17, 2024
07b6067
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2024
dddb59e
remove isrigid for residue
daico007 Jun 17, 2024
52fbbde
Merge branch 'writing_out_settles' of https://github.com/daico007/gms…
daico007 Jun 17, 2024
86b83a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2024
4ac478c
add more check when setting molecule/residue
daico007 Jun 17, 2024
469900d
Merge branch 'writing_out_settles' of https://github.com/daico007/gms…
daico007 Jun 17, 2024
bde8b6d
Update gmso/formats/top.py
daico007 Jun 17, 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
5 changes: 3 additions & 2 deletions gmso/abc/abstract_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from gmso.exceptions import GMSOError

try:
from pydantic.v1 import Field, StrictInt, StrictStr, validator
from pydantic.v1 import Field, StrictBool, StrictInt, StrictStr, validator
except ImportError:
from pydantic import Field, StrictInt, StrictStr, validator
from pydantic import Field, StrictBool, StrictInt, StrictStr, validator

PositionType = Union[Sequence[float], np.ndarray, u.unyt_array]

MoleculeType = NamedTuple("Molecule", name=StrictStr, number=StrictInt)
ResidueType = NamedTuple("Residue", name=StrictStr, number=StrictInt)

Expand Down
50 changes: 50 additions & 0 deletions gmso/formats/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,56 @@ def write_top(top, filename, top_vars=None):
site.atom_type.mass.in_units(u.amu).value,
)
)
# Special treatment for water, may ned to consider a better way to tag rigid water
# Built using this https://github.com/gromacs/gromacs/blob/main/share/top/oplsaa.ff/spce.itp as reference
if "water" in tag.lower() and all(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add check for n_sites==3

site.molecule.isrigid for site in unique_molecules[tag]["sites"]
):
sites_list = unique_molecules[tag]["sites"]
water_sites = {
"O": [
site
for site in sites_list
if site.element.symbol == "O"
],
"H": [
site
for site in sites_list
if site.element.symbol == "H"
],
}

ow_idx = shifted_idx_map[top.get_index(water_sites["O"][0])] + 1
doh = np.linalg.norm(
water_sites["O"][0].position.to(u.nm)
- water_sites["H"][0].position.to(u.nm)
)
dhh = np.linalg.norm(
water_sites["H"][0].position.to(u.nm)
- water_sites["H"][1].position.to(u.nm)
)

# Write settles
out_file.write(
"\n[ settles ] ;Water specific constraint algorithm\n"
"; OW_idx\tfunct\tdoh\tdhh\n"
)
out_file.write(
"{0:4s}{1:4s}{2:15.5f}{3:15.5f}\n".format(
str(ow_idx), "1", doh, dhh
)
)

# Write exclusion
out_file.write(
"\n[ exclusions ] ;Exclude all interactions between water's atoms\n"
"1\t2\t3\n"
"2\t1\t3\n"
"3\t1\t2\n"
)

# Skip the rest of the loop
continue

for conn_group in [
"pairs",
Expand Down