ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
broyden.h
1 /*
2  * This source code is part of
3  *
4  * E R K A L E
5  * -
6  * DFT from Hel
7  *
8  * Written by Susi Lehtola, 2010-2011
9  * Copyright (c) 2010-2011, Susi Lehtola
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  */
16 
17 
38 #ifndef ERKALE_BROYDEN
39 #define ERKALE_BROYDEN
40 
41 #include "global.h"
42 
43 #include <armadillo>
44 #include <vector>
45 
47 class Broyden {
49  std::vector<arma::vec> x;
51  std::vector<arma::vec> f;
52 
54  bool difficult;
56  bool verbose;
57 
59  size_t m;
61  double beta;
63  double sigma;
64 
65  public:
67  Broyden(bool verbose=true, size_t m=10, double beta=0.8, double sigma=0.25);
69  ~Broyden();
70 
72  void push_x(const arma::vec & x);
74  void push_f(const arma::vec & f);
75 
77  void clear();
78 
80  arma::vec update_x();
82  arma::vec operate_G(const arma::vec & v, size_t ind) const;
83 };
84 
85 #endif
86 
~Broyden()
Destructor.
Definition: broyden.cpp:29
size_t m
Number of matrices to keep in memory.
Definition: broyden.h:59
Broyden convergence accelerator.
Definition: broyden.h:47
arma::vec update_x()
Get estimate for solution.
Definition: broyden.cpp:62
bool difficult
Difficulties encountered? (Halve mixing parameter for this step)
Definition: broyden.h:54
bool verbose
Verbose operation? (Complain about bad updates?)
Definition: broyden.h:56
arma::vec operate_G(const arma::vec &v, size_t ind) const
Operate on vector with estimated inverse Jacobian.
Definition: broyden.cpp:93
Broyden(bool verbose=true, size_t m=10, double beta=0.8, double sigma=0.25)
Construct accelerator storing m iterations and with mixing parameters beta and sigma.
Definition: broyden.cpp:21
double beta
Damping parameter.
Definition: broyden.h:61
void clear()
Clean old matrices from memory.
Definition: broyden.cpp:111
void push_f(const arma::vec &f)
Add difference from SCF solution to stack.
Definition: broyden.cpp:36
double sigma
Sigma parameter.
Definition: broyden.h:63
std::vector< arma::vec > f
Stack of differences from SCF solution.
Definition: broyden.h:51
void push_x(const arma::vec &x)
Add solutions of SCF equation to stack.
Definition: broyden.cpp:32
std::vector< arma::vec > x
Stack of approximate solutions.
Definition: broyden.h:49