Skip to content

Commit

Permalink
ensure other internal types are accounted for properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ehermes committed Jun 15, 2023
1 parent 3ea12c8 commit 0634169
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions sella/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ def nangles(self) -> int:
def ndihedrals(self) -> int:
return sum(self._active['dihedrals'])

@property
def nother(self) -> int:
return sum(self._active['other'])

@property
def nrotations(self) -> int:
return sum(self._active['rotations'])
Expand Down
18 changes: 12 additions & 6 deletions sella/optimize/restricted_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def cons(self, s, dsda=None):
class MaxInternalStep(BaseRestrictedStep):
synonyms = ['mis', 'max internal step']

def __init__(self, pes, *args, wx=1., wb=1., wa=1., wd=1., **kwargs):
def __init__(
self, pes, *args, wx=1., wb=1., wa=1., wd=1., wo=1., **kwargs
):
if pes.int is None:
raise ValueError("Internal coordinates are required for the "
"{} trust region method"
Expand All @@ -162,14 +164,18 @@ def __init__(self, pes, *args, wx=1., wb=1., wa=1., wd=1., **kwargs):
self.wb = wb
self.wa = wa
self.wd = wd
self.wo = wo
BaseRestrictedStep.__init__(self, pes, *args, **kwargs)

def cons(self, s, dsda=None):
w = np.array([self.wx] * self.pes.int.ntrans
+ [self.wb] * self.pes.int.nbonds
+ [self.wa] * self.pes.int.nangles
+ [self.wd] * self.pes.int.ndihedrals
+ [self.wx] * self.pes.int.nrotations)
w = np.array(
[self.wx] * self.pes.int.ntrans
+ [self.wb] * self.pes.int.nbonds
+ [self.wa] * self.pes.int.nangles
+ [self.wd] * self.pes.int.ndihedrals
+ [self.wo] * self.pes.int.nother
+ [self.wx] * self.pes.int.nrotations
)
assert len(w) == len(s)

sw = np.abs(s * w)
Expand Down

0 comments on commit 0634169

Please sign in to comment.