ergo
mat::TC2< Treal, Tmatrix > Class Template Reference

Trace correcting purification. More...

#include <TC2.h>

Classes

class  Fun
 Help class for bisection root finding calls. More...
 

Public Member Functions

 TC2 (Tmatrix &F, Tmatrix &DM, const int size, const int noc, const Treal trunc=0, const int maxmm=100)
 Constructor Initializes everything. More...
 
Treal fermi_level (Treal tol=1e-15) const
 Returns the Fermi level. More...
 
Treal homo (Treal tol=1e-15) const
 Returns upper bound of the HOMO eigenvalue. More...
 
Treal lumo (Treal tol=1e-15) const
 Returns lower bound of the LUMO eigenvalue. More...
 
int n_multiplies () const
 Returns the number of used matrix matrix multiplications. More...
 
void print_data (int const start, int const stop) const
 
virtual ~TC2 ()
 Destructor. More...
 

Protected Member Functions

void purify ()
 Runs purification. More...
 

Protected Attributes

Tmatrix & X
 Fock / Kohn-Sham matrix at initialization. More...
 
Tmatrix & D
 Density matrix after purification. More...
 
const int n
 System size. More...
 
const int nocc
 Number of occupied orbitals. More...
 
const Treal frob_trunc
 Threshold for the truncation. More...
 
const int maxmul
 Number of tolerated matrix multiplications. More...
 
Treal lmin
 Lower bound for eigenvalue spectrum. More...
 
Treal lmax
 Upper bound for eigenvalue spectrum. More...
 
int nmul
 Number of used matrix multiplications. More...
 
int nmul_firstpart
 Number of used matrix multiplications in the first part of the purification. More...
 
Treal * idemerror
 Upper bound of euclidean norm ||D-D^2||_2 before each step. More...
 
Treal * tracediff
 The difference between the trace of the matrix and the number of occupied orbitals before each step. More...
 
int * polys
 Choices of polynomials 0 for x^2 and 1 for 2x-x^2 Length: nmul. More...
 

Detailed Description

template<typename Treal, typename Tmatrix>
class mat::TC2< Treal, Tmatrix >

Trace correcting purification.

This template instantiates the trace correcting purification algorithm developed by Niklasson [Phys. Rev. B 66, 155115 (2002)] with modifications by Rubensson and Rudberg [unpublished]. The template can be used with any matrix class Tmatrix that has the following member functions:

  • gershgorin(Treal&, Treal&) const
  • add_identity(Treal)
  • operator*=(Treal)
  • operator=(Tmatrix const &)
  • trace() const
  • frob_thresh(Treal)

The matrix class should also support the following syntax:

  • A = alpha * B * B
  • A = alpha * B * B + beta * A

where A and B are of type Tmatrix and alpha and beta are of type Treal.

Constructor & Destructor Documentation

◆ TC2()

template<typename Treal , typename Tmatrix >
mat::TC2< Treal, Tmatrix >::TC2 ( Tmatrix &  F,
Tmatrix &  DM,
const int  size,
const int  noc,
const Treal  trunc = 0,
const int  maxmm = 100 
)

Constructor Initializes everything.

Constructor.

< Run purification

Parameters
FFock/Kohn-Sham matrix (input/workspace)
DMDensity matrix (output)
sizeSystem size (Number of basis functions)
nocNumber of occupied orbitals.
truncThreshold for truncation in Frobenius norm.
maxmmMaximum aloud number of mm-multiplications.

References mat::TC2< Treal, Tmatrix >::D, mat::TC2< Treal, Tmatrix >::frob_trunc, mat::TC2< Treal, Tmatrix >::idemerror, mat::TC2< Treal, Tmatrix >::lmax, mat::TC2< Treal, Tmatrix >::lmin, mat::TC2< Treal, Tmatrix >::maxmul, mat::TC2< Treal, Tmatrix >::nocc, mat::TC2< Treal, Tmatrix >::polys, mat::TC2< Treal, Tmatrix >::purify(), mat::TC2< Treal, Tmatrix >::tracediff, and mat::TC2< Treal, Tmatrix >::X.

◆ ~TC2()

template<typename Treal , typename Tmatrix >
virtual mat::TC2< Treal, Tmatrix >::~TC2 ( )
inlinevirtual

Member Function Documentation

◆ fermi_level()

template<typename Treal , typename Tmatrix >
Treal mat::TC2< Treal, Tmatrix >::fermi_level ( Treal  tol = 1e-15) const

Returns the Fermi level.

Run after call to purify().

Parameters
tolFault-tolerance for result.

References mat::bisection().

◆ homo()

template<typename Treal , typename Tmatrix >
Treal mat::TC2< Treal, Tmatrix >::homo ( Treal  tol = 1e-15) const

Returns upper bound of the HOMO eigenvalue.

Run after call to purify().

Parameters
tolFault-tolerance for result.

