TBTK
Need a break? Support the development by playing Polarity Puzzles
ExactDiagonalizer.h
1 /* Copyright 2016 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 
17 
24 #ifndef COM_DAFER45_TBTK_SOLVER_EXACT_DIAGONALIZATION
25 #define COM_DAFER45_TBTK_SOLVER_EXACT_DIAGONALIZATION
26 
27 #include "TBTK/Solver/Diagonalizer.h"
28 #include "TBTK/FockStateRuleSet.h"
29 #include "TBTK/FockStateRule/WrapperRule.h"
30 #include "TBTK/InteractionAmplitudeSet.h"
31 #include "TBTK/Model.h"
32 #include "TBTK/ManyParticleContext.h"
33 #include "TBTK/Solver/Solver.h"
34 
35 #include <initializer_list>
36 
37 namespace TBTK{
38 namespace Solver{
39 
40 class ExactDiagonalizer : public Solver{
41 public:
43  ExactDiagonalizer(
44 // Model *model
45  );
46 
48  virtual ~ExactDiagonalizer();
49 
51  unsigned int addSubspace(std::initializer_list<const FockStateRule::WrapperRule> rules);
52 
54  unsigned int addSubspace(std::vector<FockStateRule::WrapperRule> rules);
55 
57  unsigned int addSubspace(const FockStateRuleSet &rules);
58 
60  void run(unsigned int subspace);
61 
63  const CArray<double>& getEigenValues(unsigned int subspace);
64 
66  const double getEigenValue(unsigned int subspace, int state);
67 
73  const std::complex<double> getAmplitude(
74  unsigned int subspace,
75  int state,
76  const Index &index
77  );
78 
80 // Model* getModel();
81 private:
83 // Model *model;
84 
87  class SubspaceContext{
88  public:
90  SubspaceContext(
91  std::initializer_list<const FockStateRule::WrapperRule> rules
92  );
93 
95  SubspaceContext(
96  std::vector<FockStateRule::WrapperRule> rules
97  );
98 
100  SubspaceContext(
101  const FockStateRuleSet &rules
102  );
103 
105  ~SubspaceContext();
106 
108 // std::vector<FockStateRule::WrapperRule> rules;
109  FockStateRuleSet fockStateRuleSet;
110 
112 // Model *manyParticleModel;
113  std::shared_ptr<Model> manyParticleModel;
114 
116 // Diagonalizer *dSolver;
117  std::shared_ptr<Diagonalizer> dSolver;
118  private:
119  };
120 
122  std::vector<SubspaceContext> subspaceContexts;
123 
125  void setupManyParticleModel(unsigned int subspace);
126 
128  template<typename BIT_REGISTER>
129  void setupManyParticleModel(unsigned int subspace);
130 };
131 
132 inline const CArray<double>& ExactDiagonalizer::getEigenValues(
133  unsigned int subspace
134 ){
135  return subspaceContexts.at(subspace).dSolver->getEigenValues();
136 }
137 
138 inline const double ExactDiagonalizer::getEigenValue(
139  unsigned int subspace,
140  int state
141 ){
142  return subspaceContexts.at(subspace).dSolver->getEigenValue(state);
143 }
144 
145 inline const std::complex<double> ExactDiagonalizer::getAmplitude(
146  unsigned int subspace,
147  int state,
148  const Index &index
149 ){
150  return subspaceContexts.at(subspace).dSolver->getAmplitude(
151  state,
152  index
153  );
154 }
155 
156 /*inline Model* ExactDiagonalizer::getModel(){
157  return model;
158 }*/
159 
160 }; //End of namespace Solver
161 }; //End of namespace TBTK
162 
163 #endif
164 
Container of Model related information.
Base class for Solvers.
Definition: Boolean.h:32