From 51f8bd762e8cf1ec72655a74a2d953132d92e68c Mon Sep 17 00:00:00 2001 From: Lukas Baldauf Date: Thu, 15 Aug 2024 15:39:32 +0200 Subject: [PATCH] Fix ordering of charges in CHARGE section when using to_prmtop 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. --- openff/interchange/interop/amber/export/_export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openff/interchange/interop/amber/export/_export.py b/openff/interchange/interop/amber/export/_export.py index 008e88862..43d0d5fe8 100644 --- a/openff/interchange/interop/amber/export/_export.py +++ b/openff/interchange/interop/amber/export/_export.py @@ -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)