Skip to content

Commit

Permalink
Fix ordering of charges in CHARGE section when using to_prmtop
Browse files Browse the repository at this point in the history
The ordering of the atomic charges in the CHARGE section of the
.prmtop was wrong because we iterated over a dictionary. Now we
excplicitly iterate over the atoms of interchange.topolgy to avoid
this.
  • Loading branch information
lukasbaldauf committed Aug 15, 2024
1 parent 6137232 commit 51f8bd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openff/interchange/interop/amber/export/_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ def to_prmtop(interchange: "Interchange", file_path: Path | str):

prmtop.write("%FLAG CHARGE\n" "%FORMAT(5E16.8)\n")
charges = [
charge.m_as(unit.e) * AMBER_COULOMBS_CONSTANT
for charge in interchange["Electrostatics"].charges.values()
atom.partial_charge.m_as(unit.e) * AMBER_COULOMBS_CONSTANT
for atom in interchange.topology.atoms
]
text_blob = "".join([f"{val:16.8E}" for val in charges])
_write_text_blob(prmtop, text_blob)
Expand Down

0 comments on commit 51f8bd7

Please sign in to comment.