JDFTx  1.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
68  double eigDiffRMS(const std::vector<diagMatrix>&, const std::vector<diagMatrix>&) const;
69 };
70 
71 #endif
Pulay mixing to optimize self-consistent field optimization
Definition: Pulay.h:35
SCFvariable precondition(const SCFvariable &) const
Apply preconditioner to variable/residual.
std::vector< ScalarField > ScalarFieldArray
dynamic size collection of real space scalar fields
Definition: ScalarFieldArray.h:32
Self-Consistent Field method for converging electronic state.
Definition: SCF.h:38
size_t variableSize() const
Number of bytes per variable.
void axpy(double alpha, const SCFvariable &X, SCFvariable &Y) const
Scaled accumulate on variable.
void report(int iter)
Override to perform optional reporting.
void readVariable(SCFvariable &, FILE *) const
Read variable from stream.
void minimize()
Minimizes residual to achieve self-consistency.
Pulay mixing algorithm template.
double dot(const SCFvariable &X, const SCFvariable &Y) const
Euclidean dot product. Metric applied separately for efficiency.
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
double sync(double x) const
Override to synchronize scalars over MPI processes (if the same minimization is happening in sync ove...
Operators specific to the electronic code.
SCFvariable applyMetric(const SCFvariable &) const
Apply metric to variable/residual.
Definition: Everything.h:41
ScalarFieldArray tau
KE density (or potential) [mGGA only].
Definition: SCF.h:33
SCFvariable getVariable() const
Write variable to stream.
Special class for storing real reciprocal-space kernels encountered ever so often for convolutions...
Definition: ScalarField.h:180
Variable that is mixed during SCF Component names are density-like, but when mixing potential...
Definition: SCF.h:31
void setVariable(const SCFvariable &)
Set the state of system to specified variable.
double cycle(double dEprev, std::vector< double > &extraValues)
Single cycle of the self-consistency loop. In each subsequent cycle, Pulay will try to zero the diffe...
static double eigDiffRMS(const std::vector< diagMatrix > &, const std::vector< diagMatrix > &, const Everything &e)
weigted RMS difference between two sets of eigenvalues