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
41
42namespace dftefe
43{
44 namespace ksdft
45 {
46 template <typename ValueTypeBasisData,
47 typename ValueTypeBasisCoeff,
48 typename ValueTypeWaveFnBasisData,
49 utils::MemorySpace memorySpace,
50 size_type dim>
52 : public ElectrostaticFE<ValueTypeBasisData,
53 ValueTypeBasisCoeff,
54 ValueTypeWaveFnBasisData,
55 memorySpace,
56 dim>
57 {
58 public:
59 using ValueType = typename ElectrostaticFE<ValueTypeBasisData,
60 ValueTypeBasisCoeff,
61 ValueTypeWaveFnBasisData,
62 memorySpace,
63 dim>::ValueType;
64 using Storage = typename ElectrostaticFE<ValueTypeBasisData,
65 ValueTypeBasisCoeff,
66 ValueTypeWaveFnBasisData,
67 memorySpace,
68 dim>::Storage;
69 using RealType = typename ElectrostaticFE<ValueTypeBasisData,
70 ValueTypeBasisCoeff,
71 ValueTypeWaveFnBasisData,
72 memorySpace,
73 dim>::RealType;
74
75 public:
79 // used if analytical vself canellation route taken
81 const std::vector<utils::Point> &atomCoordinates,
82 const std::vector<double> & atomCharges,
83 const std::vector<double> & smearedChargeRadius,
85 & electronChargeDensity,
86 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
87 ValueTypeBasisData,
88 memorySpace,
89 dim>> feBMTotalCharge,
90 std::shared_ptr<
92 feBDTotalChargeStiffnessMatrix,
93 std::shared_ptr<
95 feBDNuclearChargeRhs,
96 std::shared_ptr<
98 feBDElectronicChargeRhs,
99 std::shared_ptr<
100 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
101 memorySpace>> feBDHamiltonian,
102 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
104 linAlgOpContext,
105 const size_type maxCellBlock,
106 bool useDealiiMatrixFreePoissonSolve = true);
107
108 // used if numerical poisson solve vself canellation route taken
110 const std::vector<utils::Point> &atomCoordinates,
111 const std::vector<double> & atomCharges,
112 const std::vector<double> & smearedChargeRadius,
114 & electronChargeDensity,
115 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
116 ValueTypeBasisData,
117 memorySpace,
118 dim>> feBMTotalCharge,
119 std::shared_ptr<
121 feBDTotalChargeStiffnessMatrix,
122 std::shared_ptr<
124 feBDNuclearChargeRhs,
125 std::shared_ptr<
127 feBDElectronicChargeRhs,
128 std::shared_ptr<
130 feBDNuclChargeStiffnessMatrixNumSol,
131 std::shared_ptr<
133 feBDNuclChargeRhsNumSol,
134 std::shared_ptr<
135 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
136 memorySpace>> feBDHamiltonian,
137 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
139 linAlgOpContext,
140 const size_type maxCellBlock,
141 bool useDealiiMatrixFreePoissonSolve = true);
142
143 // used if delta rho approach is taken with phi total from 1D KS solve
144 // with analytical vself energy cancellation
146 const std::vector<utils::Point> &atomCoordinates,
147 const std::vector<double> & atomCharges,
148 const std::vector<double> & smearedChargeRadius,
149 // const quadrature::QuadratureValuesContainer<RealType, memorySpace>
150 // &atomicElectronChargeDensity,
151 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
152 // memorySpace>
153 // &atomicTotalElecPotNuclearQuad,
154 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
155 // memorySpace>
156 // &atomicTotalElecPotElectronicQuad,
158 &atomicTotalElectroPotentialFunction,
160 &atomicElectronicChargeDensityFunction,
161 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
162 ValueTypeBasisData,
163 memorySpace,
164 dim>>
165 feBMTotalCharge, // will be same as bc of totalCharge -
166 // atomicTotalCharge
167 std::shared_ptr<
169 feBDTotalChargeStiffnessMatrix,
170 std::shared_ptr<
172 feBDNuclearChargeRhs,
173 std::shared_ptr<
175 feBDElectronicChargeRhs,
176 std::shared_ptr<
177 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
178 memorySpace>> feBDHamiltonian,
179 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
181 linAlgOpContext,
182 const size_type maxCellBlock,
183 const bool useDealiiMatrixFreePoissonSolve = true,
184 const bool calculateIntegralDeltaRho = false);
185
186
188
189 // used if analytical vself canellation route taken
190 void
192 const std::vector<utils::Point> & atomCoordinates,
193 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
194 ValueTypeBasisData,
195 memorySpace,
196 dim>> feBMTotalCharge,
197 std::shared_ptr<
199 feBDTotalChargeStiffnessMatrix,
200 std::shared_ptr<
202 feBDNuclearChargeRhs,
203 std::shared_ptr<
205 feBDElectronicChargeRhs,
206 std::shared_ptr<
207 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
208 memorySpace>> feBDHamiltonian,
209 const utils::ScalarSpatialFunctionReal &externalPotentialFunction);
210
211 // used if numerical poisson solve vself canellation route taken
212 void
214 const std::vector<utils::Point> & atomCoordinates,
215 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
216 ValueTypeBasisData,
217 memorySpace,
218 dim>> feBMTotalCharge,
219 std::shared_ptr<
221 feBDTotalChargeStiffnessMatrix,
222 std::shared_ptr<
224 feBDNuclearChargeRhs,
225 std::shared_ptr<
227 feBDElectronicChargeRhs,
228 std::shared_ptr<
230 feBDNuclChargeStiffnessMatrixNumSol,
231 std::shared_ptr<
233 feBDNuclChargeRhsNumSol,
234 std::shared_ptr<
235 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
236 memorySpace>> feBDHamiltonian,
237 const utils::ScalarSpatialFunctionReal &externalPotentialFunction);
238
239 // used if delta rho approach is taken with phi total from 1D KS solve
240 // with analytical vself energy cancellation
241 void
243 const std::vector<utils::Point> &atomCoordinates,
244 // const quadrature::QuadratureValuesContainer<RealType, memorySpace>
245 // &atomicElectronChargeDensity,
246 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
247 // memorySpace>
248 // &atomicTotalElecPotNuclearQuad,
249 // const quadrature::QuadratureValuesContainer<ValueTypeBasisCoeff,
250 // memorySpace>
251 // &atomicTotalElecPotElectronicQuad,
253 &atomicTotalElectroPotentialFunction,
255 &atomicElectronicChargeDensityFunction,
256 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
257 ValueTypeBasisData,
258 memorySpace,
259 dim>> feBMTotalCharge,
260 std::shared_ptr<
262 feBDTotalChargeStiffnessMatrix,
263 std::shared_ptr<
265 feBDNuclearChargeRhs,
266 std::shared_ptr<
268 feBDElectronicChargeRhs,
269 std::shared_ptr<
270 const basis::FEBasisDataStorage<ValueTypeWaveFnBasisData,
271 memorySpace>> feBDHamiltonian,
272 const utils::ScalarSpatialFunctionReal &externalPotentialFunction);
273
274 void
277 &electronChargeDensity);
278
279 void
280 getLocal(Storage &cellWiseStorage) const override;
281
282 void
283 evalEnergy();
284
286 getEnergy() const override;
287
289 getFunctionalDerivative() const override;
290
291 void
295 bool updateGhostX,
296 bool updateGhostY) const override;
297
298 bool
299 hasLocalComponent() const override;
300
301 bool
302 hasNonLocalComponent() const override;
303
304 private:
305 /* Solves the nuclear potential problem, gets \sum \integral b_sm*V_sm ,
306 * gets \sum \integral V_sm * rho, \sum V_smAtRhoQuadPts
307 */
308 void
310 std::shared_ptr<
312 feBDNuclearChargeStiffnessMatrix,
313 std::shared_ptr<
315 feBDNuclearChargeRhs);
316
317 void
319
320 void
322
329 std::vector<utils::Point> d_atomCoordinates;
331 const std::vector<double> d_atomCharges;
332 const std::vector<double> d_smearedChargeRadius;
335
336 // Causing memory errors: Change these to smart pointers
351
362
365 std::vector<linearAlgebra::MultiVector<ValueType, memorySpace> *>
367
368 std::vector<std::shared_ptr<basis::FEBasisManager<ValueTypeBasisCoeff,
369 ValueTypeBasisData,
370 memorySpace,
371 dim>>>
373
374 std::shared_ptr<const basis::FEBasisOperations<ValueTypeBasisCoeff,
375 ValueTypeBasisData,
376 memorySpace,
377 dim>>
379 std::shared_ptr<const basis::FEBasisOperations<ValueTypeBasisCoeff,
380 ValueTypeBasisData,
381 memorySpace,
382 dim>>
384 std::shared_ptr<const basis::FEBasisOperations<ValueTypeBasisCoeff,
385 ValueTypeWaveFnBasisData,
386 memorySpace,
387 dim>>
389
390 std::shared_ptr<const basis::FEBasisManager<ValueTypeBasisCoeff,
391 ValueTypeBasisData,
392 memorySpace,
393 dim>>
395 std::shared_ptr<
398 std::shared_ptr<
401 std::shared_ptr<
404 std::shared_ptr<
407 std::shared_ptr<linearAlgebra::LinAlgOpContext<memorySpace>>
409 std::vector<RealType> d_nuclearChargeQuad;
411 std::shared_ptr<
413 ValueTypeBasisCoeff,
414 memorySpace,
415 dim>>
417 std::shared_ptr<
419 ValueTypeBasisCoeff,
420 memorySpace,
421 dim>>
424
426
427 std::map<
428 std::string,
429 std::shared_ptr<
432
433 }; // end of class ElectrostaticLocalFE
434 } // end of namespace ksdft
435} // end of namespace dftefe
437#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:57
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_correctionPotRhoQuad
Definition: ElectrostaticLocalFE.h:348
void getLocal(Storage &cellWiseStorage) const override
Definition: ElectrostaticLocalFE.t.cpp:1594
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDNuclChargeRhsNumSol
Definition: ElectrostaticLocalFE.h:406
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDElectronicChargeRhs
Definition: ElectrostaticLocalFE.h:400
typename ElectrostaticFE< ValueTypeBasisData, ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim >::ValueType ValueType
Definition: ElectrostaticLocalFE.h:63
RealType d_energy
Definition: ElectrostaticLocalFE.h:333
~ElectrostaticLocalFE()
Definition: ElectrostaticLocalFE.t.cpp:405
const size_type d_numAtoms
Definition: ElectrostaticLocalFE.h:330
void deleteStorages()
Definition: ElectrostaticLocalFE.t.cpp:420
std::vector< utils::Point > d_atomCoordinates
Definition: ElectrostaticLocalFE.h:329
const quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_electronChargeDensity
Definition: ElectrostaticLocalFE.h:340
RealType d_nuclearSelfEnergy
Definition: ElectrostaticLocalFE.h:334
void evalEnergy()
Definition: ElectrostaticLocalFE.t.cpp:2027
std::vector< linearAlgebra::MultiVector< ValueType, memorySpace > * > d_nuclearChargesPotential
Definition: ElectrostaticLocalFE.h:366
std::shared_ptr< electrostatics::PoissonSolverDealiiMatrixFreeFE< ValueTypeBasisData, ValueTypeBasisCoeff, memorySpace, dim > > d_poissonSolverDealiiMatFree
Definition: ElectrostaticLocalFE.h:422
utils::ConditionalOStream d_rootCout
Definition: ElectrostaticLocalFE.h:425
bool hasNonLocalComponent() const override
Definition: ElectrostaticLocalFE.t.cpp:2278
const bool d_useDealiiMatrixFreePoissonSolve
Definition: ElectrostaticLocalFE.h:323
std::shared_ptr< electrostatics::PoissonLinearSolverFunctionFE< ValueTypeBasisData, ValueTypeBasisCoeff, memorySpace, dim > > d_linearSolverFunction
Definition: ElectrostaticLocalFE.h:416
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_scratchPotHamQuad
Definition: ElectrostaticLocalFE.h:357
std::vector< RealType > d_nuclearChargeQuad
Definition: ElectrostaticLocalFE.h:409
quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_nuclearChargesDensity
Definition: ElectrostaticLocalFE.h:338
const quadrature::QuadratureValuesContainer< ValueType, memorySpace > & getFunctionalDerivative() const override
Definition: ElectrostaticLocalFE.t.cpp:2208
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:814
std::shared_ptr< const basis::FEBasisOperations< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > d_feBasisOpNuclear
Definition: ElectrostaticLocalFE.h:378
const bool d_isCalculateIntegralDeltaRho
Definition: ElectrostaticLocalFE.h:324
void computeNuclearSelfEnergy()
Definition: ElectrostaticLocalFE.t.cpp:1834
const std::vector< double > d_atomCharges
Definition: ElectrostaticLocalFE.h:331
const size_type d_numComponents
Definition: ElectrostaticLocalFE.h:328
const size_type d_maxCellBlock
Definition: ElectrostaticLocalFE.h:327
std::shared_ptr< linearAlgebra::LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: ElectrostaticLocalFE.h:408
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDNuclearChargeRhs
Definition: ElectrostaticLocalFE.h:403
typename ElectrostaticFE< ValueTypeBasisData, ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim >::RealType RealType
Definition: ElectrostaticLocalFE.h:73
quadrature::QuadratureValuesContainer< ValueTypeBasisCoeff, memorySpace > * d_atomicTotalElecPotElectronicQuad
Definition: ElectrostaticLocalFE.h:342
bool hasLocalComponent() const override
Definition: ElectrostaticLocalFE.t.cpp:2263
RealType d_totNuclearChargeQuad
Definition: ElectrostaticLocalFE.h:423
std::shared_ptr< const basis::FEBasisOperations< ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim > > d_feBasisOpHamiltonian
Definition: ElectrostaticLocalFE.h:388
bool d_isNumericalVSelfSolve
Definition: ElectrostaticLocalFE.h:325
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_scratchPotNuclearQuad
Definition: ElectrostaticLocalFE.h:361
void reinitField(const quadrature::QuadratureValuesContainer< RealType, memorySpace > &electronChargeDensity)
Definition: ElectrostaticLocalFE.t.cpp:1410
typename ElectrostaticFE< ValueTypeBasisData, ValueTypeBasisCoeff, ValueTypeWaveFnBasisData, memorySpace, dim >::Storage Storage
Definition: ElectrostaticLocalFE.h:68
std::map< std::string, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > > d_feBasisDataStorageRhsMap
Definition: ElectrostaticLocalFE.h:431
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_correctionPotNucQuad
Definition: ElectrostaticLocalFE.h:350
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_correctionPotHamQuad
Definition: ElectrostaticLocalFE.h:346
quadrature::QuadratureValuesContainer< ValueTypeBasisCoeff, memorySpace > * d_atomicTotalElecPotNuclearQuad
Definition: ElectrostaticLocalFE.h:342
quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_scratchDensRhoQuad
Definition: ElectrostaticLocalFE.h:355
size_type d_cellTimesNumVecPoisson
Definition: ElectrostaticLocalFE.h:410
void applyNonLocal(linearAlgebra::MultiVector< ValueTypeWaveFnBasisData, memorySpace > &X, linearAlgebra::MultiVector< ValueTypeWaveFnBasisData, memorySpace > &Y, bool updateGhostX, bool updateGhostY) const override
Definition: ElectrostaticLocalFE.t.cpp:2242
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_atomicElectronChargeDensity
Definition: ElectrostaticLocalFE.h:344
std::shared_ptr< const basis::FEBasisManager< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > d_feBMTotalCharge
Definition: ElectrostaticLocalFE.h:394
std::vector< std::shared_ptr< basis::FEBasisManager< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > > d_feBMNuclearCharge
Definition: ElectrostaticLocalFE.h:372
const std::vector< double > d_smearedChargeRadius
Definition: ElectrostaticLocalFE.h:332
std::shared_ptr< const basis::FEBasisOperations< ValueTypeBasisCoeff, ValueTypeBasisData, memorySpace, dim > > d_feBasisOpElectronic
Definition: ElectrostaticLocalFE.h:383
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > d_feBDTotalChargeStiffnessMatrix
Definition: ElectrostaticLocalFE.h:397
RealType getEnergy() const override
Definition: ElectrostaticLocalFE.t.cpp:2187
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_atomicElectronChargeDensityNucQuad
Definition: ElectrostaticLocalFE.h:344
linearAlgebra::MultiVector< ValueTypeBasisCoeff, memorySpace > * d_totalChargePotential
Definition: ElectrostaticLocalFE.h:364
quadrature::QuadratureValuesContainer< ValueType, memorySpace > * d_scratchPotRhoQuad
Definition: ElectrostaticLocalFE.h:359
quadrature::QuadratureValuesContainer< RealType, memorySpace > * d_scratchDensNuclearQuad
Definition: ElectrostaticLocalFE.h:353
void nuclearPotentialSolve(std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > feBDNuclearChargeStiffnessMatrix, std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeBasisData, memorySpace > > feBDNuclearChargeRhs)
Definition: ElectrostaticLocalFE.t.cpp:1640
bool d_isDeltaRhoSolve
Definition: ElectrostaticLocalFE.h:326
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