RealTimeTransport 1.0.0
Real-time simulation of quantum transport processes
Loading...
Searching...
No Matches
Utility.h
Go to the documentation of this file.
1//
2// This Source Code Form is subject to the terms of the Mozilla Public
3// License, v. 2.0. If a copy of the MPL was not distributed with this
4// file, You can obtain one at https://mozilla.org/MPL/2.0/.
5//
6
7///
8/// \file Utility.h
9///
10/// \brief Contains various utility functions used throughout.
11///
12
13#ifndef REAL_TIME_TRANSPORT_UTILITY_H
14#define REAL_TIME_TRANSPORT_UTILITY_H
15
16#include <memory>
17
18#include "BlockMatrices/BlockDiagonalMatrix.h"
19#include "BlockMatrices/BlockMatrix.h"
20#include "Model.h"
22
23namespace RealTimeTransport
24{
25
26///
27/// @brief Particle-hole \f$ \eta \f$ index.
28///
29enum class Eta : int
30{
31 /// @brief \f$ \eta=- \f$
32 Minus = 0,
33
34 /// @brief \f$ \eta=+ \f$
35 Plus = 1,
36
37 _count
38};
39
40///
41/// @brief Keldysh index \f$ p \f$.
42///
43enum class Keldysh : int
44{
45 /// @brief \f$ p=- \f$
46 Minus = 0,
47
48 /// @brief \f$ p=+ \f$
49 Plus = 1,
50
51 _count
52};
53
54REALTIMETRANSPORT_EXPORT BlockMatrix computeSuperfermion(Keldysh p, Eta eta, int l, const Model* model);
55
56///
57/// \brief Computes a superfermion for a given model.
58///
59/// This function computes superfermionic creation/annihilation operators for given models.
60/// The superfermions are superoperators defined as
61/// $$
62/// D^p_{\eta l} \bullet = \frac{1}{\sqrt{2}} ( d_{\eta l} \bullet + p (-\mathbb{1})^n \bullet (-\mathbb{1})^n d_{\eta l} )
63/// $$
64/// where \f$ \bullet \f$ denotes some operator argument.
65///
66/// \param model The model for which the superfermion is computed.
67/// \param p Represents creation or annihilation.
68/// \param eta Either "-" or "+".
69/// \param l Index for internal degrees of freedom (always \f$ \geq 0 \f$ !).
70///
72 Keldysh p,
73 Eta eta,
74 int l,
75 const std::unique_ptr<Model>& model)
76{
77 return computeSuperfermion(p, eta, l, model.get());
78}
79
80REALTIMETRANSPORT_EXPORT std::vector<BlockMatrix> computeAllSuperfermions(Keldysh p, const Model* model);
81
82///
83/// @brief Computes all creation or annihilation superfermions (for p=+,- respectively) for a given model.
84///
86 Keldysh p,
87 const std::unique_ptr<Model>& model)
88{
89 return computeAllSuperfermions(p, model.get());
90}
91
92REALTIMETRANSPORT_EXPORT SciCore::Complex computeGamma(Eta eta, int r, int l1, int l2, const Model* model);
93
94///
95/// @brief Convenience function to compute \f$ \Gamma_{η r l_1 l_2} \f$.
96///
98 Eta eta,
99 int r,
100 int l1,
101 int l2,
102 const std::unique_ptr<Model>& model)
103{
104 return computeGamma(eta, r, l1, l2, model.get());
105}
106
107REALTIMETRANSPORT_EXPORT BlockDiagonalMatrix computeLiouvillian(const Model* model);
108
109///
110/// @brief Returns \f$ -i L \f$ for a given specific _model_, where \f$ L = [H, \bullet] \f$ denotes the bare
111/// Liouvillian.
112///
113REALTIMETRANSPORT_EXPORT inline BlockDiagonalMatrix computeLiouvillian(const std::unique_ptr<Model>& model)
114{
115 return computeLiouvillian(model.get());
116}
117
119 const std::vector<BlockMatrix>& superfermion,
120 const std::vector<BlockMatrix>& superfermionAnnihilation,
121 const Model* model);
122
123///
124/// @brief Returns the \f$ \delta \f$-singular part \f$ -i \Sigma_\infty \f$ of the infinite temperature memory kernel
125/// for a given fermionic wideband _model_.
126///
128 const std::vector<BlockMatrix>& superfermion,
129 const std::vector<BlockMatrix>& superfermionAnnihilation,
130 const std::unique_ptr<Model>& model)
131{
132 return computeSigmaInfty(superfermion, superfermionAnnihilation, model.get());
133}
134
135REALTIMETRANSPORT_EXPORT Model::SuperRowVectorType computeSigmaInftyCurrent(
136 int r,
137 const std::vector<BlockMatrix>& superfermionAnnihilation,
138 const Model* model);
139
140///
141/// @brief Returns the \f$ \delta \f$-singular part of the current kernel, \f$ -i \Sigma^{(I_r)}_{\infty} \f$, for a given fermionic wideband _model_.
142///
144 int r,
146 const std::unique_ptr<Model>& model)
147{
148 return computeSigmaInftyCurrent(r, superfermionAnnihilation, model.get());
149}
150
151REALTIMETRANSPORT_EXPORT std::vector<SciCore::Vector> computeZeroEigenvectors(
152 const SciCore::Matrix& A,
153 SciCore::Real tol);
154
155REALTIMETRANSPORT_EXPORT Model::OperatorType computeStationaryState(
156 const Model::SuperoperatorType& M,
157 const Model* model);
158
159REALTIMETRANSPORT_EXPORT inline Model::OperatorType computeStationaryState(
160 const Model::SuperoperatorType& M,
161 const std::unique_ptr<Model>& model)
162{
163 return computeStationaryState(M, model.get());
164}
165
166REALTIMETRANSPORT_EXPORT Model::OperatorType computeStationaryState(
167 const BlockDiagonalMatrix& M,
168 const Model* model,
169 SciCore::Real tol);
170
171REALTIMETRANSPORT_EXPORT inline Model::OperatorType computeStationaryState(
172 const BlockDiagonalMatrix& M,
173 const std::unique_ptr<Model>& model,
174 SciCore::Real tol)
175{
176 return computeStationaryState(M, model.get(), tol);
177}
178
179// Computes the stationary state corresponding to a specific block A with index blockIndex.
180// This is useful, for example, if it is known that the zero eigenvector always lives in a specific block
181// of the memory kernel.
182REALTIMETRANSPORT_EXPORT Model::OperatorType computeStationaryState(
183 const SciCore::Matrix& M,
184 const Model* model,
185 int blockIndex,
186 SciCore::Real tol);
187
188inline Model::OperatorType computeStationaryState(
189 const SciCore::Matrix& M,
190 const std::unique_ptr<Model>& model,
191 int blockIndex,
192 SciCore::Real tol)
193{
194 return computeStationaryState(M, model.get(), blockIndex, tol);
195}
196
197REALTIMETRANSPORT_EXPORT SciCore::Matrix exp(const SciCore::Matrix& X);
199
200REALTIMETRANSPORT_EXPORT SciCore::Matrix expm1(const SciCore::Matrix& X);
202
203// Converts the multi index i to a list of in total N single indices. The single index indicesList[i]
204// can have values between 0 <= indicesList[i] < dims[i].
205REALTIMETRANSPORT_EXPORT void multiIndexToList(int i, const int* dims, int N, int* indicesList) noexcept;
206REALTIMETRANSPORT_EXPORT int listToMultiIndex(const int* indicesList, const int* dims, int N) noexcept;
207
208struct REALTIMETRANSPORT_EXPORT Indices
209{
210 Eta eta;
211 int l;
212};
213
214REALTIMETRANSPORT_EXPORT int singleToMultiIndex(Eta eta, int l, const Model* model);
215
216///
217/// \brief Converts multiple single indices into a multiindex.
218///
219REALTIMETRANSPORT_EXPORT inline int singleToMultiIndex(Eta eta, int l, const std::unique_ptr<Model>& model)
220{
221 return singleToMultiIndex(eta, l, model.get());
222}
223
224REALTIMETRANSPORT_EXPORT Indices multiToSingleIndices(int i, const Model* model);
225
226///
227/// \brief Converts a multiindex into multiple single indices.
228///
229/// Transforms the multiindex \f$i\f$ into two single indices \f$\eta\f$ and \f$l\f$ which are
230/// returned as a tuple. The function can be used as
231///
232/// \code{.cpp}
233/// const auto [eta, l] = multiToSingleIndices(model, i);
234/// \endcode
235///
236REALTIMETRANSPORT_EXPORT inline Indices multiToSingleIndices(int i, const std::unique_ptr<Model>& model)
237{
238 return multiToSingleIndices(i, model.get());
239}
240
241REALTIMETRANSPORT_EXPORT SciCore::Complex gammaMinus(
242 SciCore::Real t,
243 Eta eta,
244 int l1,
245 int l2,
246 int r,
247 const Model* model);
248
249REALTIMETRANSPORT_EXPORT inline SciCore::Complex gammaMinus(
250 SciCore::Real t,
251 Eta eta,
252 int l1,
253 int l2,
254 int r,
255 const std::unique_ptr<Model>& model)
256{
257 return gammaMinus(t, eta, l1, l2, r, model.get());
258}
259
260REALTIMETRANSPORT_EXPORT SciCore::Complex gammaMinus(SciCore::Real t, Eta eta, int l1, int l2, const Model* model);
261
262REALTIMETRANSPORT_EXPORT inline SciCore::Complex gammaMinus(
263 SciCore::Real t,
264 Eta eta,
265 int l1,
266 int l2,
267 const std::unique_ptr<Model>& model)
268{
269 return gammaMinus(t, eta, l1, l2, model.get());
270}
271
272// d/dμ γ^-(t)
273REALTIMETRANSPORT_EXPORT SciCore::Complex d_dmu_gammaMinus(
274 SciCore::Real t,
275 Eta eta,
276 int l1,
277 int l2,
278 int r,
279 const Model* model);
280
281REALTIMETRANSPORT_EXPORT inline SciCore::Complex d_dmu_gammaMinus(
282 SciCore::Real t,
283 Eta eta,
284 int l1,
285 int l2,
286 int r,
287 const std::unique_ptr<Model>& model)
288{
289 return d_dmu_gammaMinus(t, eta, l1, l2, r, model.get());
290}
291
292// Computes \sum_1 gamma_1(t) * G^+_1 G^+_{\bar{1}}
293REALTIMETRANSPORT_EXPORT SciCore::Matrix computeGammaGG(
294 int blockIndex,
295 SciCore::Real t,
296 const std::vector<BlockMatrix>& superfermion,
297 const Model* model);
298
299REALTIMETRANSPORT_EXPORT inline SciCore::Matrix computeGammaGG(
300 int blockIndex,
301 SciCore::Real t,
302 const std::vector<BlockMatrix>& superfermion,
303 const std::unique_ptr<Model>& model)
304{
305 return computeGammaGG(blockIndex, t, superfermion, model.get());
306}
307
308// Computes \sum_1 gamma_1(t) * G^+_1 G^+_{\bar{1}}
310computeGammaGG(SciCore::Real t, const std::vector<BlockMatrix>& superfermion, const Model* model);
311
313 SciCore::Real t,
314 const std::vector<BlockMatrix>& superfermion,
315 const std::unique_ptr<Model>& model)
316{
317 return computeGammaGG(t, superfermion, model.get());
318}
319
320REALTIMETRANSPORT_EXPORT SciCore::RealVector defaultInitialChebSections(SciCore::Real tMax, SciCore::Real tCrit);
321
322REALTIMETRANSPORT_EXPORT SciCore::Real defaultMinChebDistance(SciCore::Real tCrit, SciCore::Real errorGoal);
323
324} // namespace RealTimeTransport
325
326#endif // REAL_TIME_TRANSPORT_UTILITY_H
#define REALTIMETRANSPORT_EXPORT
Definition RealTimeTransport_export.h:15
REALTIMETRANSPORT_EXPORT int singleToMultiIndex(Eta eta, int l, const std::unique_ptr< Model > &model)
Converts multiple single indices into a multiindex.
Definition Utility.h:219
REALTIMETRANSPORT_EXPORT BlockDiagonalMatrix computeLiouvillian(const std::unique_ptr< Model > &model)
Returns for a given specific model, where denotes the bare Liouvillian.
Definition Utility.h:113
Eta
Particle-hole index.
Definition Utility.h:30
Keldysh
Keldysh index .
Definition Utility.h:44
REALTIMETRANSPORT_EXPORT std::vector< BlockMatrix > computeAllSuperfermions(Keldysh p, const std::unique_ptr< Model > &model)
Computes all creation or annihilation superfermions (for p=+,- respectively) for a given model.
Definition Utility.h:85
REALTIMETRANSPORT_EXPORT Indices multiToSingleIndices(int i, const std::unique_ptr< Model > &model)
Converts a multiindex into multiple single indices.
Definition Utility.h:236
REALTIMETRANSPORT_EXPORT BlockMatrix computeSuperfermion(Keldysh p, Eta eta, int l, const std::unique_ptr< Model > &model)
Computes a superfermion for a given model.
Definition Utility.h:71
REALTIMETRANSPORT_EXPORT BlockDiagonalMatrix computeSigmaInfty(const std::vector< BlockMatrix > &superfermion, const std::vector< BlockMatrix > &superfermionAnnihilation, const std::unique_ptr< Model > &model)
Returns the -singular part of the infinite temperature memory kernel for a given fermionic wideband ...
Definition Utility.h:127
REALTIMETRANSPORT_EXPORT SciCore::Complex computeGamma(Eta eta, int r, int l1, int l2, const std::unique_ptr< Model > &model)
Convenience function to compute .
Definition Utility.h:97
REALTIMETRANSPORT_EXPORT Model::SuperRowVectorType computeSigmaInftyCurrent(int r, const std::vector< BlockMatrix > &superfermionAnnihilation, const std::unique_ptr< Model > &model)
Returns the -singular part of the current kernel, , for a given fermionic wideband model.
Definition Utility.h:143
Represents a block diagonal matrix.
Definition BlockDiagonalMatrix.h:33
Abstract class representing a model.
Definition Model.h:47