votca 2024.2-dev
Loading...
Searching...
No Matches
IncrementalFockBuilder.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#pragma once
21#ifndef VOTCA_XTP_INCREMENTALFOCKBUILDER_H
22#define VOTCA_XTP_INCREMENTALFOCKBUILDER_H
23
24#include "votca/xtp/logger.h"
25#include <votca/tools/types.h>
26namespace votca {
27namespace xtp {
28
29// Small Wrapper class to build incremental fock matrix
31 public:
32 IncrementalFockBuilder(Logger& log, double start_threshold,
33 Index fock_matrix_reset)
34 : log_(log),
35 start_incremental_F_threshold_(start_threshold),
36 fock_matrix_reset_(fock_matrix_reset) {}
37
38 void Configure(const Eigen::MatrixXd& dmat) {
39 Ddiff_ = dmat;
40 Dlast_ = dmat;
41 }
42
43 void Start(Index iteration, double DiisError) {
48 last_reset_iteration_ = iteration - 1;
49 next_reset_threshold_ = DiisError / 10.0;
51 << TimeStamp() << " Using incremental 4c build from here"
52 << std::flush;
53 }
54 }
55
56 void resetMatrices(Eigen::MatrixXd& J, Eigen::MatrixXd& K,
57 const Eigen::MatrixXd& dmat) {
59 J.setZero();
60 K.setZero();
61 Ddiff_ = dmat;
62 }
63 }
64
65 const Eigen::MatrixXd& getDmat_diff() const { return Ddiff_; }
66
67 void UpdateCriteria(double DiisError, Index Iteration) {
70 last_reset_iteration_ = Iteration;
71 next_reset_threshold_ = DiisError / 10.0;
73 << TimeStamp() << " Reset incremental 4c build" << std::flush;
74 }
75 }
76
77 void UpdateDmats(const Eigen::MatrixXd& dmat, double DiisError,
78 Index Iteration) {
79 if (DiisError < next_reset_threshold_ ||
82 }
83 Ddiff_ = dmat - Dlast_;
84 Dlast_ = dmat;
85 }
86
87 private:
89 double start_incremental_F_threshold_; // Diis error from which to start
90 // using incremental builds
91 Index fock_matrix_reset_; // After how many iterations the fock matrix should
92 // be reset regardless
93
94 Eigen::MatrixXd Ddiff_;
95 Eigen::MatrixXd Dlast_;
96
101}; // namespace xtp
102
103} // namespace xtp
104} // namespace votca
105
106#endif // VOTCA_XTP_INCREMENTALFOCKBUILDER_H
void UpdateDmats(const Eigen::MatrixXd &dmat, double DiisError, Index Iteration)
void Configure(const Eigen::MatrixXd &dmat)
void resetMatrices(Eigen::MatrixXd &J, Eigen::MatrixXd &K, const Eigen::MatrixXd &dmat)
IncrementalFockBuilder(Logger &log, double start_threshold, Index fock_matrix_reset)
void Start(Index iteration, double DiisError)
void UpdateCriteria(double DiisError, Index Iteration)
const Eigen::MatrixXd & getDmat_diff() const
Logger is used for thread-safe output of messages.
Definition logger.h:164
Timestamp returns the current time as a string Example: cout << TimeStamp()
Definition logger.h:224
#define XTP_LOG(level, log)
Definition logger.h:40
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26