DFT-EFE
 
Loading...
Searching...
No Matches
dftefe::linearAlgebra::BisectionSolver< ValueType > Class Template Reference

A class that implements the bisection method to find the root of a function, given an interval known to bracket it. Unlike NewtonRaphsonSolver, bisection only ever evaluates getValue() (never a derivative), so it cannot diverge - each iteration halves the bracket that is guaranteed to contain the root. This makes it a safe way to localize a root before handing off to NewtonRaphsonSolver for fast final convergence, mirroring DFT-FE's Fermi energy solver (src/dft/fermiEnergy.cc), which bisects before running Newton-Raphson. More...

#include <BisectionSolver.h>

Public Member Functions

 BisectionSolver (const size_type maxIter, const double tolerance)
 Constructor. More...
 
 ~BisectionSolver ()=default
 Default Destructor. More...
 
BisectionError solve (BisectionSolverFunction< ValueType > &bisectionSolverFunction)
 Function that initiates the bisection solve. More...
 

Private Attributes

size_type d_maxIter
 
double d_tolerance
 
bool d_isSolved
 

Detailed Description

template<typename ValueType>
class dftefe::linearAlgebra::BisectionSolver< ValueType >

A class that implements the bisection method to find the root of a function, given an interval known to bracket it. Unlike NewtonRaphsonSolver, bisection only ever evaluates getValue() (never a derivative), so it cannot diverge - each iteration halves the bracket that is guaranteed to contain the root. This makes it a safe way to localize a root before handing off to NewtonRaphsonSolver for fast final convergence, mirroring DFT-FE's Fermi energy solver (src/dft/fermiEnergy.cc), which bisects before running Newton-Raphson.

This is a minimal, textbook bisection: it trusts getLowerBound()/getUpperBound() to already bracket a root and does not attempt to expand or otherwise fix a bad bracket. Both bisection itself and any bracket construction/expansion on top of it are only correct if getValue() is monotonic between the bracket ends - a property of the specific function being solved (e.g. an isolated Fermi-Dirac occupancy sum is provably monotonic; an arbitrary function need not be), not something this generic solver can verify. Any such domain-specific bracket handling belongs in the BisectionSolverFunction implementation, not here.

Template Parameters
ValueTypeThe datatype (float, double, etc.)

Constructor & Destructor Documentation

◆ BisectionSolver()

template<typename ValueType >
dftefe::linearAlgebra::BisectionSolver< ValueType >::BisectionSolver ( const size_type  maxIter,
const double  tolerance 
)

Constructor.

Parameters
[in]maxIterMaximum number of bisection iterations.
[in]toleranceConvergence tolerance on |getValue(x)| at the bisected midpoint.

◆ ~BisectionSolver()

template<typename ValueType >
dftefe::linearAlgebra::BisectionSolver< ValueType >::~BisectionSolver ( )
default

Default Destructor.

Member Function Documentation

◆ solve()

template<typename ValueType >
BisectionError dftefe::linearAlgebra::BisectionSolver< ValueType >::solve ( BisectionSolverFunction< ValueType > &  bisectionSolverFunction)

Function that initiates the bisection solve.

Parameters
[in]bisectionSolverFunction
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ d_isSolved

template<typename ValueType >
bool dftefe::linearAlgebra::BisectionSolver< ValueType >::d_isSolved
private

◆ d_maxIter

template<typename ValueType >
size_type dftefe::linearAlgebra::BisectionSolver< ValueType >::d_maxIter
private

◆ d_tolerance

template<typename ValueType >
double dftefe::linearAlgebra::BisectionSolver< ValueType >::d_tolerance
private

The documentation for this class was generated from the following files: