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

Fix mass type in convert_parmed #754

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
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 @@
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(

Check warning on line 578 in gmso/external/convert_parmed.py

View check run for this annotation

Codecov / codecov/patch

gmso/external/convert_parmed.py#L578

Added line #L578 was not covered by tests
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
10 changes: 10 additions & 0 deletions gmso/tests/test_convert_parmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,13 @@ 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)
Loading