JDFTx  1.2.0
LinearPCM.h
1 /*-------------------------------------------------------------------
2 Copyright 2011 Ravishankar Sundararaman, Kendra Letchworth Weaver, Deniz Gunceler
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_LINEARPCM_H
21 #define JDFTX_ELECTRONIC_LINEARPCM_H
22 
23 #include <fluid/PCM.h>
24 #include <core/Minimize.h>
25 
26 class LinearPCM : public PCM, public LinearSolvable<ScalarFieldTilde>
27 {
28 public:
29  LinearPCM(const Everything& e, const FluidSolverParams& fsp);
30  virtual ~LinearPCM();
31  bool prefersGummel() const { return false; }
32 
34  ScalarFieldTilde chi(const ScalarFieldTilde&) const;
36 
37  void minimizeFluid();
38  void loadState(const char* filename);
39  void saveState(const char* filename) const;
40 
41 protected:
42  void set_internal(const ScalarFieldTilde& rhoExplicitTilde, const ScalarFieldTilde& nCavityTilde);
43  double get_Adiel_and_grad_internal(ScalarFieldTilde& grad_rhoExplicitTilde, ScalarFieldTilde& grad_nCavityTilde, IonicGradient* extraForces, bool electricOnly) const;
44 private:
45  RadialFunctionG Kkernel; ScalarField epsInv; // for preconditioner
46  void updatePreconditioner(const ScalarField& epsilon, const ScalarField& kappaSq);
47 
48  //Optionally override epsilon and kappaSq (when used as the inner solver in NonlinearPCM's SCF):
49  friend class NonlinearPCM;
50  ScalarField epsilonOverride, kappaSqOverride;
51  void override(const ScalarField& epsilon, const ScalarField& kappaSq);
52 };
53 
54 #endif // JDFTX_ELECTRONIC_LINEARPCM_H
void loadState(const char *filename)
Load state from file.
LinearPCM(const Everything &e, const FluidSolverParams &fsp)
Parameters same as createFluidSolver()
Definition: Minimize.h:85
std::shared_ptr< ScalarFieldTildeData > ScalarFieldTilde
A smart reference-counting pointer to ScalarFieldTildeData.
Definition: ScalarField.h:45
void saveState(const char *filename) const
Save state to file.
ScalarFieldTilde hessian(const ScalarFieldTilde &) const
Implements LinearSolvable::hessian for the dielectric poisson equation.
ScalarFieldTilde precondition(const ScalarFieldTilde &) const
Implements a modified inverse kinetic preconditioner.
Definition: NonlinearPCM.h:34
void minimizeFluid()
Converge using linear conjugate gradients.
ScalarFieldTilde rhoExplicitTilde
Charge density of explicit (electronic) system.
Definition: PCM.h:40
void set_internal(const ScalarFieldTilde &rhoExplicitTilde, const ScalarFieldTilde &nCavityTilde)
Fluid-dependent implementation of set()
G-space radial function stored on a uniform grid (of |G|)
Definition: RadialFunction.h:28
Definition: Everything.h:41
Base class for all PCMs.
Definition: PCM.h:29
Nonlinear minimization templates.
double get_Adiel_and_grad_internal(ScalarFieldTilde &grad_rhoExplicitTilde, ScalarFieldTilde &grad_nCavityTilde, IonicGradient *extraForces, bool electricOnly) const
Fluid-dependent implementation of get_Adiel_and_grad()
ScalarFieldTilde chi(const ScalarFieldTilde &) const
Apply susceptility operator (return fluid charge given net potential)
bool prefersGummel() const
Specify whether fluid prefers a gummel loop (true) or is minimized each time (false) ...
Definition: LinearPCM.h:31
Definition: LinearPCM.h:26
std::shared_ptr< ScalarFieldData > ScalarField
A smart reference-counting pointer to ScalarFieldData.
Definition: ScalarField.h:41
Extra parameters for fluids:
Definition: FluidSolverParams.h:93
Object to hold all the forces.
Definition: IonicMinimizer.h:31