SIRIUS 7.5.0
Electronic structure library and applications
historylist.hpp
Go to the documentation of this file.
1/**
2 * @file historylist.hpp
3 * @author Moritz Gubler (moritz.gubler@unibas.ch)
4 * @brief Implementation of the SQNM method. More informations about the algorithm can be found here: https://aip.scitation.org/doi/10.1063/1.4905665
5 * @date 2022-07-13
6 *
7 */
8
9#ifndef HISTORYLIST_HPP
10#define HISTORYLIST_HPP
11#include <Eigen/Dense>
12
13namespace vcsqnm {
14
15namespace hlist_space{
17 private:
18 int i_count = 0;
19 int nhistx;
20 int ndim;
21 Eigen::VectorXd oldElem;
22
23 public:
24
25 Eigen::MatrixXd hlist;
26 Eigen::MatrixXd difflist;
27 Eigen::MatrixXd normalized_difflist;
28
29
30 HistoryList(int &ndim_, int &nhistx_)
31 {
32 nhistx = nhistx_;
33 ndim = ndim_;
34 hlist.resize(ndim, nhistx);
35 difflist.resize(ndim, nhistx);
36 normalized_difflist.resize(ndim, nhistx);
37 i_count = 0;
38 }
39
40 int add(Eigen::VectorXd &x_in)
41 {
42 if (i_count < nhistx){
43 hlist.col(i_count) = x_in;
44 i_count += 1;
45 for (int i = 1; i < i_count; i++){
46 difflist.col(i-1) = hlist.col(i) - hlist.col(i - 1);
47 normalized_difflist.col(i-1) = difflist.col(i-1) / difflist.col(i-1).norm();
48 }
49 return i_count - 1;
50 } else {
51 oldElem = hlist.col(0);
52 for (int i = 0; i < nhistx - 1; i++){
53 hlist.col(i) = hlist.col(i+1);
54 }
55 hlist.col(nhistx - 1) = x_in;
56 // calculate difference list
57 difflist.col(0) = hlist.col(0) - oldElem;
58 normalized_difflist.col(0) = difflist.col(0) / difflist.col(0).norm();
59 for (int i = 1; i < nhistx; i++){
60 difflist.col(i) = hlist.col(i) - hlist.col(i - 1);
61 normalized_difflist.col(i) = difflist.col(i) / difflist.col(i).norm();
62 }
63 return nhistx;
64 }
65 }
66 };
67}
68
69}
70
71#endif
Variable cell stable quasi-Newton lattice optimizer.
Definition: historylist.hpp:13