GQCP
Loading...
Searching...
No Matches
HubbardHamiltonian.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
25
26
27namespace GQCP {
28
29
35template <typename _Scalar>
37public:
38 // The scalar type for a Hubbard Hamiltonian matrix element.
39 using Scalar = _Scalar;
40
41
42private:
43 // The Hubbard Hamiltonian matrix.
44 HoppingMatrix<Scalar> hopping_matrix;
45 SquareMatrix<Scalar> U_matrix;
46 SquareMatrix<Scalar> mu_matrix;
47
48
49public:
50 /*
51 * MARK: Constructors
52 */
53
62 hopping_matrix {H},
63 U_matrix {U},
64 mu_matrix {mu} {
65
66 const SquareMatrix<Scalar> total = this->hopping_matrix.matrix() + this->U_matrix + this->mu_matrix;
67
68 if (!total.isHermitian()) {
69 throw std::invalid_argument("HubbardHamiltonian::HubbardHamiltonian(const HoppingMatrix<Scalar>&, const SquareMatrix<Scalar>&, const SquareMatrix<Scalar>&): The total Hubbard Hamiltonian matrix must be Hermitian.");
70 }
71 }
72
73
81 HubbardHamiltonian(const HoppingMatrix<Scalar>& H, const double& U, const double& mu = 0.0) :
82 hopping_matrix {H},
83 U_matrix {SquareMatrix<double>::Identity(H.matrix().dimension())},
84 mu_matrix {SquareMatrix<double>::Identity(H.matrix().dimension())} {
85
86 // Fill in the on-site repulsion on the diagonal.
87 for (size_t i = 0; i < H.matrix().dimension(); i++) {
88 this->U_matrix(i, i) *= U;
89 this->mu_matrix(i, i) *= mu;
90 }
91 }
92
93
101 HubbardHamiltonian(const HoppingMatrix<Scalar>& H, const std::vector<double>& U, const std::vector<double>& mu) :
102 hopping_matrix {H},
103 U_matrix {SquareMatrix<double>::Identity(H.matrix().dimension())},
104 mu_matrix {SquareMatrix<double>::Identity(H.matrix().dimension())} {
105
106 // Fill in the given vectors.
107 for (size_t i = 0; i < U.size(); i++) {
108 this->U_matrix(i, i) *= U[i];
109 this->mu_matrix(i, i) *= mu[i];
110 }
111 }
112
113
114 /*
115 * MARK: Named constructors
116 */
117
128 template <typename Z = Scalar>
130 // prepare the empty matrices.
131 auto mu = SquareMatrix<double>::Zero(K);
132 auto hopping = SquareMatrix<double>::Zero(K);
133 auto U = SquareMatrix<double>::Zero(K);
134
135 // Generate a random matrix.
136 const auto hopping_plus_u = SquareMatrix<double>::RandomSymmetric(K);
137
138 // Distribute the random matrix values correctly between the component matrices.
139 for (size_t p = 0; p < K; p++) {
140 for (size_t q = p; q < K; q++) {
141 if (p != q) {
142 hopping(p, q) = hopping_plus_u(p, q);
143 hopping(q, p) = hopping_plus_u(q, p);
144 } else if (p == q) {
145 U(p, q) = hopping_plus_u(p, q);
146 }
147 }
148 }
149
150 return HubbardHamiltonian {HoppingMatrix<double> {hopping}, U, mu};
151 }
152
153
154 /*
155 * MARK: Integral access
156 */
157
163 template <typename Z = Scalar>
165
166 // Prepare some variables.
167 const auto K = this->numberOfLatticeSites();
168 const auto& H = this->oneElectronContributions();
170
171 // The one-electron hopping terms can be found on the off-diagonal elements of the hopping matrix.
172 for (size_t p = 0; p < K; p++) {
173 for (size_t q = p; q < K; q++) {
174 h.parameters()(p, q) = H(p, q);
175 h.parameters()(q, p) = H(q, p);
176 }
177 }
178
179 return h;
180 }
181
182
188 template <typename Z = Scalar>
190
191 const auto K = this->numberOfLatticeSites();
192 const auto& H = this->onSiteRepulsionMatrix();
194
195 // The two-electron on-site repulsion is found on the diagonal of the hopping matrix.
196 for (size_t p = 0; p < K; p++) {
197 g_par(p, p, p, p) = H(p, p);
198 }
199
201 }
202
203
204 /*
205 * MARK: General information
206 */
207
211 const HoppingMatrix<Scalar>& hoppingMatrix() const { return this->hopping_matrix; }
212
213
217 size_t numberOfLatticeSites() const { return this->hopping_matrix.matrix().dimension(); }
218
219
224 return this->hopping_matrix.matrix() + this->mu_matrix;
225 }
226
227
231 const SquareMatrix<Scalar>& onSitePotentialMatrix() const { return this->mu_matrix; }
232
233
237 const SquareMatrix<Scalar>& onSiteRepulsionMatrix() const { return this->U_matrix; }
238};
239
240
241} // namespace GQCP
Definition: HoppingMatrix.hpp:34
const SquareMatrix< Scalar > & matrix() const
Definition: HoppingMatrix.hpp:160
Definition: HubbardHamiltonian.hpp:36
const SquareMatrix< Scalar > & onSiteRepulsionMatrix() const
Definition: HubbardHamiltonian.hpp:237
enable_if_t< std::is_same< Z, double >::value, ScalarRSQTwoElectronOperator< double > > twoElectron() const
Definition: HubbardHamiltonian.hpp:189
HubbardHamiltonian(const HoppingMatrix< Scalar > &H, const SquareMatrix< Scalar > &U, const SquareMatrix< Scalar > &mu)
Definition: HubbardHamiltonian.hpp:61
const HoppingMatrix< Scalar > & hoppingMatrix() const
Definition: HubbardHamiltonian.hpp:211
size_t numberOfLatticeSites() const
Definition: HubbardHamiltonian.hpp:217
enable_if_t< std::is_same< Z, double >::value, ScalarRSQOneElectronOperator< double > > core() const
Definition: HubbardHamiltonian.hpp:164
const SquareMatrix< Scalar > & onSitePotentialMatrix() const
Definition: HubbardHamiltonian.hpp:231
HubbardHamiltonian(const HoppingMatrix< Scalar > &H, const std::vector< double > &U, const std::vector< double > &mu)
Definition: HubbardHamiltonian.hpp:101
const SquareMatrix< Scalar > oneElectronContributions() const
Definition: HubbardHamiltonian.hpp:223
_Scalar Scalar
Definition: HubbardHamiltonian.hpp:39
static enable_if_t< std::is_same< Z, double >::value, HubbardHamiltonian< double > > Random(const size_t K)
Definition: HubbardHamiltonian.hpp:129
HubbardHamiltonian(const HoppingMatrix< Scalar > &H, const double &U, const double &mu=0.0)
Definition: HubbardHamiltonian.hpp:81
Definition: RSQOneElectronOperator.hpp:42
Definition: RSQTwoElectronOperator.hpp:43
static FinalOperator Zero(const size_t dim, const Vectorizer &vectorizer)
Definition: SQOperatorStorageBase.hpp:145
Definition: SquareMatrix.hpp:39
size_t dimension() const
Definition: SquareMatrix.hpp:299
bool isHermitian(const double threshold=1.0e-08) const
Definition: SquareMatrix.hpp:311
static Self Zero(const size_t dim)
Definition: SquareMatrix.hpp:289
static Self RandomSymmetric(const size_t dim)
Definition: SquareMatrix.hpp:201
Definition: SquareRankFourTensor.hpp:36
static Self Zero(const size_t dim)
Definition: SquareRankFourTensor.hpp:147
Definition: BaseOneElectronIntegralBuffer.hpp:25
typename std::enable_if< B, T >::type enable_if_t
Definition: type_traits.hpp:37