[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:
Ray Speth 2014-11-11 00:12:19 +00:00
parent a3645ee925
commit 53fb3bd341

View file

@ -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