Skip to content

Commit c2d2f82

Browse files
committed
Fix logging of perturbable atoms in REST2 selection.
1 parent 5d236c5 commit c2d2f82

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/somd2/runner/_base.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ def __init__(self, system, config):
172172

173173
# Make sure the system contains perturbable molecules.
174174
try:
175-
self._system.molecules("property is_perturbable")
175+
atoms = self._system["property is_perturbable"].atoms()
176+
pert_idxs = self._system.atoms().find(atoms)
176177
except KeyError:
177178
msg = "No perturbable molecules in the system"
178179
_logger.error(msg)
@@ -433,12 +434,18 @@ def __init__(self, system, config):
433434
msg = "REST2 selection cannot contain all atoms in the system."
434435
_logger.error(msg)
435436
raise ValueError(msg)
437+
438+
# Get the atom indices.
439+
idxs = self._system.atoms().find(atoms)
440+
441+
# If no indices are in the perturbable region, then add them.
442+
if not any(i in pert_idxs for i in idxs):
443+
idxs = sorted(pert_idxs + idxs)
436444
else:
437-
atoms = _sr.mol.selection_to_atoms(self._system, "property is_perturbable")
445+
idxs = pert_idxs
438446

439447
# Log the atom indices in the REST2 selection.
440448
if is_rest2:
441-
idxs = self._system.atoms().find(atoms)
442449
_logger.info(f"REST2 selection contains {len(atoms)} atoms: {idxs}")
443450

444451
# Apply hydrogen mass repartitioning.

0 commit comments

Comments
 (0)