Skip to content

Commit fc897fe

Browse files
authored
Merge pull request #134 from OpenBioSim/feature_softcore
Expose softcore_form option
2 parents c4c1b1a + 11e20dc commit fc897fe

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/somd2/config/_config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Config:
7272
"reverse_ring_break_morph",
7373
],
7474
"log_level": [level.lower() for level in _logger._core.levels],
75+
"softcore_form": ["zacharias", "taylor"],
7576
}
7677

7778
# A dictionary of nargs for the various options.
@@ -149,6 +150,7 @@ def __init__(
149150
gcmc_tolerance=0.0,
150151
rest2_scale=1.0,
151152
rest2_selection=None,
153+
softcore_form="zacharias",
152154
output_directory="output",
153155
restart=False,
154156
use_backup=False,
@@ -432,6 +434,10 @@ def __init__(
432434
those atoms will be considered as part of the REST2 region. This allows REST2 to
433435
be applied to protein mutations.
434436
437+
softcore_form: str
438+
The soft-core potential form to use for alchemical interactions. This can be
439+
either "zacharias" or "taylor". The default is "zacharias".
440+
435441
output_directory: str
436442
Path to a directory to store output files.
437443
@@ -560,6 +566,7 @@ def __init__(
560566
self.rest2_selection = rest2_selection
561567
self.restart = restart
562568
self.use_backup = use_backup
569+
self.softcore_form = softcore_form
563570
self.somd1_compatibility = somd1_compatibility
564571
self.pert_file = pert_file
565572
self.save_crash_report = save_crash_report
@@ -2181,6 +2188,22 @@ def restart(self, restart):
21812188
raise ValueError("'restart' must be of type 'bool'")
21822189
self._restart = restart
21832190

2191+
@property
2192+
def softcore_form(self):
2193+
return self._softcore_form
2194+
2195+
@softcore_form.setter
2196+
def softcore_form(self, softcore_form):
2197+
if not isinstance(softcore_form, str):
2198+
raise TypeError("'softcore_form' must be of type 'str'")
2199+
softcore_form = softcore_form.lower().replace(" ", "")
2200+
if softcore_form not in self._choices["softcore_form"]:
2201+
raise ValueError(
2202+
f"'softcore_form' not recognised. Valid forms are: {', '.join(self._choices['softcore_form'])}"
2203+
)
2204+
else:
2205+
self._softcore_form = softcore_form
2206+
21842207
@property
21852208
def use_backup(self):
21862209
return self._use_backup

src/somd2/runner/_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ def __init__(self, system, config):
206206
self._config.fix_perturbable_zero_sigmas
207207
)
208208

209+
# If specified, use the Taylor soft-core form.
210+
if self._config.softcore_form == "taylor":
211+
self._config._extra_args["use_taylor_softening"] = True
212+
209213
# We're running in SOMD1 compatibility mode.
210214
if self._config.somd1_compatibility:
211215
from .._utils._somd1 import make_compatible

0 commit comments

Comments
 (0)