From ddef28f52599d6f4152ad36c77d7b19a84240ba7 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Wed, 13 Mar 2024 16:06:47 +0000 Subject: [PATCH] Exclude ions from the perturbation. --- src/somd2/runner/_somd1.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/somd2/runner/_somd1.py b/src/somd2/runner/_somd1.py index 407a831..19ba9eb 100644 --- a/src/somd2/runner/_somd1.py +++ b/src/somd2/runner/_somd1.py @@ -648,12 +648,14 @@ def _apply_pert(system, pert_file): # Try to apply the perturbation to each non-water molecule. is_pert = False for mol in non_waters: - try: - pert_mol = _morph.create_from_pertfile(mol, pert_file) - is_pert = True - break - except: - pass + # Exclude ions. + if mol.num_atoms() > 1: + try: + pert_mol = _morph.create_from_pertfile(mol, pert_file) + is_pert = True + break + except: + pass if not is_pert: raise ValueError(f"Failed to apply the perturbation in '{pert_file}'.")