SlaterDet.h 3.21 KB
Newer Older
Francois Gygi committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
//
// SlaterDet.h
//
////////////////////////////////////////////////////////////////////////////////
6
// $Id: SlaterDet.h,v 1.20 2007-10-19 16:24:05 fgygi Exp $
Francois Gygi committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

#ifndef SLATERDET_H
#define SLATERDET_H

class FourierTransform;
#include "Context.h"
#include "Basis.h"
#include "Matrix.h"

#include "D3vector.h"
#include <vector>
#include <iostream>
#include "Timer.h"
#include <string>
#include <map>
#if USE_CSTDIO_LFS
#include <cstdio>
#endif

26
typedef std::map<std::string,Timer> TimerMap;
Francois Gygi committed
27 28 29 30 31 32

class SlaterDet
{
  private:

  const Context& ctxt_;
33 34
  Context* my_col_ctxt_;
  Basis* basis_;
Francois Gygi committed
35
  ComplexMatrix c_;
36 37
  std::vector<double> occ_;
  std::vector<double> eig_;
38

Francois Gygi committed
39 40 41 42
  void byteswap_double(size_t n, double* x);
  double fermi(double e, double mu, double fermitemp);

  public:
43

Francois Gygi committed
44 45 46 47 48 49
  mutable TimerMap tmap;

  SlaterDet(const Context& ctxt, D3vector kpoint);
  SlaterDet(const SlaterDet& rhs);
  ~SlaterDet();
  const Context& context(void) const { return ctxt_; }
50 51
  const Basis& basis(void) const { return *basis_; }
  const D3vector kpoint(void) const { return basis_->kpoint(); }
Francois Gygi committed
52 53
  const ComplexMatrix& c(void) const { return c_; }
  ComplexMatrix& c(void) { return c_; }
54 55
  const std::vector<double>& occ(void) const { return occ_; }
  const std::vector<double>& eig(void) const { return eig_; }
Francois Gygi committed
56 57 58 59 60
  int nst(void) const { return c_.n(); }
  int nstloc(void) const { return c_.nloc(); }
  void resize(const UnitCell& cell, const UnitCell& refcell,
              double ecut, int nst);
  void compute_density(FourierTransform& ft, double weight, double* rho) const;
Francois Gygi committed
61
  void rs_mul_add(FourierTransform& ft, const double* v, SlaterDet& sdp) const;
Francois Gygi committed
62 63
  void randomize(double amplitude);
  void cleanup(void);
64
  void reset(void);
Francois Gygi committed
65 66
  void gram(void);
  void riccati(SlaterDet& sd);
67 68 69
  void lowdin(void);
  void align(const SlaterDet& sd);
  void ortho_align(const SlaterDet& sd);
70
  double dot(const SlaterDet& sd) const;
Francois Gygi committed
71 72 73 74
  double total_charge(void);
  void update_occ(int nel, int nspin);
  void update_occ(int nspin, double mu, double temp);
  double eig(int i) const { return eig_[i]; };
75 76
  const double* eig_ptr(void) const { return &eig_[0]; }
  const double* eig_ptr(int i) const { return &eig_[i]; }
Francois Gygi committed
77
  double occ(int i) const { return occ_[i]; };
78 79
  const double* occ_ptr(void) const { return &occ_[0]; }
  const double* occ_ptr(int i) const { return &occ_[i]; }
80
  void set_occ(std::vector<double>& occ)
Francois Gygi committed
81
    { assert(occ_.size()==occ.size()); occ_ = occ; }
82
  void set_eig(std::vector<double>& eig)
Francois Gygi committed
83
    { assert(eig_.size()==eig.size()); eig_ = eig; }
84
  void set_eig(std::valarray<double>& eig)
85
    { assert(eig_.size()==eig.size());
Francois Gygi committed
86 87 88
      for ( int i = 0; i < eig.size(); i++ )
        eig_[i] = eig[i];
    }
Francois Gygi committed
89 90 91 92 93
  double entropy(int nspin);
  double ortho_error(void);
  double memsize(void) const;
  double localmemsize(void) const;
  SlaterDet& operator=(SlaterDet& rhs);
94
  void print(std::ostream& os, std::string encoding);
Francois Gygi committed
95
#if USE_CSTDIO_LFS
96
  void write(FILE* outfile, std::string encoding);
Francois Gygi committed
97
#endif
98
  void info(std::ostream& os);
Francois Gygi committed
99
};
100
std::ostream& operator << ( std::ostream& os, SlaterDet& sd );
101 102 103 104

class SlaterDetException
{
  public:
105 106
  std::string msg;
  SlaterDetException(std::string s) : msg(s) {}
107
};
Francois Gygi committed
108
#endif