GQCP
Loading...
Searching...
No Matches
RHFDensityMatrixDamper.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
24#include "QCModel/HF/RHF.hpp"
25
26
27namespace GQCP {
28
29
35template <typename _Scalar>
37 public Step<RHFSCFEnvironment<_Scalar>> {
38
39public:
40 using Scalar = _Scalar;
42
43
44private:
45 ConstantDamper damper; // The damping accelerator.
46
47
48public:
49 /*
50 * CONSTRUCTORS
51 */
52
57 damper {alpha} {}
58
59
60 /*
61 * PUBLIC OVERRIDDEN METHODS
62 */
63
67 std::string description() const override {
68 return "Replace the most recent density matrix with an accelerated one.";
69 }
70
71
77 void execute(Environment& environment) override {
78
79 if (environment.density_matrices.size() < 2) {
80 return; // No acceleration is possible.
81 }
82
83 // Get the two most recent density matrices and produce an accelerated density matrix.
84 const auto second_to_last_it = environment.density_matrices.end() - 2;
85 const auto& D_previous = *second_to_last_it; // Dereference the iterator.
86 const auto D_current = environment.density_matrices.back();
87
88 const auto D_accelerated = this->damper.accelerate(D_current, D_previous);
89 environment.density_matrices.pop_back(); // We will replace the most recent density matrix with the accelerated one, so remove the most recent one.
90 environment.density_matrices.push_back(D_accelerated);
91 }
92};
93
94
95} // namespace GQCP
Definition: ConstantDamper.hpp:27
Subject accelerate(const Subject &last, const Subject &next_to_last)
Definition: ConstantDamper.hpp:64
Definition: RHFDensityMatrixDamper.hpp:37
_Scalar Scalar
Definition: RHFDensityMatrixDamper.hpp:40
RHFDensityMatrixDamper(const double alpha)
Definition: RHFDensityMatrixDamper.hpp:56
std::string description() const override
Definition: RHFDensityMatrixDamper.hpp:67
void execute(Environment &environment) override
Definition: RHFDensityMatrixDamper.hpp:77
Definition: RHFSCFEnvironment.hpp:45
std::deque< Orbital1DM< Scalar > > density_matrices
Definition: RHFSCFEnvironment.hpp:60
Definition: Step.hpp:37
Definition: BaseOneElectronIntegralBuffer.hpp:25
@ alpha
Definition: Spin.hpp:28