Skip to content

Commit

Permalink
Merge pull request #57 from OpenBioSim/fix_56
Browse files Browse the repository at this point in the history
Fix issue #56
  • Loading branch information
mb2055 authored Sep 27, 2024
2 parents 49e9f99 + 39ca635 commit eaed3ab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/somd2/config/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(
charge_scale_factor=0.2,
swap_end_states=False,
coulomb_power=1.0,
shift_coulomb="1A",
shift_delta="1A",
restraints=None,
constraint="h_bonds",
Expand Down Expand Up @@ -185,6 +186,10 @@ def __init__(
Power to use for the soft-core Coulomb interaction. This is used
to soften the electrostatic interaction.
shift_coulomb : str
The soft-core shift-coulomb parameter. This is used to soften the
Coulomb interaction.
shift_delta : str
The soft-core shift-delta parameter. This is used to soften the
Lennard-Jones interaction.
Expand Down Expand Up @@ -319,6 +324,7 @@ def __init__(
self.charge_scale_factor = charge_scale_factor
self.swap_end_states = swap_end_states
self.coulomb_power = coulomb_power
self.shift_coulomb = shift_coulomb
self.shift_delta = shift_delta
self.restraints = restraints
self.constraint = constraint
Expand Down Expand Up @@ -772,6 +778,28 @@ def coulomb_power(self, coulomb_power):
raise ValueError("'coulomb_power' must be a of type 'float'")
self._coulomb_power = coulomb_power

@property
def shift_coulomb(self):
return self._shift_coulomb

@shift_coulomb.setter
def shift_coulomb(self, shift_coulomb):
if not isinstance(shift_coulomb, str):
raise TypeError("'shift_coulomb' must be of type 'str'")

from sire.units import angstrom

try:
sc = _sr.u(shift_coulomb)
except:
raise ValueError(
f"Unable to parse 'shift_coulomb' as a Sire GeneralUnit: {shift_coulomb}"
)
if not sc.has_same_units(angstrom):
raise ValueError("'shift_coulomb' units are invalid.")

self._shift_coulomb = sc

@property
def shift_delta(self):
return self._shift_delta
Expand Down
9 changes: 9 additions & 0 deletions src/somd2/runner/_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ def _setup_dynamics(self, equilibration=False):
swap_end_states=self._config.swap_end_states,
com_reset_frequency=self._config.com_reset_frequency,
vacuum=not self._has_space,
coulomb_power=self._config.coulomb_power,
shift_coulomb=self._config.shift_coulomb,
shift_delta=self._config.shift_delta,
map=self._config._extra_args,
)

Expand Down Expand Up @@ -249,6 +252,9 @@ def _minimisation(
include_constrained_energies=self._config.include_constrained_energies,
dynamic_constraints=self._config.dynamic_constraints,
swap_end_states=self._config.swap_end_states,
coulomb_power=self._config.coulomb_power,
shift_coulomb=self._config.shift_coulomb,
shift_delta=self._config.shift_delta,
map=self._config._extra_args,
)
m.run()
Expand All @@ -270,6 +276,9 @@ def _minimisation(
include_constrained_energies=self._config.include_constrained_energies,
dynamic_constraints=self._config.dynamic_constraints,
swap_end_states=self._config.swap_end_states,
coulomb_power=self._config.coulomb_power,
shift_coulomb=self._config.shift_coulomb,
shift_delta=self._config.shift_delta,
map=self._config._extra_args,
)
m.run()
Expand Down

0 comments on commit eaed3ab

Please sign in to comment.