Skip to content

Commit

Permalink
fix failing tests in handling charges from atom_type and not site
Browse files Browse the repository at this point in the history
  • Loading branch information
CalCraven committed Dec 11, 2023
1 parent cc16d53 commit a47016a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gmso/external/convert_parmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def from_parmed(structure, refer_type=True):
if refer_type and isinstance(atom.atom_type, pmd.AtomType)
else None
)
site.atom_type.charge = atom.charge * u.elementary_charge
if site.atom_type:
site.atom_type.charge = atom.charge * u.elementary_charge
site_map[atom] = site
top.add_site(site)

Expand Down
4 changes: 3 additions & 1 deletion gmso/formats/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ def write_top(top, filename, top_vars=None):
tag,
site.atom_type.tags["element"],
"1", # TODO: care about charge groups
site.charge.in_units(u.elementary_charge).value,
site.atom_type.charge.in_units(
u.elementary_charge
).value,
site.atom_type.mass.in_units(u.amu).value,
)
)
Expand Down
4 changes: 2 additions & 2 deletions gmso/tests/files/typed_ethane_ref.top
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

[ atomtypes ]
; name at.num mass charge ptype sigma epsilon
opls_135 6 12.01078 0.00000 A 0.35000 0.27614
opls_140 1 1.00795 0.00000 A 0.25000 0.12552
opls_135 6 12.01078 -0.18000 A 0.35000 0.27614
opls_140 1 1.00795 0.06000 A 0.25000 0.12552

[ moleculetype ]
; name nrexcl
Expand Down

0 comments on commit a47016a

Please sign in to comment.