Utilities for the Fluid Properties Module

Newton method solver

The fluid properties module includes a 1D and a 2D Newton method solver.

1D solver

The 1D Newton method solver is used to solve the problem:

  • Find zz such that f(x,z)=yf(x, z) = y, with xx, yy known constants and ff a function.

ff should compute both its return value and the derivatives of its value with regards to both its variables using references.

The routine will error if a NaN is encountered or if the maximum number of iterations is exceeded.

2D solver

The 2D Newton method solver is used to solve the problem:

f1(x,y)=af2(x,y)=b\begin{split} f1(x, y) &= a \\ f2(x, y) &= b \end{split}

with aa, bb known constants, f1f1, f2f2 functions and xx, yy the real-valued variables to solve for.

The functions should compute both their return value and the derivatives of their value with regards to both variables using references.

The routine will not error if a NaN is encountered or if the maximum number of iterations is exceeded. Instead, a converged boolean will be set to false, and the routine will return the last valid estimates of xx and yy. It is the responsibility of the user to handle this unconverged output.

Brent's method solver

Brent's method may be used to find roots of a general function. It was adapted from Numerical Recipes in C++.

More information may be found here.