DFT-EFE
 
Loading...
Searching...
No Matches
ElectrostaticLocalFE.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Avirup Sircar
24 */
25
26#ifndef dftefeElectrostaticLocalFE_h
27#define dftefeElectrostaticLocalFE_h
28
42#include "Defaults.h"
43
44namespace dftefe
45{
46 namespace ksdft
47 {
48 template <typename ValueTypeBasisData,
49 typename ValueTypeBasisCoeff,
50 typename ValueTypeWaveFnBasisData,
51 utils::MemorySpace memorySpace,
52 size_type dim>
54 : public ElectrostaticFE<ValueTypeBasisData,
55 ValueTypeBasisCoeff,
56 ValueTypeWaveFnBasisData,
57 memorySpace,
58 dim>
59 {
60 public:
61 using ValueType = typename ElectrostaticFE<ValueTypeBasisData,
62 ValueTypeBasisCoeff,
63 ValueTypeWaveFnBasisData,
64 memorySpace,
65 dim>::ValueType;
66 using Storage = typename ElectrostaticFE<ValueTypeBasisData,
67 ValueTypeBasisCoeff,
68 ValueTypeWaveFnBasisData,
69 memorySpace,
70 dim>::Storage;
71 using RealType = typename ElectrostaticFE<ValueTypeBasisData,
72 ValueTypeBasisCoeff,
73 ValueTypeWaveFnBasisData,
74 memorySpace,
75 dim>::RealType;
76
77 public:
81 // used if analytical vself canellation route taken
83 const std::vector<utils::Point> &atomCoordinates,
84 const std::vector<double> & atomCharges,
85 const double & smearedChargeRadius,
87 & electronChargeDensity,
88 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
89 ValueTypeBasisData,
90 memorySpace,
91 dim>> feBMTotalCharge,
92 std::shared_ptr<
94 feBDTotalChargeStiffnessMatrix,
95 std::shared_ptr<
97 feBDNuclearChargeRhs,
98 std::shared_ptr<
100 feBDElectronicChargeRhs,
101 std::shared_ptr<
102 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
103 memorySpace>> feBDHamiltonian,
104 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
106 linAlgOpContext,
107 const size_type maxCellBlock,
108 bool useDealiiMatrixFreePoissonSolve = true);
109
110 // used if numerical poisson solve vself canellation route taken
112 const std::vector<utils::Point> &atomCoordinates,
113 const std::vector<double> & atomCharges,
114 const double & smearedChargeRadius,
116 & electronChargeDensity,
117 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
118 ValueTypeBasisData,
119 memorySpace,
120 dim>> feBMTotalCharge,
121 std::shared_ptr<
123 feBDTotalChargeStiffnessMatrix,
124 std::shared_ptr<
126 feBDNuclearChargeRhs,
127 std::shared_ptr<
129 feBDElectronicChargeRhs,
130 std::shared_ptr<
132 feBDNuclChargeStiffnessMatrixNumSol,
133 std::shared_ptr<
135 feBDNuclChargeRhsNumSol,
136 std::shared_ptr<
137 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
138 memorySpace>> feBDHamiltonian,
139 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
141 linAlgOpContext,
142 const size_type maxCellBlock,
143 bool useDealiiMatrixFreePoissonSolve = true);
144
145 // used if delta rho approach is taken with phi total from 1D KS solve
146 // with analytical vself energy cancellation
148 const std::vector<utils::Point> &atomCoordinates,
149 const std::vector<std::string> & atomSymbols,
150 const std::vector<double> & atomCharges,
151 const double & smearedChargeRadius,
152 // const quadrature::QuadratureValuesContainer<RealType, memorySpace>
153 // &atomicElectronChargeDensity,
154 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
155 // memorySpace>
156 // &atomicTotalElecPotNuclearQuad,
157 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
158 // memorySpace>
159 // &atomicTotalElecPotElectronicQuad,
161 &atomicTotalElectroPotentialFunction,
163 &atomicElectronicChargeDensityFunction,
164 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
165 ValueTypeBasisData,
166 memorySpace,
167 dim>>
168 feBMTotalCharge, // will be same as bc of totalCharge -
169 // atomicTotalCharge
170 std::shared_ptr<
172 feBDTotalChargeStiffnessMatrix,
173 std::shared_ptr<
175 feBDNuclearChargeRhs,
176 std::shared_ptr<
178 feBDElectronicChargeRhs,
179 std::shared_ptr<
180 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
181 memorySpace>> feBDHamiltonian,
182 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
184 linAlgOpContext,
185 const size_type maxCellBlock,
186 const std::unordered_map<std::string,
187 std::shared_ptr<atoms::AtomTCIASpline>>
188 fieldToTCIASplineMap = {},
189 const bool useDealiiMatrixFreePoissonSolve = true,
190 const bool calculateIntegralDeltaRho = false);
191
192
194
195 // used if analytical vself canellation route taken
196 void
198 const std::vector<utils::Point> & atomCoordinates,
199 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
200 ValueTypeBasisData,
201 memorySpace,
202 dim>> feBMTotalCharge,
203 std::shared_ptr<
205 feBDTotalChargeStiffnessMatrix,
206 std::shared_ptr<
208 feBDNuclearChargeRhs,
209 std::shared_ptr<
211 feBDElectronicChargeRhs,
212 std::shared_ptr<
213 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
214 memorySpace>> feBDHamiltonian,
215 const utils::ScalarSpatialFunctionReal &externalPotentialFunction);
216
217 // used if numerical poisson solve vself canellation route taken
218 void
220 const std::vector<utils::Point> & atomCoordinates,
221 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
222 ValueTypeBasisData,
223 memorySpace,
224 dim>> feBMTotalCharge,
225 std::shared_ptr<
227 feBDTotalChargeStiffnessMatrix,
228 std::shared_ptr<
230 feBDNuclearChargeRhs,
231 std::shared_ptr<
233 feBDElectronicChargeRhs,
234 std::shared_ptr<
236 feBDNuclChargeStiffnessMatrixNumSol,
237 std::shared_ptr<
239 feBDNuclChargeRhsNumSol,
240 std::shared_ptr<
241 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
242 memorySpace>> feBDHamiltonian,
243 const utils::ScalarSpatialFunctionReal &externalPotentialFunction);
244
245 // used if delta rho approach is taken with phi total from 1D KS solve
246 // with analytical vself energy cancellation
247 void
249 const std::vector<utils::Point> &atomCoordinates,
250 // const quadrature::QuadratureValuesContainer<RealType, memorySpace>
251 // &atomicElectronChargeDensity,
252 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
253 // memorySpace>
254 // &atomicTotalElecPotNuclearQuad,
255 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
256 // memorySpace>
257 // &atomicTotalElecPotElectronicQuad,
259 &atomicTotalElectroPotentialFunction,
261 &atomicElectronicChargeDensityFunction,
262 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
263 ValueTypeBasisData,
264 memorySpace,
265 dim>> feBMTotalCharge,
266 std::shared_ptr<
268 feBDTotalChargeStiffnessMatrix,
269 std::shared_ptr<
271 feBDNuclearChargeRhs,
272 std::shared_ptr<
274 feBDElectronicChargeRhs,
275 std::shared_ptr<
276 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
277 memorySpace>> feBDHamiltonian,
278 const utils::ScalarSpatialFunctionReal &externalPotentialFunction);
279
280 void
283 &electronChargeDensity);
284
285 void
286 getLocal(Storage &cellWiseStorage) const override;
287
288 void
289 evalEnergy();
290
292 getEnergy() const override;
293
295 getFunctionalDerivative() const override;
296
297 void
301 bool updateGhostX,
302 bool updateGhostY) const override;
303
304 bool
305 hasLocalComponent() const override;
306
307 bool
308 hasNonLocalComponent() const override;
309
310 private:
311 /* Solves the nuclear potential problem, gets \sum \integral b_sm*V_sm ,
312 * gets \sum \integral V_sm * rho, \sum V_smAtRhoQuadPts
313 */
314 void
316 std::shared_ptr<
318 feBDNuclearChargeStiffnessMatrix,
319 std::shared_ptr<
321 feBDNuclearChargeRhs);
322
323 void
325
326 void
328
335 std::vector<utils::Point> d_atomCoordinates;
337 const std::vector<double> d_atomCharges;
341
342 // Causing memory errors: Change these to smart pointers
350 d_atomicElectronChargeDensity /*,d_atomicElectronChargeDensityNucQuad*/;
355
366
369 std::vector<linearAlgebra::MultiVector<ValueType, memorySpace> *>
371
372 std::vector<std::shared_ptr<basis::FEBasisManager<ValueTypeBasisCoeff,
373 ValueTypeBasisData,
374 memorySpace,
375 dim>>>
377
378 std::shared_ptr<const basis::FEBasisOperations<ValueTypeBasisCoeff,
379 ValueTypeBasisData,
380 memorySpace,
381 dim>>
383 std::shared_ptr<const basis::FEBasisOperations<ValueTypeBasisCoeff,
384 ValueTypeBasisData,
385 memorySpace,
386 dim>>
388 std::shared_ptr<const basis::FEBasisOperations<ValueTypeBasisCoeff,
389 ValueTypeWaveFnBasisData,
390 memorySpace,
391 dim>>
393
394 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
395 ValueTypeBasisData,
396 memorySpace,
397 dim>>
399 std::shared_ptr<
402 std::shared_ptr<
405 std::shared_ptr<
408 std::shared_ptr<
411 std::shared_ptr<linearAlgebra::LinAlgOpContext<memorySpace>>
413 std::vector<RealType> d_nuclearChargeQuad;
415 std::shared_ptr<
417 ValueTypeBasisCoeff,
418 memorySpace,
419 dim>>
421 std::shared_ptr<
423 ValueTypeBasisCoeff,
424 memorySpace,
425 dim>>
428
430
431 std::map<
432 std::string,
433 std::shared_ptr<
436
439
440 std::vector<std::string> d_atomSymbolVec;
441 const std::unordered_map<std::string,
442 std::shared_ptr<atoms::AtomTCIASpline>>
447
448 }; // end of class ElectrostaticLocalFE
449 } // end of namespace ksdft
450} // end of namespace dftefe
452#endif // dftefeElectrostaticLocalFE_h
An abstract class to store and access data for a given basis, such as the basis function values on a ...
Definition: FEBasisDataStorage.h:54
An abstract class to encapsulate the partitioning of a finite element basis across multiple processor...
Definition: FEBasisManager.h:44
Definition: FEBasisOperations.h:57
A derived class of linearAlgebra::LinearSolverFunction to encapsulate the Poisson partial differentia...
Definition: PoissonLinearSolverFunctionFE.h:77
A derived class of linearAlgebra::LinearSolverFunction to encapsulate the Poisson partial differentia...
Definition: PoissonSolverDealiiMatrixFreeFE.h:73
A derived class of linearAlgebra::OperatorContext to encapsulate the action of a discrete operator on...
Definition: ElectrostaticFE.h:65
Definition: ElectrostaticLocalFE.h:59
RealType d_intRhoAtPhiAt
Definition: ElectrostaticLocalFE.h:437
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_correctionPotRhoQuad
Definition: ElectrostaticLocalFE.h:354
void getLocal(Storage &cellWiseStorage) const override
Definition: ElectrostaticLocalFE.t.cpp:1882
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDNuclChargeRhsNumSol
Definition: ElectrostaticLocalFE.h:410
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDElectronicChargeRhs
Definition: ElectrostaticLocalFE.h:404
typename ElectrostaticFE< ValueTypeBasisData, ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim >::ValueType ValueType
Definition: ElectrostaticLocalFE.h:65
RealType d_energy
Definition: ElectrostaticLocalFE.h:339
~ElectrostaticLocalFE()
Definition: ElectrostaticLocalFE.t.cpp:435
const size_type d_numAtoms
Definition: ElectrostaticLocalFE.h:336
void deleteStorages()
Definition: ElectrostaticLocalFE.t.cpp:450
std::vector< utils::Point > d_atomCoordinates
Definition: ElectrostaticLocalFE.h:335
double d_integralAtRho
Definition: ElectrostaticLocalFE.h:446
const quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_electronChargeDensity
Definition: ElectrostaticLocalFE.h:346
RealType d_nuclearSelfEnergy
Definition: ElectrostaticLocalFE.h:340
void evalEnergy()
Definition: ElectrostaticLocalFE.t.cpp:2334
std::vector< linearAlgebra::MultiVector< ValueType, memorySpace > * > d_nuclearChargesPotential
Definition: ElectrostaticLocalFE.h:370
std::shared_ptr< electrostatics::PoissonSolverDealiiMatrixFreeFE< ValueTypeBasisData, ValueTypeBasisCoeff, memorySpace, dim > > d_poissonSolverDealiiMatFree
Definition: ElectrostaticLocalFE.h:426
utils::ConditionalOStream d_rootCout
Definition: ElectrostaticLocalFE.h:429
bool hasNonLocalComponent() const override
Definition: ElectrostaticLocalFE.t.cpp:2603
const std::unordered_map< std::string, std::shared_ptr< atoms::AtomTCIASpline > > d_fieldToTCIASplineMap
Definition: ElectrostaticLocalFE.h:443
bool d_isTCIEnabled
Definition: ElectrostaticLocalFE.h:444
std::shared_ptr< electrostatics::PoissonLinearSolverFunctionFE< ValueTypeBasisData, ValueTypeBasisCoeff, memorySpace, dim > > d_linearSolverFunction
Definition: ElectrostaticLocalFE.h:420
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_scratchPotHamQuad
Definition: ElectrostaticLocalFE.h:361
std::vector< RealType > d_nuclearChargeQuad
Definition: ElectrostaticLocalFE.h:413
quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_nuclearChargesDensity
Definition: ElectrostaticLocalFE.h:344
const quadrature::QuadratureValuesContainer< ValueType, memorySpace > & getFunctionalDerivative() const override
Definition: ElectrostaticLocalFE.t.cpp:2533
void reinitBasis(const std::vector< utils::Point > &atomCoordinates, std::shared_ptr< const basis::FEBasisManager< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > feBMTotalCharge, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > feBDTotalChargeStiffnessMatrix, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > feBDNuclearChargeRhs, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > feBDElectronicChargeRhs, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeWaveFnBasisData, memorySpace > > feBDHamiltonian, const utils::ScalarSpatialFunctionReal &externalPotentialFunction)
Definition: ElectrostaticLocalFE.t.cpp:835
std::shared_ptr< const basis::FEBasisOperations< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > d_feBasisOpNuclear
Definition: ElectrostaticLocalFE.h:382
std::vector< std::string > d_atomSymbolVec
Definition: ElectrostaticLocalFE.h:440
const bool d_isCalculateIntegralDeltaRho
Definition: ElectrostaticLocalFE.h:330
quadrature::QuadratureValuesContainer< ValueTypeBasisCoeff, memorySpace > * d_atomicTotalElecPotElectronicQuad
Definition: ElectrostaticLocalFE.h:348
void computeNuclearSelfEnergy()
Definition: ElectrostaticLocalFE.t.cpp:2123
const std::vector< double > d_atomCharges
Definition: ElectrostaticLocalFE.h:337
const size_type d_numComponents
Definition: ElectrostaticLocalFE.h:334
const size_type d_maxCellBlock
Definition: ElectrostaticLocalFE.h:333
std::shared_ptr< linearAlgebra::LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: ElectrostaticLocalFE.h:412
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDNuclearChargeRhs
Definition: ElectrostaticLocalFE.h:407
typename ElectrostaticFE< ValueTypeBasisData, ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim >::RealType RealType
Definition: ElectrostaticLocalFE.h:75
bool hasLocalComponent() const override
Definition: ElectrostaticLocalFE.t.cpp:2588
RealType d_totNuclearChargeQuad
Definition: ElectrostaticLocalFE.h:427
std::shared_ptr< const basis::FEBasisOperations< ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim > > d_feBasisOpHamiltonian
Definition: ElectrostaticLocalFE.h:392
RealType d_integralPhiAtxbSmear
Definition: ElectrostaticLocalFE.h:437
bool d_isNumericalVSelfSolve
Definition: ElectrostaticLocalFE.h:331
double d_integralDiffVZZCorrVSmearxSumBZZCorrBSmear
Definition: ElectrostaticLocalFE.h:445
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_scratchPotNuclearQuad
Definition: ElectrostaticLocalFE.h:365
void reinitField(const quadrature::QuadratureValuesContainer< RealType, memorySpace > &electronChargeDensity)
Definition: ElectrostaticLocalFE.t.cpp:1623
typename ElectrostaticFE< ValueTypeBasisData, ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim >::Storage Storage
Definition: ElectrostaticLocalFE.h:70
std::map< std::string, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > > d_feBasisDataStorageRhsMap
Definition: ElectrostaticLocalFE.h:435
RealType d_correctionEnergyAtomic
Definition: ElectrostaticLocalFE.h:438
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_correctionPotHamQuad
Definition: ElectrostaticLocalFE.h:352
bool d_useDealiiMatrixFreePoissonSolve
Definition: ElectrostaticLocalFE.h:329
quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_scratchDensRhoQuad
Definition: ElectrostaticLocalFE.h:359
size_type d_cellTimesNumVecPoisson
Definition: ElectrostaticLocalFE.h:414
void applyNonLocal(linearAlgebra::MultiVector< ValueTypeWaveFnBasisData, memorySpace > &X, linearAlgebra::MultiVector< ValueTypeWaveFnBasisData, memorySpace > &Y, bool updateGhostX, bool updateGhostY) const override
Definition: ElectrostaticLocalFE.t.cpp:2567
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_atomicElectronChargeDensity
Definition: ElectrostaticLocalFE.h:350
std::shared_ptr< const basis::FEBasisManager< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > d_feBMTotalCharge
Definition: ElectrostaticLocalFE.h:398
std::vector< std::shared_ptr< basis::FEBasisManager< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > > d_feBMNuclearCharge
Definition: ElectrostaticLocalFE.h:376
std::shared_ptr< const basis::FEBasisOperations< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > d_feBasisOpElectronic
Definition: ElectrostaticLocalFE.h:387
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDTotalChargeStiffnessMatrix
Definition: ElectrostaticLocalFE.h:401
const double d_smearedChargeRadius
Definition: ElectrostaticLocalFE.h:338
RealType getEnergy() const override
Definition: ElectrostaticLocalFE.t.cpp:2512
linearAlgebra::MultiVector< ValueTypeBasisCoeff, memorySpace > * d_totalChargePotential
Definition: ElectrostaticLocalFE.h:368
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_scratchPotRhoQuad
Definition: ElectrostaticLocalFE.h:363
quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_scratchDensNuclearQuad
Definition: ElectrostaticLocalFE.h:357
void nuclearPotentialSolve(std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > feBDNuclearChargeStiffnessMatrix, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > feBDNuclearChargeRhs)
Definition: ElectrostaticLocalFE.t.cpp:1928
bool d_isDeltaRhoSolve
Definition: ElectrostaticLocalFE.h:332
Definition: LinAlgOpContext.h:38
An class template to encapsulate a MultiVector. A MultiVector is a collection of vectors belonging t...
Definition: MultiVector.h:134
Definition: QuadratureValuesContainer.h:39
Provides an interface to print based on whether a certain condition is met or not....
Definition: ConditionalOStream.h:47
Definition: Function.h:10
MemorySpace
Definition: MemorySpaceType.h:37
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
unsigned int size_type
Definition: TypeConfig.h:8
Definition: TypeConfig.h:15