diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 000000000..59affecda --- /dev/null +++ b/.readthedocs.yml @@ -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 \ No newline at end of file diff --git a/docs/formats.rst b/docs/formats.rst index e55b8f1f3..ca2a164ca 100644 --- a/docs/formats.rst +++ b/docs/formats.rst @@ -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 diff --git a/docs/requirements.txt b/docs/requirements.txt index 856b3f4cb..c1e261c6a 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,6 @@ sphinx -sphinx_rtd_theme \ No newline at end of file +boltons +lxml +unyt +pytest +sphinx_rtd_theme diff --git a/gmso/formats/top.py b/gmso/formats/top.py index 3996b45fc..1f00bf12e 100644 --- a/gmso/formats/top.py +++ b/gmso/formats/top.py @@ -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( @@ -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( @@ -151,7 +150,7 @@ 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}' @@ -159,9 +158,9 @@ def write_top(top, filename): '\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( @@ -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}' @@ -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'], @@ -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: diff --git a/gmso/tests/base_test.py b/gmso/tests/base_test.py index beda73b38..9c28a77f0 100644 --- a/gmso/tests/base_test.py +++ b/gmso/tests/base_test.py @@ -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 @@ -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 diff --git a/gmso/tests/test_top.py b/gmso/tests/test_top.py index d5d31700b..372866bb9 100644 --- a/gmso/tests/test_top.py +++ b/gmso/tests/test_top.py @@ -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): diff --git a/setup.py b/setup.py index 9e418c1c8..1dbdc57eb 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ -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: @@ -10,16 +10,26 @@ ##################################### +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='matt.thompson@vanderbilt.edu, justin.b.gilmer@vanderbilt.edu', - 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', @@ -35,5 +45,6 @@ 'Operating System :: Unix', 'Operating System :: MacOS', ], + install_requires=requirements, + python_requires='>=3.6, <4', ) -