HubbardGPU
Hubbard diagonalisation on the GPU (and CPU)
 All Classes Files Functions Variables Typedefs Friends Macros
bare-ham.h
Go to the documentation of this file.
1 /* Copyright (C) 2014 Ward Poelmans
2 
3 This file is part of Hubbard-GPU.
4 
5 Hubbard-GPU is free software: you can redistribute it and/or modify
6 it under the terms of the GNU 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 Hubbard-GPU 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 General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with Hubbard-GPU. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef BARE_HAM_H
20 #define BARE_HAM_H
21 
22 #include <vector>
23 #include <string>
24 
26 typedef unsigned int myint;
27 
28 extern "C" {
29  void dsyevd_( char* jobz, char* uplo, int* n, double* a, int* lda, double* w, double* work, int* lwork, int* iwork, int* liwork, int* info);
30  double ddot_(int *n,double *x,int *incx,double *y,int *incy);
31  void dscal_(int *n,double *alpha,double *x,int *incx);
32  void dsymv_(char *uplo, const int *n, const double *alpha, const double *a, const int *lda, const double *x, const int *incx, const double *beta, double *y, const int *incy);
33  void daxpy_(int *n,const double *alpha,double *x,int *incx,double *y,int *incy);
34  void dstev_( const char* jobz, const int* n, double* d, double* e, double* z, const int* ldz, double* work, int* info );
35  void dgesvd_( char* jobu, char* jobvt, int* m, int* n, double* a, int* lda, double* s, double* u, int* ldu, double* vt, int* ldvt, double* work, int* lwork, int* info );
36  void dgemm_(char *transA,char *transB,const int *m,const int *n,const int *k,double *alpha,double *A,const int *lda,double *B,const int *ldb,double *beta,double *C,const int *ldc);
37 
38  void dsaupd_(int *ido, char *bmat, int *n, char *which,
39  int *nev, double *tol, double *resid, int *ncv,
40  double *v, int *ldv, int *iparam, int *ipntr,
41  double *workd, double *workl, int *lworkl, int *info);
42 
43  void dseupd_(int *rvec, char *All, int *select, double *d,
44  double *z, int *ldz, double *sigma,
45  char *bmat, int *n, char *which, int *nev,
46  double *tol, double *resid, int *ncv, double *v,
47  int *ldv, int *iparam, int *ipntr, double *workd,
48  double *workl, int *lworkl, int *info);
49 }
50 
56 {
57  public:
58  BareHamiltonian(int L, int Nu, int Nd, double J, double U);
59  virtual ~BareHamiltonian();
60 
61  static int CalcDim(int L, int N);
62 
63  static int CountBits(myint bits);
64 
65  std::string print_bin(myint num) const;
66 
67  static std::string print_bin(myint num,int bitcount);
68 
69  virtual void BuildBase();
70 
71  virtual void BuildFullHam() = 0;
72 
73  virtual void BuildHam();
74 
75  int getL() const;
76  int getNu() const;
77  int getNd() const;
78  int getDim() const;
79 
80  double getJ() const;
81  double getU() const;
82 
83  void setU(double);
84 
85  myint getBaseUp(unsigned int i) const;
86  myint getBaseDown(unsigned int i) const;
87 
88  virtual std::vector<double> ExactDiagonalizeFull(bool calc_eigenvectors=false);
89  virtual double LanczosDiagonalize(int m=0);
90  virtual double arpackDiagonalize();
91 
92  void Print(bool list=false) const;
93 
94  void PrintBase() const;
95 
96  void PrintGroundstateVector() const;
97 
98  virtual void mvprod(double *x, double *y, double alpha) const = 0;
99 
100  double MemoryNeededFull() const;
101 
102  double MemoryNeededLanczos() const;
103 
104  double MemoryNeededArpack() const;
105 
106  virtual void SaveToFile(const std::string filename) const;
107 
108  protected:
109  int CalcSign(int i,int j,myint a) const;
110 
111  static void Diagonalize(int dim, double *mat, double *eigs, bool calc_eigenvectors);
112 
113  void SaveToFile(const std::string filename, double *data, int dim) const;
114 
116  int L;
118  int Nu;
120  int Nd;
122  double J;
124  double U;
126  double *ham;
128  int dim;
129 
133  int Hbc;
134 
136  std::vector<myint> baseUp;
138  std::vector<myint> baseDown;
139 };
140 
141 #endif /* BARE_HAM_H */
142 
143 /* vim: set ts=8 sw=4 tw=0 expandtab :*/