diff --git a/gmso/external/convert_parmed.py b/gmso/external/convert_parmed.py index 6338c80a6..8ab60f741 100644 --- a/gmso/external/convert_parmed.py +++ b/gmso/external/convert_parmed.py @@ -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 ) diff --git a/gmso/tests/test_convert_parmed.py b/gmso/tests/test_convert_parmed.py index 47d10a7db..433dd0a93 100644 --- a/gmso/tests/test_convert_parmed.py +++ b/gmso/tests/test_convert_parmed.py @@ -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) + )