Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions openff/interchange/common/_nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ def charges(

return self._charges

def get_charge_array(self, include_virtual_sites: bool = False) -> Quantity:
"""
Return a one-dimensional array-like of atomic charges, ordered topologically.

If virtual sites are present in the system, `NotImplementedError` is raised.
"""
if include_virtual_sites:
raise NotImplementedError("Not yet implemented with virtual sites")

if VirtualSiteKey in {type(key) for key in self.key_map}:
raise NotImplementedError(
"Not yet implemented when virtual sites are present, even with `include_virtual_sites=False`.",
)

return Quantity.from_list([q for _, q in sorted(self.charges.items(), key=lambda x: x[0].atom_indices)])

def _get_charges(
self,
include_virtual_sites: bool = False,
Expand Down
2 changes: 1 addition & 1 deletion openff/interchange/interop/amber/export/_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def to_prmtop(interchange: "Interchange", file_path: Path | str):

prmtop.write("%FLAG CHARGE\n%FORMAT(5E16.8)\n")
charges = (
interchange["Electrostatics"] # type: ignore[attr-defined]
interchange["Electrostatics"]
.get_charge_array()
.m_as(
"elementary_charge",
Expand Down
16 changes: 0 additions & 16 deletions openff/interchange/smirnoff/_nonbonded.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,22 +343,6 @@ def charges(

return self._charges

def get_charge_array(self, include_virtual_sites: bool = False) -> Quantity:
"""
Return a one-dimensional array-like of atomic charges, ordered topologically.

If virtual sites are present in the system, `NotImplementedError` is raised.
"""
if include_virtual_sites:
raise NotImplementedError("Not yet implemented with virtual sites")

if VirtualSiteKey in {type(key) for key in self.key_map}:
raise NotImplementedError(
"Not yet implemented when virtual sites are present, even with `include_virtual_sites=False`.",
)

return Quantity.from_list([q for _, q in sorted(self.charges.items(), key=lambda x: x[0].atom_indices)])

def _get_charges(
self,
include_virtual_sites: bool = True,
Expand Down
Loading