EnergyFunctional.h 3.69 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
// EnergyFunctional.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef ENERGYFUNCTIONAL_H
#define ENERGYFUNCTIONAL_H

#include <complex>
#include <vector>
24
#include <valarray>
Francois Gygi committed
25 26 27
#include <map>
#include <string>
#include "StructureFactor.h"
28
#include "ElectricEnthalpy.h"
Francois Gygi committed
29 30
#include "Timer.h"

31
class D3vector;
Francois Gygi committed
32 33 34 35
class Sample;
class Basis;
class AtomSet;
class Wavefunction;
36
class ChargeDensity;
Francois Gygi committed
37 38
class UnitCell;
class FourierTransform;
Francois Gygi committed
39
class XCOperator;
Francois Gygi committed
40
class NonLocalPotential;
41
class ConfinementPotential;
Francois Gygi committed
42

43
typedef std::map<std::string,Timer> TimerMap;
Francois Gygi committed
44 45 46 47

class EnergyFunctional
{
  private:
48

Francois Gygi committed
49
  Sample& s_;
50
  ChargeDensity& cd_;
Francois Gygi committed
51 52
  Basis* vbasis_;
  FourierTransform *vft;
53
  std::vector<FourierTransform*> ft;
Francois Gygi committed
54
  StructureFactor sf;
Francois Gygi committed
55
  XCOperator* xco;
56
  ElectricEnthalpy* el_enth_;
Francois Gygi committed
57
  std::vector<std::vector<NonLocalPotential*> > nlp;    // nlp[ispin][ikp]
58
  std::vector<ConfinementPotential*> cfp; // cfp[ikp]
59

60 61
  std::vector<std::vector<double> > vps, dvps, rhops, rhocore_sp_g;
  std::vector<double> rhocore_r;
62
  std::vector<std::complex<double> > tmp_r, vion_local_g,
63
    dvion_local_g, vxc_g, vlocal_g, rhopst, rhogt, rhoelg, vtemp, rhocore_g;
64

65
  std::vector<std::vector<double> > tau0, fion_esr;
Francois Gygi committed
66
  std::vector<std::vector<double> > fext;
67 68
  std::vector<double> zv_, rcps_;
  std::vector<int> na_;
Francois Gygi committed
69
  int nsp_;
70
  double ekin_, econf_, eps_, enl_, ehart_, ehart_e_, ehart_ep_, ehart_p_,
71
         ecoul_, exc_, esr_, eself_, ets_, eexf_, etotal_;
72
  double dxc_;
73
  double epv_, eefield_, enthalpy_;
74
  std::valarray<double> sigma_ekin,sigma_econf,sigma_eps,sigma_ehart,sigma_exc,
75
    sigma_enl, sigma_esr, sigma;
Francois Gygi committed
76

77 78
  bool core_charge_;

Francois Gygi committed
79 80
  public:

81
  std::vector<std::vector<double> > v_r;
Francois Gygi committed
82
  mutable TimerMap tmap;
83

Francois Gygi committed
84
  double energy(bool compute_hpsi, Wavefunction& dwf,
85 86
    bool compute_forces, std::vector<std::vector<double> >& fion,
    bool compute_stress, std::valarray<double>& sigma);
87

Francois Gygi committed
88 89
  double etotal(void) const { return etotal_; }
  double ekin(void) const { return ekin_; }
90
  double econf(void) const { return econf_; }
Francois Gygi committed
91 92 93
  double eps(void) const { return eps_; }
  double enl(void) const { return enl_; }
  double ehart(void) const { return ehart_; }
94 95 96
  double ehart_e(void) const { return ehart_e_; }
  double ehart_ep(void) const { return ehart_ep_; }
  double ehart_p(void) const { return ehart_p_; }
Francois Gygi committed
97 98
  double ecoul(void) const { return ecoul_; }
  double exc(void) const { return exc_; }
99
  double dxc(void) const { return dxc_; }
Francois Gygi committed
100 101
  double esr(void) const { return esr_; }
  double eself(void) const { return eself_; }
102
  double ets(void) const { return ets_; }
Francois Gygi committed
103
  double eexf(void) const { return eexf_; }
104
  double eefield(void) const { return eefield_; }
105 106
  double epv(void) const { return epv_; }
  double enthalpy(void) const { return enthalpy_; }
107 108

  ElectricEnthalpy* el_enth() { return el_enth_; }
109

110
  const ConfinementPotential *confpot(int ikp) const { return cfp[ikp]; }
111

112
  void update_vhxc(bool compute_stress);
113

Francois Gygi committed
114 115
  void atoms_moved(void);
  void cell_moved(void);
116

117
  void print(std::ostream& os) const;
Francois Gygi committed
118

119
  EnergyFunctional(Sample& s, ChargeDensity& cd);
Francois Gygi committed
120 121
  ~EnergyFunctional();
};
122
std::ostream& operator << ( std::ostream& os, const EnergyFunctional& e );
Francois Gygi committed
123
#endif