1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2008 The Regents of the University of California 4 // 5 // This file is part of Qbox 6 // 7 // Qbox is distributed under the terms of the GNU General Public License 8 // as published by the Free Software Foundation, either version 2 of 9 // the License, or (at your option) any later version. 10 // See the file COPYING in the root directory of this distribution 11 // or <http://www.gnu.org/licenses/>. 12 // 13 //////////////////////////////////////////////////////////////////////////////// 14 // 15 // MLWFTransform.h 16 // 17 //////////////////////////////////////////////////////////////////////////////// 18 19 #ifndef MLWFTRANSFORM_H 20 #define MLWFTRANSFORM_H 21 22 #include <vector> 23 #include <complex> 24 class SlaterDet; 25 class UnitCell; 26 class DoubleMatrix; 27 #include "D3vector.h" 28 #include "BasisMapping.h" 29 30 class Context; 31 32 class MLWFTransform 33 { 34 private: 35 36 const SlaterDet& sd_; 37 const UnitCell& cell_; 38 const Context& ctxt_; 39 40 BasisMapping bm_; 41 std::vector<DoubleMatrix*> a_; // cosine and sine matrices 42 DoubleMatrix* u_; // orthogonal transformation 43 std::vector<std::vector<double> > adiag_; // diagonal elements adiag_[k][i] 44 45 SlaterDet *sdcosx_, *sdsinx_, 46 *sdcosy_, *sdsiny_, 47 *sdcosz_, *sdsinz_; 48 49 double tol_; 50 int maxsweep_; 51 52 public: 53 a(int k)54 DoubleMatrix* a(int k) { return a_[k]; }; 55 sdcosx(void)56 SlaterDet* sdcosx(void) { return sdcosx_; }; sdcosy(void)57 SlaterDet* sdcosy(void) { return sdcosy_; }; sdcosz(void)58 SlaterDet* sdcosz(void) { return sdcosz_; }; sdsinx(void)59 SlaterDet* sdsinx(void) { return sdsinx_; }; sdsiny(void)60 SlaterDet* sdsiny(void) { return sdsiny_; }; sdsinz(void)61 SlaterDet* sdsinz(void) { return sdsinz_; }; 62 63 // diagonal element i of matrix a_[k] adiag(int k,int i)64 double adiag(int k, int i) { return adiag_[k][i]; } 65 66 void update(void); // compute matrices for Berry phase and MLWF 67 void compute_transform(void); 68 void compute_sincos(const int n, const std::complex<double>* f, 69 std::complex<double>* fc, std::complex<double>* fs); 70 void apply_transform(SlaterDet& sd); 71 set_tol(double t)72 void set_tol(double t) { tol_ = t; } set_maxsweep(int n)73 void set_maxsweep(int n) { maxsweep_ = n; } 74 75 double spread2(int i, int j); 76 double spread2(int i); 77 double spread2(void); 78 double spread(int i); 79 double spread(void); 80 D3vector center(int i); 81 D3vector dipole(void); 82 83 MLWFTransform(const SlaterDet& sd); 84 ~MLWFTransform(void); 85 }; 86 #endif 87