TBTK
BlockDiagonalizer.h
1 /* Copyright 2017 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_PROPERTY_EXTRACTOR_BLOCK_DIAGONALIZER
24 #define COM_DAFER45_TBTK_PROPERTY_EXTRACTOR_BLOCK_DIAGONALIZER
25 
26 #include "TBTK/Solver/BlockDiagonalizer.h"
27 #include "TBTK/Property/DOS.h"
28 #include "TBTK/Property/Density.h"
31 #include "TBTK/Property/LDOS.h"
36 
37 #include <complex>
38 //#include <initializer_list>
39 
40 namespace TBTK{
41 namespace PropertyExtractor{
42 
47 public:
52 
54  virtual ~BlockDiagonalizer();
55 
57 /* void saveEigenValues(
58  std::string path = "./",
59  std::string filename = "EV.dat"
60  );*/
61 
64 /* void getTabulatedHoppingAmplitudeSet(
65  std::complex<double> **amplitudes,
66  int **indices,
67  int *numHoppingAmplitudes,
68  int *maxIndexSize
69  );*/
70 
75  virtual void setEnergyWindow(
76  double lowerBound,
77  double upperBound,
78  int resolution
79  );
80 
81  //TODO
82  //This should be extended to become part of the PropertyExtractor
83  //interface once it is tested to work for this specific case.
84  virtual void setEnergyWindow(
85  int lowerFermionicMatsubaraEnergyIndex,
86  int upperFermionicMatsubaraEnergyIndex,
87  int lowerBosonicMatsubaraEnergyIndex,
88  int upperBosonicMatsubaraEnergyIndex
89  );
90 
99 
109  double getEigenValue(int state) const;
110 
118  double getEigenValue(const Index &blockIndex, int state) const;
119 
127  const std::complex<double> getAmplitude(int state, const Index &index);
128 
137  const std::complex<double> getAmplitude(
138  const Index &blockIndex,
139  int state,
140  const Index &intraBlockIndex
141  ) const;
142 
156 // std::initializer_list<Index> patterns,
157  std::vector<Index> patterns,
158 // std::initializer_list<int> states
159  std::vector<int> states
160  );
161 
163 /* Property::GreensFunction2 calculateGreensFunction(
164  Index to,
165  Index from,
166  Property::GreensFunction2::Type type
167  = Property::GreensFunction2::Type::Retarded
168  );*/
169 
180  std::vector<Index> patterns,
182  = Property::GreensFunction::Type::Retarded
183  );
184 
186  virtual Property::DOS calculateDOS();
187 
189  virtual std::complex<double> calculateExpectationValue(
190  Index to,
191  Index from
192  );
193 
195 /* virtual Property::Density calculateDensity(
196  Index pattern,
197  Index ranges
198  );*/
199 
202 // std::initializer_list<Index> patterns
203  std::vector<Index> patterns
204  );
205 
207 /* virtual Property::Magnetization calculateMagnetization(
208  Index pattern,
209  Index ranges
210  );*/
211 
214 // std::initializer_list<Index> patterns
215  std::vector<Index> patterns
216  );
217 
219 /* virtual Property::LDOS calculateLDOS(
220  Index pattern,
221  Index ranges
222  );*/
223 
226 // std::initializer_list<Index> patterns
227  std::vector<Index> patterns
228  );
229 
231 /* virtual Property::SpinPolarizedLDOS calculateSpinPolarizedLDOS(
232  Index pattern,
233  Index ranges
234  );*/
235 
238 // std::initializer_list<Index> patterns
239  std::vector<Index> patterns
240  );
241 
243  virtual double calculateEntropy();
244 private:
247  static void calculateWaveFunctionsCallback(
248  PropertyExtractor *cb_this,
249  void *waveFunctions,
250  const Index &index,
251  int offset
252  );
253 
256  static void calculateGreensFunctionCallback(
257  PropertyExtractor *cb_this,
258  void *greensFunction,
259  const Index &index,
260  int offset
261  );
262 
264  static void calculateDensityCallback(
265  PropertyExtractor *cb_this,
266  void *density,
267  const Index &index,
268  int offset
269  );
270 
272  static void calculateMagnetizationCallback(
273  PropertyExtractor *cb_this,
274  void *mag,
275  const Index &index,
276  int offset
277  );
278 
281  static void calculateLDOSCallback(
282  PropertyExtractor *cb_this,
283  void *ldos,
284  const Index &index,
285  int offset
286  );
287 
290  static void calculateSP_LDOSCallback(
291  PropertyExtractor *cb_this,
292  void *sp_ldos,
293  const Index &index,
294  int offset
295  );
296 
298  Solver::BlockDiagonalizer *bSolver;
299 
301 // std::vector<std::complex<double>> energies;
302 
303  //TODO
304  //These variables should be made part of the PropertyExtractor instead
305  //once it has been tested to work for this specific case.
306  enum class EnergyType{Real, Matsubara};
307  EnergyType energyType;
308  int lowerFermionicMatsubaraEnergyIndex;
309  int upperFermionicMatsubaraEnergyIndex;
310  int lowerBosonicMatsubaraEnergyIndex;
311  int upperBosonicMatsubaraEnergyIndex;
312 };
313 
314 inline double BlockDiagonalizer::getEigenValue(int state) const{
315  return bSolver->getEigenValue(state);
316 }
317 
319  const Index &blockIndex,
320  int state
321 ) const{
322  return bSolver->getEigenValue(blockIndex, state);
323 }
324 
325 inline const std::complex<double> BlockDiagonalizer::getAmplitude(
326  int state,
327  const Index &index
328 ){
329  return bSolver->getAmplitude(state, index);
330 }
331 
332 inline const std::complex<double> BlockDiagonalizer::getAmplitude(
333  const Index &blockIndex,
334  int state,
335  const Index &intraBlockIndex
336 ) const{
337  return bSolver->getAmplitude(blockIndex, state, intraBlockIndex);
338 }
339 
340 }; //End of namespace PropertyExtractor
341 }; //End of namespace TBTK
342 
343 #endif
Type
Definition: GreensFunction.h:39
Property container for local density of states (LDOS).
Definition: LDOS.h:33
Property container for eigen values..
Definition: EigenValues.h:32
virtual std::complex< double > calculateExpectationValue(Index to, Index from)
virtual Property::LDOS calculateLDOS(std::vector< Index > patterns)
Property container for magnetization.
Definition: Magnetization.h:35
Property container for eigen values.
Definition: BlockDiagonalizer.h:46
Property container for local density of states (LDOS).
virtual void setEnergyWindow(double lowerBound, double upperBound, int resolution)
double getEigenValue(int state) const
Definition: BlockDiagonalizer.h:314
virtual Property::Density calculateDensity(std::vector< Index > patterns)
Base class PropertyExtractors.
Property container for spin-polarized local density of states (spin-polarized LDOS).
Property container for density.
Property::WaveFunctions calculateWaveFunctions(std::vector< Index > patterns, std::vector< int > states)
Property container for the Green&#39;s function.
const std::complex< double > getAmplitude(int state, const Index &index)
Definition: BlockDiagonalizer.h:325
Property container for magnetization.
Flexible physical index.
Definition: Index.h:69
Definition: PropertyExtractor.h:44
Definition: ModelFactory.h:35
Property container for wave function.
Definition: WaveFunctions.h:34
Property container for spin-polarized local density of states (spin-polarized LDOS).
Definition: SpinPolarizedLDOS.h:37
Property container for density.
Definition: Density.h:33
Property container for density of states (DOS).
virtual Property::Magnetization calculateMagnetization(std::vector< Index > patterns)
Solves a block diagonal Model using diagonalization.
Definition: BlockDiagonalizer.h:43
virtual Property::SpinPolarizedLDOS calculateSpinPolarizedLDOS(std::vector< Index > patterns)
Property container for density of states (DOS).
Definition: DOS.h:32
Property::GreensFunction calculateGreensFunction(std::vector< Index > patterns, Property::GreensFunction::Type type=Property::GreensFunction::Type::Retarded)
BlockDiagonalizer(Solver::BlockDiagonalizer &solver)
Property container for wave functions.
Property container for the Green&#39;s function.
Definition: GreensFunction.h:36