JDFTx  1.0.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 needsGummel() { return false; }
32 
35 
36  void minimizeFluid();
37  void loadState(const char* filename);
38  void saveState(const char* filename) const;
39 
40 protected:
41  void set_internal(const ScalarFieldTilde& rhoExplicitTilde, const ScalarFieldTilde& nCavityTilde);
42  double get_Adiel_and_grad_internal(ScalarFieldTilde& grad_rhoExplicitTilde, ScalarFieldTilde& grad_nCavityTilde, IonicGradient* extraForces, bool electricOnly) const;
43 private:
44  RadialFunctionG Kkernel; ScalarField epsInv; // for preconditioner
45  void updatePreconditioner(const ScalarField& epsilon, const ScalarField& kappaSq);
46 
47  //Optionally override epsilon and kappaSq (when used as the inner solver in NonlinearPCM's SCF):
48  friend class NonlinearPCM;
49  ScalarField epsilonOverride, kappaSqOverride;
50  void override(const ScalarField& epsilon, const ScalarField& kappaSq);
51 };
52 
53 #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:86
std::shared_ptr< ScalarFieldTildeData > ScalarFieldTilde
A smart reference-counting pointer to ScalarFieldTildeData.
Definition: ScalarField.h:44
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()
Definition: LinearPCM.h:26
std::shared_ptr< ScalarFieldData > ScalarField
A smart reference-counting pointer to ScalarFieldData.
Definition: ScalarField.h:40
Extra parameters for fluids:
Definition: FluidSolverParams.h:86
Object to hold all the forces.
Definition: IonicMinimizer.h:31
bool needsGummel()
Specify whether fluid requires a gummel loop (true) or is minimized each time (false) ...
Definition: LinearPCM.h:31