References mat::bisection(), and template_blas_sqrt().

◆ lumo()

template<typename Treal , typename Tmatrix >
Treal mat::TC2< Treal, Tmatrix >::lumo ( Treal  tol = 1e-15) const

Returns lower bound of the LUMO eigenvalue.

Run after call to purify().

Parameters
tolFault-tolerance for result.

References mat::bisection(), and template_blas_sqrt().

◆ n_multiplies()

template<typename Treal , typename Tmatrix >
int mat::TC2< Treal, Tmatrix >::n_multiplies ( ) const
inline

Returns the number of used matrix matrix multiplications.

References mat::TC2< Treal, Tmatrix >::nmul.

◆ print_data()

template<typename Treal , typename Tmatrix >
void mat::TC2< Treal, Tmatrix >::print_data ( int const  start,
int const  stop 
) const

◆ purify()

template<typename Treal , typename Tmatrix >
void mat::TC2< Treal, Tmatrix >::purify
protected

Runs purification.

Run by constructor.

References template_blas_sqrt().

Referenced by mat::TC2< Treal, Tmatrix >::TC2().

Member Data Documentation

◆ D

template<typename Treal , typename Tmatrix >
Tmatrix& mat::TC2< Treal, Tmatrix >::D
protected

Density matrix after purification.

Referenced by mat::TC2< Treal, Tmatrix >::TC2().

◆ frob_trunc

template<typename Treal , typename Tmatrix >
const Treal mat::TC2< Treal, Tmatrix >::frob_trunc
protected

Threshold for the truncation.

Referenced by mat::TC2< Treal, Tmatrix >::TC2().

◆ idemerror

template<typename Treal , typename Tmatrix >
Treal* mat::TC2< Treal, Tmatrix >::idemerror
protected

Upper bound of euclidean norm ||D-D^2||_2 before each step.

This means: idemerror[i] = norm(D[i]-D[i]^2) where D[0] is the initial matrix and D[i] is the matrix after i steps in the purification. This value is calculated after the step since D[i]^2 or 2D[i] - D[i]^2 is needed. Length: nmul

Referenced by mat::TC2< Treal, Tmatrix >::TC2(), and mat::TC2< Treal, Tmatrix >::~TC2().

◆ lmax

template<typename Treal , typename Tmatrix >
Treal mat::TC2< Treal, Tmatrix >::lmax
protected

Upper bound for eigenvalue spectrum.

Referenced by mat::TC2< Treal, Tmatrix >::TC2().

◆ lmin

template<typename Treal , typename Tmatrix >
Treal mat::TC2< Treal, Tmatrix >::lmin
protected

Lower bound for eigenvalue spectrum.

Referenced by mat::TC2< Treal, Tmatrix >::TC2().

◆ maxmul

template<typename Treal , typename Tmatrix >
const int mat::TC2< Treal, Tmatrix >::maxmul
protected

Number of tolerated matrix multiplications.

Referenced by mat::TC2< Treal, Tmatrix >::TC2().

◆ n

template<typename Treal , typename Tmatrix >
const int mat::TC2< Treal, Tmatrix >::n
protected

System size.

◆ nmul

template<typename Treal , typename Tmatrix >
int mat::TC2< Treal, Tmatrix >::nmul
protected

Number of used matrix multiplications.

Referenced by mat::TC2< Treal, Tmatrix >::n_multiplies().

◆ nmul_firstpart

template<typename Treal , typename Tmatrix >
int mat::TC2< Treal, Tmatrix >::nmul_firstpart
protected

Number of used matrix multiplications in the first part of the purification.

◆ nocc

template<typename Treal , typename Tmatrix >
const int mat::TC2< Treal, Tmatrix >::nocc
protected

Number of occupied orbitals.

Referenced by mat::TC2< Treal, Tmatrix >::TC2().

◆ polys

template<typename Treal , typename Tmatrix >
int* mat::TC2< Treal, Tmatrix >::polys
protected

Choices of polynomials 0 for x^2 and 1 for 2x-x^2 Length: nmul.

Referenced by mat::TC2< Treal, Tmatrix >::TC2(), and mat::TC2< Treal, Tmatrix >::~TC2().

◆ tracediff

template<typename Treal , typename Tmatrix >
Treal* mat::TC2< Treal, Tmatrix >::tracediff
protected

The difference between the trace of the matrix and the number of occupied orbitals before each step.

Length: nmul + 1

Referenced by mat::TC2< Treal, Tmatrix >::TC2(), and mat::TC2< Treal, Tmatrix >::~TC2().

◆ X

template<typename Treal , typename Tmatrix >
Tmatrix& mat::TC2< Treal, Tmatrix >::X
protected

Fock / Kohn-Sham matrix at initialization.

Then used as workspace by purify(). Empty after call to purify().

Referenced by mat::TC2< Treal, Tmatrix >::TC2().


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