Cantera
2.0
|
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. | |
RootFind (const RootFind &r) | |
Copy constructor. | |
~RootFind () | |
Destructor. Deletes the integrator. | |
RootFind & | operator= (const RootFind &right) |
Assignment operator. | |
int | solve (doublereal xmin, doublereal xmax, int itmax, doublereal &funcTargetValue, doublereal *xbest) |
Using a line search method, find the root of a 1D function. | |
doublereal | func (doublereal x) |
Return the function value. | |
void | setTol (doublereal rtolf, doublereal atolf, doublereal rtolx=0.0, doublereal atolx=0.0) |
Set the tolerance parameters for the rootfinder. | |
void | setPrintLvl (int printLvl) |
Set the print level from the rootfinder. | |
void | setFuncIsGenerallyIncreasing (bool value) |
Set the function behavior flag. | |
void | setFuncIsGenerallyDecreasing (bool value) |
Set the function behavior flag. | |
void | setDeltaX (doublereal deltaXNorm) |
Set the minimum value of deltaX. | |
void | setDeltaXMax (doublereal deltaX) |
Set the maximum value of deltaX. | |
void | printTable () |
Print the iteration history table. | |
Public Attributes | |
ResidEval * | m_residFunc |
Pointer to the residual function evaluator. | |
doublereal | m_funcTargetValue |
Target value for the function. We seek the value of f that is equal to this value. | |
doublereal | m_atolf |
Absolute tolerance for the value of f. | |
doublereal | m_atolx |
Absolute tolerance for the value of x. | |
doublereal | m_rtolf |
Relative tolerance for the value of f and x. | |
doublereal | m_rtolx |
Relative tolerance for the value of x. | |
doublereal | m_maxstep |
Maximum number of step sizes. | |
bool | writeLogAllowed_ |
Boolean to turn on the possibility of writing a log file. | |
Protected Attributes | |
int | printLvl |
Print level. | |
doublereal | DeltaXnorm_ |
Delta X norm. This is the nominal value of deltaX that will be used by the program. | |
int | specifiedDeltaXnorm_ |
Boolean indicating whether DeltaXnorm_ has been specified by the user or not. | |
doublereal | DeltaXMax_ |
Delta X Max. This is the maximum value of deltaX that will be used by the program. | |
int | specifiedDeltaXMax_ |
Boolean indicating whether DeltaXMax_ has been specified by the user or not. | |
bool | FuncIsGenerallyIncreasing_ |
Boolean indicating whether the function is an increasing with x. | |
bool | FuncIsGenerallyDecreasing_ |
Boolean indicating whether the function is decreasing with x. | |
doublereal | deltaXConverged_ |
Value of delta X that is needed for convergence. | |
doublereal | x_maxTried_ |
Internal variable tracking largest x tried. | |
doublereal | fx_maxTried_ |
Internal variable tracking f(x) of largest x tried. | |
doublereal | x_minTried_ |
Internal variable tracking smallest x tried. | |
doublereal | fx_minTried_ |
Internal variable tracking f(x) of smallest x tried. | |
std::vector< struct rfTable > | rfHistory_ |
Vector of iteration histories. | |
Private Member Functions | |
doublereal | delXNonzero (doublereal x1) const |
Calculate a deltaX from an input value of x. | |
doublereal | delXMeaningful (doublereal x1) const |
Calculate a deltaX from an input value of x. | |
doublereal | deltaXControlled (doublereal x2, doublereal x1) const |
Calculate a controlled, nonzero delta between two numbers. | |
bool | theSame (doublereal x2, doublereal x1, doublereal factor=1.0) const |
Function to decide whether two real numbers are the same or not. | |
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 142 of file RootFind.h.