JDFTx  1.2.0
Coulomb.h
1 /*-------------------------------------------------------------------
2 Copyright 2012 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_CORE_COULOMB_H
21 #define JDFTX_CORE_COULOMB_H
22 
23 #include <core/GridInfo.h>
24 #include <core/string.h>
25 #include <memory>
26 #include <set>
27 
28 
30 {
31  enum Geometry
33  Slab,
34  Wire,
38  };
40  int iDir;
41  double Rc;
42 
43  double ionMargin;
44 
45  bool embed;
48 
50 
51  //Parameters for computing exchange integrals:
54  { None,
59  };
61  std::set<double> omegaSet;
62  std::shared_ptr<struct Supercell> supercell;
63 
64  CoulombParams();
65 
67  std::shared_ptr<class Coulomb> createCoulomb(const GridInfo& gInfo) const;
68 
70  vector3<bool> isTruncated() const;
71 };
72 
73 
75 struct Atom
76 { double Z;
80  int sp;
81 
82  Atom(double Z, vector3<> pos, vector3<> force=vector3<>(0,0,0), int atomicNumber=0, int sp=0)
83  : Z(Z), pos(pos), force(force), atomicNumber(atomicNumber), sp(sp)
84  {
85  }
86 };
87 
88 
90 class Ewald
91 {
92 public:
96  virtual double energyAndGrad(std::vector<Atom>& atoms) const=0;
97 };
98 
99 
101 class Coulomb
102 {
103 public:
108  PointChargeRight
109  };
110 
114  ScalarFieldTilde operator()(ScalarFieldTilde&&, PointChargeMode pointChargeMode=PointChargeNone) const;
115 
117  ScalarFieldTilde operator()(const ScalarFieldTilde&, PointChargeMode pointChargeMode=PointChargeNone) const;
118 
121  double energyAndGrad(std::vector<Atom>& atoms) const;
122 
124  ScalarField getEfieldPotential() const;
125 
128  complexScalarFieldTilde operator()(complexScalarFieldTilde&&, vector3<> kDiff, double omega) const;
129 
132  complexScalarFieldTilde operator()(const complexScalarFieldTilde&, vector3<> kDiff, double omega) const;
133 
134 private:
135  const GridInfo& gInfoOrig;
136 protected:
137  const CoulombParams& params;
138  const GridInfo& gInfo;
139  std::shared_ptr<Ewald> ewald;
140  std::map<double, std::shared_ptr<struct ExchangeEval>> exchangeEval;
141  friend struct ExchangeEval;
142 
143  Coulomb(const GridInfo& gInfoOrig, const CoulombParams& params);
144  virtual ~Coulomb();
145 
148  void initExchangeEval();
149 
152  virtual ScalarFieldTilde apply(ScalarFieldTilde&&) const=0;
153 
158  virtual std::shared_ptr<Ewald> createEwald(matrix3<> R, size_t nAtoms) const=0;
159 
160 private:
161  //Data for mesh-embedded truncation:
162  GridInfo gInfoEmbed;
163  vector3<int> ivCenter;
164  vector3<> xCenter;
165  vector3<> embedScale;
166  int* embedIndex;
167  std::vector< std::pair<int,int*> > symmIndex;
168  class WignerSeitz* wsOrig;
169  double ionWidth;
170  RealKernel* ionKernel;
171  ScalarFieldTilde embedExpand(const ScalarFieldTilde& in) const;
172  complexScalarFieldTilde embedExpand(complexScalarFieldTilde&& in) const;
173  ScalarFieldTilde embedShrink(const ScalarFieldTilde& in) const;
174  complexScalarFieldTilde embedShrink(complexScalarFieldTilde&& in) const;
175  friend struct FluidSolver;
176  friend struct SlabEpsilon;
177  friend struct ChargedDefect;
178 };
179 
180 #endif // JDFTX_CORE_COULOMB_H
Wigner-Seitz volume spherical truncation [J. Spencer et al, PRB 77, 193110 (2008)].
Definition: Coulomb.h:57
Wigner-Seitz cell truncation [R. Sundararaman et al, arXiv:1302.6204].
Definition: Coulomb.h:58
point charge distribution on left end of operator (use for pointCharge^ K smooth) ...
Definition: Coulomb.h:107
PointChargeMode
Special point-charge handling mode when using embedded truncation.
Definition: Coulomb.h:105
Geometry
Truncation geometry.
Definition: Coulomb.h:31
Simulation grid descriptor.
Definition: GridInfo.h:45
STL strings and streams with case insensitive comparison.
Abstract base class for Ewald summation in arbitrary dimension.
Definition: Coulomb.h:90
Auxiliary function method (3D periodic systems only) [P. Carrier et al, PRB 75, 205126 (2007)]...
Definition: Coulomb.h:55
smooth charge distributions, no handling required
Definition: Coulomb.h:106
std::set< double > omegaSet
set of exchange erf-screening parameters
Definition: Coulomb.h:61
std::shared_ptr< struct Supercell > supercell
Description of k-point supercell for exchange.
Definition: Coulomb.h:62
Helper class for evaluating regularized Coulomb kernel for exchange.
Definition: Coulomb_ExchangeEval.h:27
int sp
species index for atom; used for VDW
Definition: Coulomb.h:80
std::shared_ptr< ScalarFieldTildeData > ScalarFieldTilde
A smart reference-counting pointer to ScalarFieldTildeData.
Definition: ScalarField.h:45
Cylindrical truncation, with 1D periodicity along axis.
Definition: Coulomb.h:35
vector3 embedCenter
&#39;center&#39; of the system, when it is embedded into the larger box (in lattice coordinates) ...
Definition: Coulomb.h:46
bool embedFluidMode
if true, don&#39;t truncate, just evaluate coulomb interactions in the larger box (fluid screening does t...
Definition: Coulomb.h:47
vector3 pos
position in lattice coordinates (covariant)
Definition: Coulomb.h:77
std::shared_ptr< class Coulomb > createCoulomb(const GridInfo &gInfo) const
Create a Coulomb object corresponding to the parameters of this class.
ExchangeRegularization
Regularization method for G=0 singularities in exchange.
Definition: Coulomb.h:53
int atomicNumber
atomic number
Definition: Coulomb.h:79
Abstract base class for the fluid solvers.
Definition: FluidSolver.h:31
Definition: Coulomb.h:29
Definition: Dump_internal.h:60
Fully periodic calculation (default)
Definition: Coulomb.h:32
const GridInfo & gInfo
embedding grid, which is 2x larger in truncated directions if params.embed == true ...
Definition: Coulomb.h:138
Information required for pair-potential evaluations.
Definition: Coulomb.h:75
std::shared_ptr< complexScalarFieldTildeData > complexScalarFieldTilde
A smart reference-counting pointer to complexScalarFieldTildeData.
Definition: ScalarField.h:47
Abstract base class for the (optionally truncated) Coulomb interaction.
Definition: Coulomb.h:101
Isolated system (all directions truncated)
Definition: Coulomb.h:36
Wigner-Seitz construction for a 3D lattice (2D lattice may be handled with orthogonal 3rd direction) ...
Definition: WignerSeitz.h:32
vector3< bool > isTruncated() const
Get a list of which directions are truncated:
bool embed
whether to embed in double-sized box (along truncated directions) to compute Coulomb interactions ...
Definition: Coulomb.h:45
Geometry geometry
Truncation geometry.
Definition: Coulomb.h:39
vector3 Efield
electric field (in Cartesian coordinates, atomic units [Eh/e/a0])
Definition: Coulomb.h:49
Spherical isolation in all directions.
Definition: Coulomb.h:37
ExchangeRegularization exchangeRegularization
exchange regularization method
Definition: Coulomb.h:60
Geometry of the simulation grid.
Definition: Dump_internal.h:68
double Z
charge
Definition: Coulomb.h:76
double Rc
Truncation radius for cylindrical / spherical modes (0 => in-radius of Wigner-Seitz cell) ...
Definition: Coulomb.h:41
Special class for storing real reciprocal-space kernels encountered ever so often for convolutions...
Definition: ScalarField.h:180
Truncated along two lattice directions, periodic in one.
Definition: Coulomb.h:34
vector3 force
force in lattice coordinates (contravariant)
Definition: Coulomb.h:78
std::shared_ptr< ScalarFieldData > ScalarField
A smart reference-counting pointer to ScalarFieldData.
Definition: ScalarField.h:41
int iDir
Truncated lattice direction for Slab or periodic direction for Wire.
Definition: Coulomb.h:40
double ionMargin
margin around ions when checking localization constraints
Definition: Coulomb.h:43
Ewald sum on a probe charge per unit cell (3D/2D/1D periodic systems) [J. Paier et al...
Definition: Coulomb.h:56
Truncated along one lattice direction, periodic in two.
Definition: Coulomb.h:33
No regularization (3D periodic or non-periodic systems only)
Definition: Coulomb.h:54