TBTK
ChebyshevExpander.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 
25 #ifndef COM_DAFER45_TBTK_SOLVER_CHEBYSHEV_EXPANDER
26 #define COM_DAFER45_TBTK_SOLVER_CHEBYSHEV_EXPANDER
27 
28 #include "TBTK/Communicator.h"
29 #include "TBTK/Model.h"
30 #include "TBTK/Solver/Solver.h"
31 
32 #include <complex>
33 #ifndef __APPLE__
34 # include <omp.h>
35 #endif
36 
37 namespace TBTK{
38 namespace Solver{
39 
51 class ChebyshevExpander : public Solver, public Communicator{
52 public:
55 
57  virtual ~ChebyshevExpander();
58 
60  virtual void setModel(Model &model);
61 
63  void setScaleFactor(double scaleFactor);
64 
66  double getScaleFactor();
67 
81  std::vector<Index> &to,
82  Index from,
83  std::complex<double> *coefficients,
84  int numCoefficients,
85  double broadening = 0.000001
86  );
87 
98  Index to,
99  Index from,
100  std::complex<double> *coefficients,
101  int numCoefficients,
102  double broadening = 0.000001
103  );
104 
118  std::vector<Index> &to,
119  Index from,
120  std::complex<double> *coefficients,
121  int numCoefficients,
122  double broadening = 0.000001
123  );
124 
135  Index to,
136  Index from,
137  std::complex<double> *coefficients,
138  int numCoefficients,
139  double broadening = 0.000001
140  );
141 
144  Index to,
145  Index from,
146  std::complex<double> *coefficients,
147  int numCoefficients,
148  double componentCutoff,
149  double broadening = 0.000001
150  );
151 
160  void generateLookupTable(
161  int numCoefficeints,
162  int energyResolution,
163  double lowerBound = -1.,
164  double upperBound = 1.
165  );
166 
168  void destroyLookupTable();
169 
172 
175  void loadLookupTableGPU();
176 
179  void destroyLookupTableGPU();
180 
183 
184  enum class Type{
185  Advanced,
186  Retarded,
187  Principal,
188  NonPrincipal
189  };
190 
204 // Property::GreensFunction* generateGreensFunction(
205  std::complex<double>* generateGreensFunction(
206  std::complex<double> *coefficients,
207  int numCoefficients,
208  int energyResolution,
209  double lowerBound = -1.,
210  double upperBound = 1.,
211 // Property::GreensFunction::Type type = Property::GreensFunction::Type::Retarded
212  Type type = Type::Retarded
213  );
214 
225 // Property::GreensFunction* generateGreensFunction(
226  std::complex<double>* generateGreensFunction(
227  std::complex<double> *coefficients,
228 // Property::GreensFunction::Type type = Property::GreensFunction::Type::Retarded
229  Type type = Type::Retarded
230  );
231 
242 // Property::GreensFunction* generateGreensFunctionGPU(
243  std::complex<double>* generateGreensFunctionGPU(
244  std::complex<double> *coefficients,
245 // Property::GreensFunction::Type type = Property::GreensFunction::Type::Retarded
246  Type type = Type::Retarded
247  );
248 
260  std::complex<double> getMonolopoulosABCDamping(
261  double distanceToEdge,
262  double boundarySize,
263  double e = 1.,
264  double c = 2.62
265  );
266 
271  void setDamping(std::complex<double> *damping);
272 private:
274  double scaleFactor;
275 
277  std::complex<double> *damping;
278 
281  std::complex<double> **generatingFunctionLookupTable;
282 
284  std::complex<double> ***generatingFunctionLookupTable_device;
285 
288  int lookupTableNumCoefficients;
289 
292  int lookupTableResolution;
293 
295  double lookupTableLowerBound;
296 
298  double lookupTableUpperBound;
299 };
300 
301 inline void ChebyshevExpander::setScaleFactor(double scaleFactor){
302  this->scaleFactor = scaleFactor;
303 }
304 
306  return scaleFactor;
307 }
308 
310  if(generatingFunctionLookupTable != NULL)
311  return true;
312  else
313  return false;
314 }
315 
317  if(generatingFunctionLookupTable_device != NULL)
318  return true;
319  else
320  return false;
321 }
322 
323 inline void ChebyshevExpander::setDamping(std::complex<double> *damping){
324  this->damping = damping;
325 }
326 
327 }; //End of namespace Solver
328 }; //End of namespace TBTK
329 
330 #endif
Base class for Solvers.
Definition: Solver.h:32
std::complex< double > getMonolopoulosABCDamping(double distanceToEdge, double boundarySize, double e=1., double c=2.62)
bool getLookupTableIsGenerated()
Definition: ChebyshevExpander.h:309
Container of Model related information.
Solves a Model using the Chebyshev method.
Definition: ChebyshevExpander.h:51
virtual void setModel(Model &model)
void calculateCoefficientsGPU(std::vector< Index > &to, Index from, std::complex< double > *coefficients, int numCoefficients, double broadening=0.000001)
void setDamping(std::complex< double > *damping)
Definition: ChebyshevExpander.h:323
void calculateCoefficients(std::vector< Index > &to, Index from, std::complex< double > *coefficients, int numCoefficients, double broadening=0.000001)
Base class for Solvers.
Flexible physical index.
Definition: Index.h:70
Definition: ModelFactory.h:35
bool getLookupTableIsLoadedGPU()
Definition: ChebyshevExpander.h:316
Base class that communicate their current status during execution.
std::complex< double > * generateGreensFunctionGPU(std::complex< double > *coefficients, Type type=Type::Retarded)
std::complex< double > * generateGreensFunction(std::complex< double > *coefficients, int numCoefficients, int energyResolution, double lowerBound=-1., double upperBound=1., Type type=Type::Retarded)
void generateLookupTable(int numCoefficeints, int energyResolution, double lowerBound=-1., double upperBound=1.)
Definition: Communicator.h:28
double getScaleFactor()
Definition: ChebyshevExpander.h:305
void setScaleFactor(double scaleFactor)
Definition: ChebyshevExpander.h:301
Container of Model related information.
Definition: Model.h:52
void calculateCoefficientsWithCutoff(Index to, Index from, std::complex< double > *coefficients, int numCoefficients, double componentCutoff, double broadening=0.000001)