63 template<
typename Treal,
typename Tmatrix>
70 const Treal trunc = 0,
83 Treal
homo(Treal tol = 1e-15
88 Treal
lumo(Treal tol = 1e-15
147 template<
typename Treal,
typename Tmatrix>
150 Fun(
int const*
const p,
int const pl, Treal
const s)
152 assert(shift <= 1 && shift >= 0);
155 Treal
eval(Treal
const x)
const {
157 for (
int ind = 0; ind <
pollength; ind++ )
158 y = 2 *
pol[ind] * y + (1 - 2 *
pol[ind]) * y * y;
173 template<
typename Treal,
typename Tmatrix>
176 const Treal trunc,
const int maxmm)
184 X.add_identity(-
lmax);
195 template<
typename Treal,
typename Tmatrix>
199 Treal delta, beta, trD2;
207 "Purification reached maxmul"
208 " without convergence",
maxmul);
233 while (ind > 0 &&
polys[ind] ==
polys[ind - 1]) {
239 }
while((trD2 + beta * (1 + delta) *
n - (1 + delta + beta) *
241 ((1 + 2 * delta) * (delta + beta)) <
n -
nocc - 1 ||
242 (trD2 - delta * (1 - beta) *
n - (1 - delta - beta) *
244 ((1 + 2 * delta) * (delta + beta)) <
nocc - 1);
274 "Purification reached maxmul"
275 " without convergence",
maxmul);
314 template<
typename Treal,
typename Tmatrix>
317 Treal chempot =
bisection(fermifun, (Treal)0, (Treal)1, tol);
321 template<
typename Treal,
typename Tmatrix>
328 tmp =
bisection(homofun, (Treal)0, (Treal)1, tol);
339 template<
typename Treal,
typename Tmatrix>
346 tmp =
bisection(lumofun, (Treal)0, (Treal)1, tol);
357template<
typename Treal,
typename Tmatrix>
359 for (
int ind = start; ind < stop; ind ++) {
360 std::cout <<
"Iteration: " << ind
361 <<
" Idempotency error: " <<
idemerror[ind]
363 <<
" Poly: " <<
polys[ind]
Help class for bisection root finding calls.
Definition TC2.h:148
Treal const shift
Definition TC2.h:169
int const *const pol
Definition TC2.h:167
Fun(int const *const p, int const pl, Treal const s)
Definition TC2.h:150
Treal eval(Treal const x) const
Definition TC2.h:155
int const pollength
Definition TC2.h:168
Treal lmax
Upper bound for eigenvalue spectrum.
Definition TC2.h:115
const Treal frob_trunc
Threshold for the truncation.
Definition TC2.h:112
const int nocc
Number of occupied orbitals.
Definition TC2.h:111
Tmatrix & X
Fock / Kohn-Sham matrix at initialization.
Definition TC2.h:105
TC2(Tmatrix &F, Tmatrix &DM, const int size, const int noc, const Treal trunc=0, const int maxmm=100)
Constructor Initializes everything.
Definition TC2.h:174
const int maxmul
Number of tolerated matrix multiplications.
Definition TC2.h:113
int n_multiplies() const
Returns the number of used matrix matrix multiplications.
Definition TC2.h:94
int nmul_firstpart
Number of used matrix multiplications in the first part of the purification.
Definition TC2.h:117
virtual ~TC2()
Destructor.
Definition TC2.h:99
Treal * idemerror
Upper bound of euclidean norm ||D-D^2||_2 before each step.
Definition TC2.h:120
void print_data(int const start, int const stop) const
Definition TC2.h:358
Treal fermi_level(Treal tol=1e-15) const
Returns the Fermi level.
Definition TC2.h:315
Treal * tracediff
The difference between the trace of the matrix and the number of occupied orbitals before each step.
Definition TC2.h:129
Treal homo(Treal tol=1e-15) const
Returns upper bound of the HOMO eigenvalue.
Definition TC2.h:322
const int n
System size.
Definition TC2.h:110
int * polys
Choices of polynomials 0 for x^2 and 1 for 2x-x^2 Length: nmul.
Definition TC2.h:133
Tmatrix & D
Density matrix after purification.
Definition TC2.h:109
int nmul
Number of used matrix multiplications.
Definition TC2.h:116
Treal lumo(Treal tol=1e-15) const
Returns lower bound of the LUMO eigenvalue.
Definition TC2.h:340
void purify()
Runs purification.
Definition TC2.h:196
Treal lmin
Lower bound for eigenvalue spectrum.
Definition TC2.h:114
Definition allocate.cc:39
Treal bisection(Tfun const &fun, Treal min, Treal max, Treal const tol)
Bisection algorithm for root finding.
Definition bisection.h:70
const Treal Matrix< Treal >::ONE
Definition Matrix.h:3448
Treal template_blas_sqrt(Treal x)