Skip to content

Commit

Permalink
check for non-zero abs charge before scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjonesBSU committed Aug 30, 2023
1 parent 3081355 commit 0f2ec45
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hoomd_organics/base/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,11 @@ def _scale_charges(self):
)
net_charge = sum(charges)
abs_charge = sum(abs(charges))
for site in self.gmso_system.sites:
site.charge -= abs(site.charge) * (net_charge / abs_charge)
if abs_charge != 0:
for site in self.gmso_system.sites:
site.charge -= abs(site.charge if site.charge else 0) * (
net_charge / abs_charge
)

def to_gsd(self, file_name):
with gsd.hoomd.open(file_name, "wb") as traj:
Expand Down

0 comments on commit 0f2ec45

Please sign in to comment.