ChargeDensity.h 2.31 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
// ChargeDensity.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef CHARGEDENSITY_H
#define CHARGEDENSITY_H

#include <vector>
#include <valarray>
#include <complex>
Francois Gygi committed
25 26 27
#include <string>
#include <map>
#include "Timer.h"
Francois Gygi committed
28
#include "Context.h"
29
#include "D3vector.h"
Francois Gygi committed
30 31 32 33 34

class Wavefunction;
class FourierTransform;
class Basis;

35
typedef std::map<std::string,Timer> TimerMap;
Francois Gygi committed
36

Francois Gygi committed
37 38 39
class ChargeDensity
{
  private:
40

Francois Gygi committed
41
  const Context& ctxt_;
42
  MPI_Comm vcomm_;
Francois Gygi committed
43 44 45
  const Wavefunction& wf_;
  Basis* vbasis_;
  FourierTransform* vft_;
46 47
  std::vector<FourierTransform*> ft_; // ft_[ikp];
  std::valarray<std::complex<double> > rhotmp;
48
  std::vector<double> total_charge_;
49

Francois Gygi committed
50
  public:
51

Francois Gygi committed
52 53
  mutable TimerMap tmap;

54
  // rhor, rhog: valence density
55 56
  std::vector<std::vector<double> > rhor; // rhor[ispin][i]
  std::vector<std::vector<std::complex<double> > > rhog; // rhog[ispin][ig]
57 58 59
  // rhocore_r, rhocore_g: core density. Non-zero size only if nlcc used
  std::vector<double> rhocore_r;
  std::vector<std::complex<double> > rhocore_g;
Francois Gygi committed
60
  void update_density(void);
Francois Gygi committed
61
  void update_rhor(void);
Francois Gygi committed
62 63
  void update_taur(double* taur) const;
  void update_taur(double* taur_up, double* taur_dn) const;
He Ma committed
64
  void update_rhog(void);
65

66 67
  const Context& context(void) const { return ctxt_; }
  MPI_Comm vcomm(void) const { return vcomm_; }
Francois Gygi committed
68 69 70
  Basis* vbasis(void) const { return vbasis_; }
  FourierTransform* vft(void) const { return vft_; }
  FourierTransform* ft(int ikp) const { return ft_[ikp]; }
71 72 73 74
  double total_charge(int ispin) const { return total_charge_[ispin]; }
  double total_charge(void) const;

  void print(std::ostream& os) const;
Francois Gygi committed
75 76 77 78

  ChargeDensity(const Wavefunction& wf);
  ~ChargeDensity();
};
79
std::ostream& operator << ( std::ostream& os, const ChargeDensity& cd );
Francois Gygi committed
80
#endif