JDFTx  1.1.2
SCF.h
1 /*-------------------------------------------------------------------
2 Copyright 2013 Deniz Gunceler, Ravishankar Sundararaman
3 
4 This file is part of JDFTx.
5 
6 JDFTx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 JDFTx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with JDFTx. If not, see <http://www.gnu.org/licenses/>.
18 -------------------------------------------------------------------*/
19 
20 #ifndef JDFTX_ELECTRONIC_SCF_H
21 #define JDFTX_ELECTRONIC_SCF_H
22 
23 #include <electronic/common.h>
24 #include <electronic/Everything.h>
25 #include <electronic/BandMinimizer.h>
26 #include <electronic/operators.h>
27 #include <core/Pulay.h>
28 
34  std::vector<matrix> rhoAtom;
35 };
36 
38 class SCF : public Pulay<SCFvariable>
39 {
40 public:
41  SCF(Everything& e);
42 
44  void minimize();
45 
46  static double eigDiffRMS(const std::vector<diagMatrix>&, const std::vector<diagMatrix>&, const Everything& e);
47 
48 protected:
49  //---- Interface to Pulay ----
50  double sync(double x) const;
51  double cycle(double dEprev, std::vector<double>& extraValues);
52  void report(int iter);
53  void axpy(double alpha, const SCFvariable& X, SCFvariable& Y) const;
54  double dot(const SCFvariable& X, const SCFvariable& Y) const;
55  size_t variableSize() const;
56  void readVariable(SCFvariable&, FILE*) const;
57  void writeVariable(const SCFvariable&, FILE*) const;
58  SCFvariable getVariable() const;
59  void setVariable(const SCFvariable&);
60  SCFvariable precondition(const SCFvariable&) const;
61  SCFvariable applyMetric(const SCFvariable&) const;
62 
63 private:
64  Everything& e;
65  bool mixTau;
66  RealKernel kerkerMix, diisMetric;
67 
69  void updateFillings();
71  void updateMOM();
72  std::vector<ColumnBundle> Cold; // Wavefunctions from the previous iteration
73 
74  double eigDiffRMS(const std::vector<diagMatrix>&, const std::vector<diagMatrix>&) const;
75  void eigenShiftInit();
76  void eigenShiftApply(bool reverse);
77 };
78 
79 #endif
Pulay mixing to optimize self-consistent field optimization .
Definition: Pulay.h:35
std::vector< ScalarField > ScalarFieldArray
dynamic size collection of real space scalar fields
Definition: ScalarFieldArray.h:32
complex dot(const Tptr &X, const Tptr &Y)
Definition: Operators.h:196
Self-Consistent Field method for converging electronic state.
Definition: SCF.h:38
Pulay mixing algorithm template.
std::vector< matrix > rhoAtom
atomic density matrices (or corresponding potential) [DFT+U only]
Definition: SCF.h:34
ScalarFieldArray n
electron density (or potential)
Definition: SCF.h:32
Operators specific to the electronic code.
Definition: Everything.h:41
ScalarFieldArray tau
KE density (or potential) [mGGA only].
Definition: SCF.h:33
Special class for storing real reciprocal-space kernels encountered ever so often for convolutions...
Definition: ScalarField.h:177
Variable that is mixed during SCF Component names are density-like, but when mixing potential...
Definition: SCF.h:31
void axpy(double alpha, const Tptr &X, Tptr &Y)
Generic axpy for complex data types (Note: null pointers are treated as zero)
Definition: Operators.h:158