Cantera
2.1.2
|
Root finder for 1D problems. More...
#include <RootFind.h>
Classes | |
struct | rfTable |
Structure containing the iteration history. More... | |
Public Member Functions | |
RootFind (ResidEval *resid) | |
Constructor for the object. More... | |
RootFind (const RootFind &r) | |
Copy constructor. More... | |
RootFind & | operator= (const RootFind &right) |
Assignment operator. More... | |
int | solve (doublereal xmin, doublereal xmax, int itmax, doublereal &funcTargetValue, doublereal *xbest) |
Using a line search method, find the root of a 1D function. More... | |
doublereal | func (doublereal x) |
Return the function value. More... | |
void | setTol (doublereal rtolf, doublereal atolf, doublereal rtolx=0.0, doublereal atolx=0.0) |
Set the tolerance parameters for the rootfinder. More... | |
void | setPrintLvl (int printLvl) |
Set the print level from the rootfinder. More... | |
void | setFuncIsGenerallyIncreasing (bool value) |
Set the function behavior flag. More... | |
void | setFuncIsGenerallyDecreasing (bool value) |
Set the function behavior flag. More... | |
void | setDeltaX (doublereal deltaXNorm) |
Set the minimum value of deltaX. More... | |
void | setDeltaXMax (doublereal deltaX) |
Set the maximum value of deltaX. More... | |
void | printTable () |
Print the iteration history table. More... | |
Public Attributes | |
ResidEval * | m_residFunc |
Pointer to the residual function evaluator. More... | |
doublereal | m_funcTargetValue |
Target value for the function. We seek the value of f that is equal to this value. More... | |
doublereal | m_atolf |
Absolute tolerance for the value of f. More... | |
doublereal | m_atolx |
Absolute tolerance for the value of x. More... | |
doublereal | m_rtolf |
Relative tolerance for the value of f and x. More... | |
doublereal | m_rtolx |
Relative tolerance for the value of x. More... | |
doublereal | m_maxstep |
Maximum number of step sizes. More... | |
bool | writeLogAllowed_ |
Boolean to turn on the possibility of writing a log file. More... | |
Protected Attributes | |
int | printLvl |
Print level. More... | |
doublereal | DeltaXnorm_ |
Delta X norm. This is the nominal value of deltaX that will be used by the program. More... | |
int | specifiedDeltaXnorm_ |
Boolean indicating whether DeltaXnorm_ has been specified by the user or not. More... | |
doublereal | DeltaXMax_ |
Delta X Max. This is the maximum value of deltaX that will be used by the program. More... | |
int | specifiedDeltaXMax_ |
Boolean indicating whether DeltaXMax_ has been specified by the user or not. More... | |
bool | FuncIsGenerallyIncreasing_ |
Boolean indicating whether the function is an increasing with x. More... | |
bool | FuncIsGenerallyDecreasing_ |
Boolean indicating whether the function is decreasing with x. More... | |
doublereal | deltaXConverged_ |
Value of delta X that is needed for convergence. More... | |
doublereal | x_maxTried_ |
Internal variable tracking largest x tried. More... | |
doublereal | fx_maxTried_ |
Internal variable tracking f(x) of largest x tried. More... | |
doublereal | x_minTried_ |
Internal variable tracking smallest x tried. More... | |
doublereal | fx_minTried_ |
Internal variable tracking f(x) of smallest x tried. More... | |
std::vector< struct rfTable > | rfHistory_ |
Vector of iteration histories. More... | |
Private Member Functions | |
doublereal | delXNonzero (doublereal x1) const |
Calculate a deltaX from an input value of x. More... | |
doublereal | delXMeaningful (doublereal x1) const |
Calculate a deltaX from an input value of x. More... | |
doublereal | deltaXControlled (doublereal x2, doublereal x1) const |
Calculate a controlled, nonzero delta between two numbers. More... | |
bool | theSame (doublereal x2, doublereal x1, doublereal factor=1.0) const |
Function to decide whether two real numbers are the same or not. More... | |
Root finder for 1D problems.
The root finder solves a single nonlinear equation described below.
\[ f(x) = f_0 \]
\( f(x) \) is assumed to be single valued as a function of x. \( f(x) \) is not assumed to be continuous nor is its derivative assumed to be well formed.
Root finders are significantly different in the sense that do not have to rely solely on Newton's method to find the answer to the problem. Instead they use a method to bound the solution between high and low values and then use a method to refine that bound. The eventual solution to the problem is presented as x_best and as a bound, delta_X, on the solution component. Because of this, they are far more stable for functions and Jacobians that have discontinuities or noise associated with them.
The algorithm is a convolution of a local Secant method with an approach of finding a straddle in x. The Jacobian is never required.
There is a general breakdown of the algorithm into stages. The first stage seeks to find a straddle of the function. The second stage seeks to reduce the bounds in x and f in order to satisfy the specification of the stopping criteria. In the last stage the algorithm seeks to find the base value of x that satisfies the original equation given what it current knows about the function.
Globalization strategy
Specifying the General Changes in x Supplying Hints with General Function Behavior Flags
Stopping Criteria
Specification of the Stopping Criteria
Additional constraints
Bounds Criteria For the Routine
Example
Noise
General Search to be done when all else fails
Definition at line 131 of file RootFind.h.