Wavefunction.h 3.79 KB
Newer Older
Francois Gygi committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
//
// Wavefunction.h
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
6
// $Id: Wavefunction.h,v 1.17 2007-10-19 17:37:06 fgygi Exp $
Francois Gygi committed
7 8 9 10 11 12 13

#ifndef WAVEFUNCTION_H
#define WAVEFUNCTION_H

#include "D3vector.h"
#include "UnitCell.h"
#include <vector>
Francois Gygi committed
14
#include <complex>
Francois Gygi committed
15 16 17 18 19 20 21 22 23 24 25 26
#if USE_CSTDIO_LFS
#include <cstdio>
#endif

class SlaterDet;
class Context;

class Wavefunction
{
  private:

  const Context& ctxt_;
27

Francois Gygi committed
28 29 30 31
  int nel_;           // number of electrons
  int nempty_;        // number of empty states
  int nspin_;         // number of spins (1 or 2)
  int deltaspin_;     // number of spin excitations
32

Francois Gygi committed
33
  int nrowmax_;       // maximum number of rows of a spincontext
34

Francois Gygi committed
35 36 37
  UnitCell cell_ ;    // unit cell
  UnitCell refcell_ ; // reference cell
  double   ecut_ ;    // energy cutoff
38

39 40
  std::vector<double>    weight_;  // weight[ikp]
  std::vector<D3vector>  kpoint_;  // kpoint[ikp]
41

Francois Gygi committed
42 43 44 45 46
  std::vector<int> nst_;  // nst_[ispin]
  const Context* spincontext_;   // context used for spin reductions
  const Context* kpcontext_;     // context used for kp reductions
  const Context* sdcontext_;     // context of local SlaterDet instances
  std::vector<std::vector<SlaterDet*> > sd_;  // local SlaterDets sd_[ispin][ikp]
47 48

  void allocate(); // create contexts and allocate SlaterDet's
Francois Gygi committed
49 50 51
  void deallocate();
  void compute_nst();
  void resize(); // resize SlaterDets if ecut,cell,refcell,or nst have changed
52

Francois Gygi committed
53
  public:
54

Francois Gygi committed
55 56 57 58
  Wavefunction(const Context& ctxt);
  Wavefunction(const Wavefunction& wf);
  ~Wavefunction();
  Wavefunction& operator=(const Wavefunction& wf);
59

Francois Gygi committed
60 61 62 63 64 65 66
  const Context& context(void) const { return ctxt_; }
  const UnitCell& cell(void) const { return cell_; }
  const UnitCell& refcell(void) const { return refcell_; }
  const D3vector kpoint(int ikp) const { return kpoint_[ikp]; }
  double weight(int ikp) const { return weight_[ikp]; }
  double ecut(void) const { return ecut_; }
  SlaterDet* sd(int ispin, int ikp) const { return sd_[ispin][ikp]; }
Francois Gygi committed
67 68 69 70

  const Context* spincontext(void) const { return spincontext_; }
  const Context* kpcontext(void) const { return kpcontext_; }
  const Context* sdcontext(void) const { return sdcontext_; }
Francois Gygi committed
71 72 73 74 75 76 77 78
  int nkp(void) const;            // number of k points
  int nel(void) const;            // total number of electrons
  int nst(int ispin) const;       // number of states of spin ispin
  int nst(void) const;            // number of states
  int nempty(void) const;         // number of empty states
  int nspin(void) const;          // number of spins
  int deltaspin(void) const;      // number of spin excitations
  int nrowmax(void) const { return nrowmax_; }
79

Francois Gygi committed
80 81 82 83
  double spin(void) const;        // total spin

  void resize(const UnitCell& cell, const UnitCell& refcell, double ecut);
  void resize(double ec) { resize(cell_,refcell_,ec); }
84 85
  void reset(void); // initialize with lowest plane waves
  void clear(void); // initialize with zero
Francois Gygi committed
86 87 88 89 90 91 92 93 94
  void set_nel(int nel);
  void set_nempty(int nempty);
  void set_nspin(int nspin);
  void set_deltaspin(int deltaspin);
  void set_nrowmax(int n);
  void add_kpoint(D3vector kpoint, double weight);
  void del_kpoint(D3vector kpoint);

  void randomize(double amplitude);
95

Francois Gygi committed
96 97 98 99
  void update_occ(double fermitemp);
  double entropy(void) const; // dimensionless entropy
  void gram(void);
  void riccati(Wavefunction& wf);
Francois Gygi committed
100 101
  void align(Wavefunction& wf);
  void diag(Wavefunction& dwf, bool eigvec);
102

Francois Gygi committed
103
  std::complex<double> dot(const Wavefunction& wf) const;
104

105
  void print(std::ostream& os, std::string encoding, std::string tag) const;
Francois Gygi committed
106
#if USE_CSTDIO_LFS
107
  void write(FILE* outfile, std::string encoding, std::string tag) const;
Francois Gygi committed
108
#endif
109
  void info(std::ostream& os, std::string tag) const;
Francois Gygi committed
110
};
111
std::ostream& operator << ( std::ostream& os, const Wavefunction& wf );
Francois Gygi committed
112
#endif