GQCP
Loading...
Searching...
No Matches
UHFErrorCalculation.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
23#include "QCModel/HF/UHF.hpp"
24
25
26namespace GQCP {
27
28
34template <typename _Scalar>
36 public Step<UHFSCFEnvironment<_Scalar>> {
37
38public:
39 using Scalar = _Scalar;
41
42
43public:
44 /*
45 * PUBLIC OVERRIDDEN METHODS
46 */
47
51 std::string description() const override {
52 return "Calculate the current alpha- and beta- error vectors and add them to the environment.";
53 }
54
55
61 void execute(Environment& environment) override {
62
63 // Read F, D and S from the environment.
64 const auto& S = environment.S;
65
66 const auto& F = environment.fock_matrices.back();
67
68 const auto& D = environment.density_matrices.back();
69
70 // Calculate the errors and write them to the environment (as a vector).
71 const auto error_matrices = QCModel::UHF<Scalar>::calculateError(F, D, S);
72
73 // Transform the error matrices to error vectors.
74 const auto error_vectors = SpinResolved<VectorX<Scalar>> {error_matrices.alpha().pairWiseReduced(), error_matrices.beta().pairWiseReduced()};
75
76 environment.error_vectors.push_back(error_vectors);
77 }
78};
79
80
81} // namespace GQCP
static SpinResolved< SquareMatrix< Scalar > > calculateError(const ScalarUSQOneElectronOperator< Scalar > &F, const SpinResolved1DM< Scalar > &D, const ScalarUSQOneElectronOperator< Scalar > &S)
Definition: UHF.hpp:169
const Of & alpha() const
Definition: SpinResolvedBase.hpp:130
Definition: SpinResolved.hpp:34
Definition: Step.hpp:37
Definition: UHFErrorCalculation.hpp:36
void execute(Environment &environment) override
Definition: UHFErrorCalculation.hpp:61
_Scalar Scalar
Definition: UHFErrorCalculation.hpp:39
std::string description() const override
Definition: UHFErrorCalculation.hpp:51
Definition: UHFSCFEnvironment.hpp:45
std::deque< ScalarUSQOneElectronOperator< Scalar > > fock_matrices
Definition: UHFSCFEnvironment.hpp:63
ScalarUSQOneElectronOperator< Scalar > S
Definition: UHFSCFEnvironment.hpp:57
std::deque< SpinResolved1DM< Scalar > > density_matrices
Definition: UHFSCFEnvironment.hpp:61
std::deque< SpinResolved< VectorX< Scalar > > > error_vectors
Definition: UHFSCFEnvironment.hpp:65
Definition: BaseOneElectronIntegralBuffer.hpp:25