MLWFTransform.h 2.32 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// MLWFTransform.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef MLWFTRANSFORM_H
#define MLWFTRANSFORM_H

#include <vector>
#include <complex>
class SlaterDet;
class UnitCell;
class DoubleMatrix;
#include "D3vector.h"
#include "BasisMapping.h"

30 31
class Context;

Francois Gygi committed
32 33 34 35 36
class MLWFTransform
{
  private:

  const SlaterDet& sd_;
37
  const UnitCell& cell_;
Francois Gygi committed
38 39 40 41 42
  const Context& ctxt_;

  BasisMapping bm_;
  std::vector<DoubleMatrix*> a_;  // cosine and sine matrices
  DoubleMatrix* u_;               // orthogonal transformation
43 44 45 46 47 48 49 50
  std::vector<std::vector<double> > adiag_; // diagonal elements adiag_[k][i]

  SlaterDet *sdcosx_, *sdsinx_,
            *sdcosy_, *sdsiny_,
            *sdcosz_, *sdsinz_;

  double tol_;
  int maxsweep_;
51

Francois Gygi committed
52
  public:
53

54 55 56 57 58 59 60 61 62 63 64 65 66
  DoubleMatrix* a(int k) { return a_[k]; };

  SlaterDet* sdcosx(void) { return sdcosx_; };
  SlaterDet* sdcosy(void) { return sdcosy_; };
  SlaterDet* sdcosz(void) { return sdcosz_; };
  SlaterDet* sdsinx(void) { return sdsinx_; };
  SlaterDet* sdsiny(void) { return sdsiny_; };
  SlaterDet* sdsinz(void) { return sdsinz_; };

  // diagonal element i of matrix a_[k]
  double adiag(int k, int i) { return adiag_[k][i]; }

  void update(void); // compute matrices for Berry phase and MLWF
Francois Gygi committed
67
  void compute_transform(void);
68
  void compute_sincos(const int n, const std::complex<double>* f,
Francois Gygi committed
69 70 71
    std::complex<double>* fc, std::complex<double>* fs);
  void apply_transform(SlaterDet& sd);

72 73 74
  void set_tol(double t) { tol_ = t; }
  void set_maxsweep(int n) { maxsweep_ = n; }

Francois Gygi committed
75 76 77 78 79 80
  double spread2(int i, int j);
  double spread2(int i);
  double spread2(void);
  double spread(int i);
  double spread(void);
  D3vector center(int i);
Francois Gygi committed
81
  D3vector dipole(void);
82

Francois Gygi committed
83 84 85 86
  MLWFTransform(const SlaterDet& sd);
  ~MLWFTransform(void);
};
#endif