ElectricEnthalpy.h 2.36 KB
Newer Older
Francois Gygi committed
1 2 3 4 5 6 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
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// 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/>.
//
////////////////////////////////////////////////////////////////////////////////
//
// ElectricEnthalpy.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef ELECTRICENTHALPY_H
#define ELECTRICENTHALPY_H

#include <vector>
#include <complex>
#include <cassert>
#include <string>
#include "Matrix.h"
#include "D3vector.h"
#include "Wavefunction.h"
#include "SlaterDet.h"
#include "Context.h"
#include "Sample.h"
#include "Timer.h"
#include "D3tensor.h"
#include "Basis.h"
35
#include "Matrix.h"
Francois Gygi committed
36 37 38 39 40 41 42 43 44 45

class Sample;
class MLWFTransform;

class ElectricEnthalpy
{
  private:

  Sample& s_;
  Wavefunction& wf_;
46
  Wavefunction* dwf_;
Francois Gygi committed
47 48
  SlaterDet& sd_;
  const Context& ctxt_;
49
  const Basis& basis_;
Francois Gygi committed
50 51

  bool onpe0_;
52
  bool finite_field_;
Francois Gygi committed
53

54
  enum { off, berry, mlwf, mlwf_ref, mlwf_ref_q } pol_type_;
Francois Gygi committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68
  bool compute_quadrupole_;

  // electric field
  D3vector e_field_;

  Wavefunction* rwf_[3];

  // MLWFtransform is used to compute S matrix
  MLWFTransform* mlwft_;

  // s matrices
  ComplexMatrix* smat_[3];

  // total, ionic and electronic part of macroscopic polarization
69
  D3vector dipole_total_, dipole_ion_, dipole_el_;
Francois Gygi committed
70

71 72
  // electric enthalpy
  double enthalpy_;
Francois Gygi committed
73 74 75 76 77 78

  std::vector <D3vector> mlwfc_;
  std::vector <double> mlwfs_;
  std::vector <D3vector> correction_;
  std::vector <D3tensor> quad_;

79
  void compute_correction(void);
80
  double vsst(double x) const;
Francois Gygi committed
81 82 83 84 85

  public:

  mutable TimerMap tmap;

86
  D3vector e_field(void) const { return e_field_; }
87 88 89
  D3vector dipole_total(void) const { return dipole_total_; }
  D3vector dipole_ion(void) const { return dipole_ion_; }
  D3vector dipole_el(void) const { return dipole_el_; }
Francois Gygi committed
90

91
  double enthalpy(Wavefunction& dwf, bool compute_hpsi);
Francois Gygi committed
92 93

  void update(void);
94 95
  void print(std::ostream& os) const;

Francois Gygi committed
96 97 98
  ElectricEnthalpy(Sample& s);
  ~ElectricEnthalpy(void);
};
99
std::ostream& operator << ( std::ostream& os, const ElectricEnthalpy& e );
Francois Gygi committed
100
#endif