AlephZero said:
The NR failure could be trying to tell you that the solution for your part-load condition is unstable. You wouldn't be the first person to design a gas turbine that is unstable at part load, and you probably won't be the last either!
You bring up an interesting point, but I don't believe my models are complicated enough to take into account surge or other peculiarities that would lead to unstable part load operation. Also, using EES and varying percent load (what I did initially) generates the proper curves from 0% load to 100% load, something my current implementation will not.
AlephZero said:
You could try starting from your working full load solution and reduce the load in small increments to see when it fails, or if the "path" of the solution points looks sensible before it fails.
All of the numbers "head" in the right direction, but as far as I can tell, the accuracy of the off-design numbers (even at 99.9%) is questionable. The only place the NR method converges on the proper numbers is at 100% load, which I find odd.
For what it's worth, my code can calculate the Jacobian two different ways (numerically, and with hard-coded partial derivatives) and both match. Part of the problem with my implementation arises when the Jacobian cannot be inverted. I have a feeling there's a way around this, but I am not good enough with calculus or linear algebra to know how to do this.
AlephZero said:
The "best way" to solve the equations is to use all the information you have, and since we don't know anything about the equations except there are 6 (or 17) of them, we haven't got much to work with.
Reducing 17 "simple" nonlnear equations to 6 more complicated ones could be a bad idea. You could try solving the original system directly.
That's probably true. Since posting my original question, I've re-derived my equations and reduced them down to 10 equations, 10 unknowns. Some of the equations can be combined and reduced very nicely. Also, some are last-child equations, meaning they can be eliminated without affecting the rest of the models (calculating a new cycle efficiency comes to mind).
These 10 equations are the same in EES as they are in my python model. Based on the solution in EES, I know the equations are sound. It is the method or (more likely) my implementation that is the problem.
AlephZero said:
For other methods, you could try treating this as an optimisation problem. If you want to solve the system of equations Ax = B, given an approximate solution x' write Ax' = B + R, and minimise RT.R using a standard optimisation algorithm like nonlnear least squares, conjugate gradient, or (my usual first choice) BFGS. They are all in "Numerical Recipes". The NR implementations aren't particularly efficient, but that isn't very important for a problem with 6 or 17 variables (it might be more important if you had 600 variables!)
If all that fails, a really "brute force and no brain" optimisation method is the Simplex algorithm - also in NR. It is almost guaranteed to find you SOME solution to a nonlinear system if you let it run for long enough, but it may not find the one you were looking for.
I'll take a look into these methods. These numerical solvers are really amazing. I feel like I've learned so much over the last few days, but I realize I haven't even begun to scratch the surface. I like how something seemingly simple can be used to solve some of the most complicated equations out there (and by no means am I calling my equations complicated!).