To solve a system of nonlinear algebraic equations of the form f(u) = 0. More...
Public Member Functions | |
NLASSolver () | |
Default constructor. | |
NLASSolver (NonLinearIter nl, size_t nb_eq=1) | |
Constructor defining the iterative method to solve the equation. More... | |
NLASSolver (real_t &x, NonLinearIter nl=NEWTON) | |
Constructor defining a one-variable problem. More... | |
NLASSolver (Vect< real_t > &x, NonLinearIter nl=NEWTON) | |
Constructor defining a multi-variable problem. More... | |
NLASSolver (MyNLAS &my_nlas, NonLinearIter nl=NEWTON) | |
Constructor using a user defined class. More... | |
~NLASSolver () | |
Destructor. | |
void | setMaxIter (int max_it) |
Set Maximal number of iterations. More... | |
void | setTolerance (real_t toler) |
Set tolerance value for convergence. More... | |
void | set (NonLinearIter nl) |
Define an iterative procedure To be chosen among the enumerated values: BISECTION , REGULA_FALSI or NEWTON . | |
void | setNbEq (size_t nb_eq) |
Define number of equations. | |
void | setFunction (function< real_t(real_t)> f) |
Define the function associated to the equation to solve. More... | |
void | setFunction (function< Vect< real_t >(Vect< real_t >)> f) |
Define the function associated to the equation to solve. More... | |
void | setGradient (function< real_t(real_t)> g) |
Define the function associated to the derivative of the equation to solve. More... | |
void | setGradient (function< Vect< real_t >(Vect< real_t >)> g) |
Define the function associated to the gradient of the equation to solve. More... | |
void | setf (string exp) |
Set function for which zero is sought (case of one equation) More... | |
void | setDf (string exp, size_t i=1, size_t j=1) |
Set pzrtial derivative of function for which zero is sought (case of many equations) More... | |
void | setPDE (Equa &eq) |
Define a PDE. More... | |
void | setInitial (Vect< real_t > &u) |
Set initial guess for the iterations. More... | |
void | setInitial (real_t &x) |
Set initial guess for a unique unknown. More... | |
void | setInitial (real_t a, real_t b) |
Set initial guesses bisection or Regula falsi algorithms. More... | |
int | run () |
Run the solution procedure. | |
real_t | get () const |
Return solution (Case of a scalar equation) | |
void | get (Vect< real_t > &u) const |
Return solution (case of a nonlinear system of equations) More... | |
int | getNbIter () const |
Return number of iterations. | |
To solve a system of nonlinear algebraic equations of the form f(u) = 0.
Features:
NLASSolver | ( | NonLinearIter | nl, |
size_t | nb_eq = 1 |
||
) |
Constructor defining the iterative method to solve the equation.
[in] | nl | Choose an iterative procedure to solve the nonlinear system of equations: To be chosen among the enumerated values: BISECTION , REGULA_FALSI or NEWTON . |
[in] | nb_eq | Number of equations [Default: 1 ] |
NLASSolver | ( | real_t & | x, |
NonLinearIter | nl = NEWTON |
||
) |
Constructor defining a one-variable problem.
[in] | x | Variable containing on input initial guess and on output solution, if convergence is achieved |
[in] | nl | Iterative procedure to solve the nonlinear system of equations: To be chosen among the enumerated values: BISECTION , REGULA_FALSI or NEWTON . |
NLASSolver | ( | Vect< real_t > & | x, |
NonLinearIter | nl = NEWTON |
||
) |
Constructor defining a multi-variable problem.
[in] | x | Variable containing on input initial guess and on output solution, if convergence is achieved |
[in] | nl | Iterative procedure to solve the nonlinear system of equations: The only possible value (default one) in the current version is NEWTON . |
NLASSolver | ( | MyNLAS & | my_nlas, |
NonLinearIter | nl = NEWTON |
||
) |
Constructor using a user defined class.
[in] | my_nlas | Reference to instance of user defined class. This class inherits from abstract class MyNLAS. It must contain the member function Vect<double> Function(const Vect<double>& x) which returns the value of the nonlinear function, as a vector, for a given solution vector x . The user defined class must contain, if the iterative scheme requires it the member function Vect<double> Gradient(const Vect<real_t>& x) which returns the gradient as a n*n vector, each index (i,j) containing the j-th partial derivative of the i-th function. |
[in] | nl | Iterative procedure to solve the nonlinear system of equations: To be chosen among the enumerated values: BISECTION , REGULA_FALSI or NEWTON . |
Return solution (case of a nonlinear system of equations)
[out] | u | Vector that contains on output the solution |
void setDf | ( | string | exp, |
size_t | i = 1 , |
||
size_t | j = 1 |
||
) |
Set pzrtial derivative of function for which zero is sought (case of many equations)
[in] | exp | Regular expression defining the partial derivative. In this expression, the variables are x1 , x2 , ... x10 (up to 10 variables) |
[in] | i | Component of function [Default: =1 ] |
[in] | j | Index of the partial derivative [Default: =1 ] |
void setf | ( | string | exp | ) |
Set function for which zero is sought (case of one equation)
[in] | exp | Regular expression defining the function using the symbol x as a variable |
Define the function associated to the equation to solve.
This function can be used in the case where a user defined function is to be given. To be used in the one-variable case.
[in] | f | Function given as a function of one real variable and returning a real number. This function can be defined by the calling program as a C-function and then cast to an instance of class function |
Define the function associated to the equation to solve.
This function can be used in the case where a user defined function is to be given.
[in] | f | Function given as a function of many variables, stored in an input vector, and returns a vector. This function can be defined by the calling program as a C-function and then cast to an instance of class function |
Define the function associated to the derivative of the equation to solve.
[in] | g | Function given as a function of one real variable and returning a real number. This function can be defined by the calling program as a C-function and then cast to an instance of class function |
Define the function associated to the gradient of the equation to solve.
[in] | g | Function given as a function of many variables, stored in an input vector. and returns a n*n vector (n is the number of variables). This function can be defined by the calling program as a C-function and then cast to an instance of class function |
Set initial guess for the iterations.
[in] | u | Vector containing initial guess for the unknown |
void setInitial | ( | real_t & | x | ) |
Set initial guess for a unique unknown.
[in] | x | Rference to value of initial guess |
Set initial guesses bisection or Regula falsi algorithms.
[in] | a | Value of first initial guess |
[in] | b | Value of second initial guess |
i.e.
f(a)f(b)<0. void setMaxIter | ( | int | max_it | ) |
Set Maximal number of iterations.
Default value of this parameter is 100
void setPDE | ( | Equa & | eq | ) |
Define a PDE.
The solver can be used to solve a nonlinear PDE. In this case, the PDE is defined as an instance of a class inheriting of Equa.
[in] | eq | Pointer to equation instance |
void setTolerance | ( | real_t | toler | ) |
Set tolerance value for convergence.
Default value of this parameter is 1.e-8