Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mosdef-hub/gmso into 748-re…
Browse files Browse the repository at this point in the history
…move-gmso-xml-conversions
  • Loading branch information
CalCraven committed Aug 10, 2023
2 parents d6bc933 + 8b639c6 commit 60025c0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gmso/external/convert_parmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,15 +568,16 @@ def _atom_types_from_gmso(top, structure, atom_map):
atype_charge = float(atom_type.charge.to("Coulomb").value) / (
1.6 * 10 ** (-19)
)
atype_mass = float(atom_type.mass.to("amu"))
atype_sigma = float(atom_type.parameters["sigma"].to("angstrom").value)
atype_epsilon = float(
atom_type.parameters["epsilon"].to("kcal/mol").value
)
if atom_type.mass:
atype_mass = atom_type.mass.to("amu").value
atype_mass = float(atom_type.mass.to("amu").value)
else:
atype_mass = element_by_symbol(atom_type.name).mass.to("amu").value
atype_mass = float(
element_by_symbol(atom_type.name).mass.to("amu").value
)
atype_atomic_number = getattr(
element_by_symbol(atom_type.name), "atomic_number", None
)
Expand Down
26 changes: 26 additions & 0 deletions gmso/tests/test_convert_parmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,29 @@ def test_pmd_complex_ureybradleys(self, parmed_methylnitroaniline):
for t in dihedrals_list
)
)

def test_to_and_from_parmed_with_topology(self, typed_ethane):
top = typed_ethane
struc = to_parmed(top)
top_from_struc = from_parmed(struc)
assert top.n_sites == top_from_struc.n_sites
assert top.n_bonds == top_from_struc.n_bonds
assert top.n_angles == top_from_struc.n_angles
assert top.n_dihedrals == top_from_struc.n_dihedrals
assert len(top.atom_types) == len(top_from_struc.atom_types)

def test_to_and_from_parmed_with_impropers_dihedrals(
self, typed_methylnitroaniline
):
top = typed_methylnitroaniline
struc = to_parmed(top)
top_from_struc = from_parmed(struc)
assert top.n_sites == top_from_struc.n_sites
assert top.n_bonds == top_from_struc.n_bonds
assert top.n_angles == top_from_struc.n_angles
assert top.n_dihedrals == top_from_struc.n_dihedrals
assert top.n_impropers == top_from_struc.n_impropers
assert len(top.atom_types) == len(top_from_struc.atom_types)
assert len(top.dihedral_types(filter_by=pfilter)) == len(
top_from_struc.dihedral_types(filter_by=pfilter)
)

0 comments on commit 60025c0

Please sign in to comment.