Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mosdef-hub/gmso into lamm…
Browse files Browse the repository at this point in the history
…ps_bonds_angles
  • Loading branch information
rmatsum836 committed Mar 12, 2020
2 parents 50c11d0 + 55bc765 commit 7c76241
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 34 deletions.
14 changes: 14 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

version: 2
formats:
- htmlzip
python:
version: 3.7
install:
- requirements: docs/requirements.txt
system_packages: true

sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: false
2 changes: 1 addition & 1 deletion docs/formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GROMACS
-------
The following methods are available for reading and writing GROMACS files.

.. autofunction:: gmso.external.read_gro
.. autofunction:: gmso.formats.read_gro
.. autofunction:: gmso.formats.write_gro

GSD
Expand Down
6 changes: 5 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
sphinx
sphinx_rtd_theme
boltons
lxml
unyt
pytest
sphinx_rtd_theme
30 changes: 12 additions & 18 deletions gmso/formats/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def write_top(top, filename):

_validate_compatibility(top)
top_vars = _get_top_vars()
_assign_indices(top)

with open(filename, 'w') as out_file:
out_file.write(
Expand Down Expand Up @@ -131,15 +130,15 @@ def write_top(top, filename):
'\n[ bonds ]\n'
'; ai aj funct c0 c1\n'
)
for bond_idx, bond in enumerate(top.bonds):
for bond in top.bonds:
out_file.write(
'\t{0}'
'\t{1}'
'\t{2}'
'\t{3}'
'\t{4}\n'.format(
bond.connection_members[0].idx,
bond.connection_members[1].idx,
top.sites.index(bond.connection_members[0]),
top.sites.index(bond.connection_members[1]),
'1',
bond.connection_type.parameters['r_eq'].in_units(u.nm).value,
bond.connection_type.parameters['k'].in_units(
Expand All @@ -151,17 +150,17 @@ def write_top(top, filename):
'\n[ angles ]\n'
'; ai aj ak funct c0 c1\n'
)
for angle_idx, angle in enumerate(top.angles):
for angle in top.angles:
out_file.write(
'\t{0}'
'\t{1}'
'\t{2}'
'\t{3}'
'\t{4}'
'\t{5}\n'.format(
angle.connection_members[0].idx,
angle.connection_members[1].idx,
angle.connection_members[2].idx,
top.sites.index(angle.connection_members[0]),
top.sites.index(angle.connection_members[1]),
top.sites.index(angle.connection_members[2]),
'1',
angle.connection_type.parameters['theta_eq'].in_units(u.degree).value,
angle.connection_type.parameters['k'].in_units(
Expand All @@ -173,7 +172,7 @@ def write_top(top, filename):
'\n[ dihedrals ]\n'
'; ai aj ak al funct c0 c1 c2\n'
)
for dihedral_idx, dihedral in enumerate(top.dihedrals):
for dihedral in top.dihedrals:
out_file.write(
'\t{0}'
'\t{1}'
Expand All @@ -186,10 +185,10 @@ def write_top(top, filename):
'\t{8}'
'\t{9}'
'\t{10}\n'.format(
dihedral.connection_members[0].idx,
dihderal.connection_members[1].idx,
dihedral.connection_members[2].idx,
dihedral.connection_members[3].idx,
top.sites.index(dihedral.connection_members[0]),
top.sites.index(dihedral.connection_members[1]),
top.sites.index(dihedral.connection_members[2]),
top.sites.index(dihedral.connection_members[3]),
'3',
dihedral.connection_type.parameters['c0'],
dihedral.connection_type.parameters['c1'],
Expand Down Expand Up @@ -246,11 +245,6 @@ def _get_top_vars():
return top_vars


def _assign_indices(top):
for idx, site in enumerate(top.sites):
site.idx = idx + 1


def _lookup_atomic_number(atom_type):
"""Attempt to look up an atomic_number based on atom type information, 0 if non-element type"""
try:
Expand Down
31 changes: 29 additions & 2 deletions gmso/tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

from gmso.core.box import Box
from gmso.core.topology import Topology
from gmso.core.element import Hydrogen
from gmso.core.element import Hydrogen, Oxygen
from gmso.core.site import Site
from gmso.core.angle import Angle
from gmso.core.atom_type import AtomType
from gmso.core.forcefield import ForceField
from gmso.external.convert_mbuild import from_mbuild
Expand Down Expand Up @@ -97,8 +98,34 @@ def water_system(self):

packed_system = mb.fill_box(
compound=water,
n_compounds=10,
n_compounds=2,
box=mb.Box([2, 2, 2])
)

return from_mbuild(packed_system)

@pytest.fixture
def typed_water_system(self, water_system):
top = water_system

ff = ForceField(get_path('tip3p.xml'))

element_map = {"O": "opls_111", "H": "opls_112"}

for atom in top.sites:
atom.atom_type = ff.atom_types[atom.name]

for bond in top.bonds:
bond.connection_type = ff.bond_types["opls_111~opls_112"]

for subtop in top.subtops:
angle = Angle(
connection_members=[site for site in subtop.sites],
name="opls_112~opls_111~opls_112",
connection_type=ff.angle_types["opls_112~opls_111~opls_112"]
)
top.add_connection(angle)

top.update_topology()

return top
9 changes: 5 additions & 4 deletions gmso/tests/test_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ def test_write_top(self, typed_ar_system):
write_top(top, 'ar.top')


def test_pmd_loop(self, typed_ar_system):
top = typed_ar_system
write_top(top, 'ar.top')
pmd.load_file('ar.top')
@pytest.mark.parametrize('top', ['typed_ar_system',
'typed_water_system'])
def test_pmd_loop(self, top, request):
write_top(request.getfixturevalue(top), 'system.top')
pmd.load_file('system.top')


def test_modified_potentials(self, ar_system):
Expand Down
27 changes: 19 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
from setuptools import setup
from setuptools import setup, find_packages

#####################################
VERSION = "0.0.0"
ISRELEASED = False
VERSION = "0.2.0"
ISRELEASED = False
if ISRELEASED:
__version__ = VERSION
else:
__version__ = VERSION + '.dev0'
#####################################


requirements = [
'numpy',
'scipy',
'mbuild>=0.10.4',
'unyt>=2.4',
'boltons',
'lxml',
]


setup(
name='gmso',
version=__version__,
packages=find_packages(),
zip_safe=True,
author='Matthew W Thompson, Justin Gilmer',
author_email='[email protected], [email protected]',
url='https://github.com/mattwthompson/topology',
download_url='https://github.com/mattwthompson/topology/tarball/{}'.format(__version__),
package_dir={'gmso': 'gmso'},
url='https://github.com/mosdef-hub/gmso',
download_url='https://github.com/mosdef-hub/gmso/tarball/{}'.format(__version__),
license="MIT",
zip_safe=False,
keywords='gmso',
classifiers=[
'Development Status :: 1 - Planning',
Expand All @@ -35,5 +45,6 @@
'Operating System :: Unix',
'Operating System :: MacOS',
],
install_requires=requirements,
python_requires='>=3.6, <4',
)

0 comments on commit 7c76241

Please sign in to comment.