Commit d817b46b authored by Peter Eastman's avatar Peter Eastman
Browse files

Improved rounding behavior when computing the number of ions to add

parent 285a4d88
...@@ -316,7 +316,7 @@ class Modeller(object): ...@@ -316,7 +316,7 @@ class Modeller(object):
# Add ions to neutralize the system. # Add ions to neutralize the system.
totalCharge = int(sum((nonbonded.getParticleParameters(i)[0].value_in_unit(elementary_charge) for i in range(system.getNumParticles())))) totalCharge = int(floor(0.5+sum((nonbonded.getParticleParameters(i)[0].value_in_unit(elementary_charge) for i in range(system.getNumParticles())))))
if abs(totalCharge) > len(addedWaters): if abs(totalCharge) > len(addedWaters):
raise Exception('Cannot neutralize the system because the charge is greater than the number of available positions for ions') raise Exception('Cannot neutralize the system because the charge is greater than the number of available positions for ions')
def addIon(element): def addIon(element):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment