Wavefunction.h 3.63 KB
Newer Older
Francois Gygi committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
//
// Wavefunction.h
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
6
// $Id: Wavefunction.h,v 1.13 2004-09-14 22:24:11 fgygi Exp $
Francois Gygi committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

#ifndef WAVEFUNCTION_H
#define WAVEFUNCTION_H

#include "D3vector.h"
#include "UnitCell.h"
#include <vector>
#if USE_CSTDIO_LFS
#include <cstdio>
#endif
using namespace std;

class SlaterDet;
class Context;

class Wavefunction
{
  private:

  const Context& ctxt_;
  
  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
  
  int nrowmax_;       // maximum number of rows of a spincontext
  
  UnitCell cell_ ;    // unit cell
  UnitCell refcell_ ; // reference cell
  double   ecut_ ;    // energy cutoff
  
  vector<double>      weight_;  // weight[ikp]
  vector<D3vector  >  kpoint_;  // kpoint[ikp]
  
  vector<int> nst_;                       // nst_[ispin]
  vector<Context*> spincontext_;          // spincontext[ispin]
  vector<vector<Context*> > sdcontext_;   // sdcontext_[ispin][ikp]
  vector<vector<SlaterDet*> > sd_;        // sd[ispin][ikp]
  
  void allocate(); // create contexts and allocate SlaterDet's 
  void deallocate();
  void compute_nst();
  void resize(); // resize SlaterDets if ecut,cell,refcell,or nst have changed
  
  public:
  
  Wavefunction(const Context& ctxt);
  Wavefunction(const Wavefunction& wf);
  ~Wavefunction();
  Wavefunction& operator=(const Wavefunction& wf);
  
  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]; }
  const Context* sdcontext(int ispin, int ikp) const 
    { return sdcontext_[ispin][ikp]; }
  const Context* spincontext(int ispin) const 
    { return spincontext_[ispin]; }
  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_; }
  
  double spin(void) const;        // total spin

  void resize(const UnitCell& cell, const UnitCell& refcell, double ecut);
  void resize(double ec) { resize(cell_,refcell_,ec); }
83 84
  void reset(void); // initialize with lowest plane waves
  void clear(void); // initialize with zero
Francois Gygi committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98
  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);
  
  void update_occ(double fermitemp);
  double entropy(void) const; // dimensionless entropy
  void gram(void);
  void riccati(Wavefunction& wf);
Francois Gygi committed
99 100 101 102
  void align(Wavefunction& wf);
  void diag(Wavefunction& dwf, bool eigvec);
  
  double dot(const Wavefunction& wf) const;
Francois Gygi committed
103 104 105 106 107 108 109 110 111
  
  void print(ostream& os, string encoding, string tag);
#if USE_CSTDIO_LFS
  void write(FILE* outfile, string encoding, string tag);
#endif
  void info(ostream& os, string tag);
};
ostream& operator << ( ostream& os, Wavefunction& wf );
#endif