[Test] Prevent infinite loop in TestSofcKinetics
If an infinite loop occurs in the Newton solver, it indicates a problem, but this way the test will finish (and fail).
This commit is contained in:
parent
a3645ee925
commit
53fb3bd341
1 changed files with 5 additions and 0 deletions
|
|
@ -384,9 +384,14 @@ class TestSofcKinetics(utilities.CanteraTest):
|
|||
""" Solve f(x) = C by Newton iteration. """
|
||||
x0 = xstart
|
||||
dx = 1.0e-6
|
||||
|
||||
n = 0
|
||||
while True:
|
||||
n += 1
|
||||
f0 = f(x0) - C
|
||||
x0 -= f0/(f(x0 + dx) - C - f0)*dx
|
||||
if n > 1000:
|
||||
raise Exception('No convergence in Newton solve')
|
||||
if abs(f0) < 0.00001:
|
||||
return x0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue