Skip to content

Commit c1c893a

Browse files
authored
Merge pull request geodynamics#685 from bobmyhill/constraints
changed constrain threshold
2 parents 141f512 + d69ad51 commit c1c893a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

burnman/optimize/nonlinear_solvers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def __init__(
129129
regularization: float = 0.0,
130130
cond_lu_thresh: float = 1e12,
131131
cond_lstsq_thresh: float = 1e15,
132+
constraint_thresh: float = 1.0e-8,
132133
):
133134
"""
134135
Initialize the solver instance.
@@ -180,12 +181,17 @@ def __init__(
180181
:param cond_lstsq_thresh: Condition number threshold below which
181182
least-squares fallback is considered stable, defaults to 1e15.
182183
:type cond_lstsq_thresh: float, optional
184+
185+
:param constraint_thresh: Threshold for considering a constraint
186+
"active" when determining step feasibility, defaults to 1.0e-8.
187+
:type constraint_thresh: float, optional
183188
"""
184189
self.F = F
185190
self.J = J
186191
self.guess = guess
187192
self.tol = tol
188193
self.F_tol = F_tol
194+
self.constraint_thresh = constraint_thresh
189195
self.max_iterations = max_iterations
190196
self.lambda_bounds = lambda_bounds
191197
self.linear_constraints = linear_constraints
@@ -408,10 +414,10 @@ def _lagrangian_walk_along_constraints(
408414
:rtype: tuple[float, np.ndarray, np.ndarray, bool]
409415
"""
410416
active_constraint_indices = [
411-
i for i, vc in violated_constraints if vc < self.eps
417+
i for i, vc in violated_constraints if vc < self.constraint_thresh
412418
]
413419
inactive_constraint_indices = [
414-
i for i, vc in violated_constraints if vc >= self.eps
420+
i for i, vc in violated_constraints if vc >= self.constraint_thresh
415421
]
416422
c_newton = self._constraints(sol.x + dx)[active_constraint_indices]
417423
c_A = self.linear_constraints[0][active_constraint_indices]

0 commit comments

Comments
 (0)