From 11e20dca702ebfee070d5d135fce74e06142247d Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Fri, 27 Mar 2026 14:28:16 +0000 Subject: [PATCH] Expose softcore_form option. --- src/somd2/config/_config.py | 23 +++++++++++++++++++++++ src/somd2/runner/_base.py | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/somd2/config/_config.py b/src/somd2/config/_config.py index 840f87f..217cd4e 100644 --- a/src/somd2/config/_config.py +++ b/src/somd2/config/_config.py @@ -72,6 +72,7 @@ class Config: "reverse_ring_break_morph", ], "log_level": [level.lower() for level in _logger._core.levels], + "softcore_form": ["zacharias", "taylor"], } # A dictionary of nargs for the various options. @@ -149,6 +150,7 @@ def __init__( gcmc_tolerance=0.0, rest2_scale=1.0, rest2_selection=None, + softcore_form="zacharias", output_directory="output", restart=False, use_backup=False, @@ -432,6 +434,10 @@ def __init__( those atoms will be considered as part of the REST2 region. This allows REST2 to be applied to protein mutations. + softcore_form: str + The soft-core potential form to use for alchemical interactions. This can be + either "zacharias" or "taylor". The default is "zacharias". + output_directory: str Path to a directory to store output files. @@ -560,6 +566,7 @@ def __init__( self.rest2_selection = rest2_selection self.restart = restart self.use_backup = use_backup + self.softcore_form = softcore_form self.somd1_compatibility = somd1_compatibility self.pert_file = pert_file self.save_crash_report = save_crash_report @@ -2181,6 +2188,22 @@ def restart(self, restart): raise ValueError("'restart' must be of type 'bool'") self._restart = restart + @property + def softcore_form(self): + return self._softcore_form + + @softcore_form.setter + def softcore_form(self, softcore_form): + if not isinstance(softcore_form, str): + raise TypeError("'softcore_form' must be of type 'str'") + softcore_form = softcore_form.lower().replace(" ", "") + if softcore_form not in self._choices["softcore_form"]: + raise ValueError( + f"'softcore_form' not recognised. Valid forms are: {', '.join(self._choices['softcore_form'])}" + ) + else: + self._softcore_form = softcore_form + @property def use_backup(self): return self._use_backup diff --git a/src/somd2/runner/_base.py b/src/somd2/runner/_base.py index b351054..5fd0799 100644 --- a/src/somd2/runner/_base.py +++ b/src/somd2/runner/_base.py @@ -206,6 +206,10 @@ def __init__(self, system, config): self._config.fix_perturbable_zero_sigmas ) + # If specified, use the Taylor soft-core form. + if self._config.softcore_form == "taylor": + self._config._extra_args["use_taylor_softening"] = True + # We're running in SOMD1 compatibility mode. if self._config.somd1_compatibility: from .._utils._somd1 import make_compatible