DFT-EFE
 
Loading...
Searching...
No Matches
KohnShamDFT.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 dftefeKohnShamDFT_h
27#define dftefeKohnShamDFT_h
28
29#include <variant>
31#include <ksdft/KineticFE.h>
38#include <ksdft/MixingScheme.h>
39#include <utils/Profiler.h>
40
41namespace dftefe
42{
43 namespace ksdft
44 {
45 template <typename ValueTypeElectrostaticsCoeff,
46 typename ValueTypeElectrostaticsBasis,
47 typename ValueTypeWaveFunctionCoeff,
48 typename ValueTypeWaveFunctionBasis,
49 utils::MemorySpace memorySpace,
50 size_type dim>
52 {
53 public:
55 std::variant<Hamiltonian<float, memorySpace> *,
57 Hamiltonian<std::complex<float>, memorySpace> *,
58 Hamiltonian<std::complex<double>, memorySpace> *>;
59
61 linearAlgebra::blasLapack::scalar_type<ValueTypeElectrostaticsBasis,
62 ValueTypeWaveFunctionBasis>;
64 linearAlgebra::blasLapack::scalar_type<ValueTypeElectrostaticsCoeff,
65 ValueTypeWaveFunctionCoeff>;
66 using ValueType =
70 using OpContext = typename linearAlgebra::HermitianIterativeEigenSolver<
73 memorySpace>::OpContext;
74
75 public:
77 /* Atom related info */
78 const std::vector<utils::Point> &atomCoordinates,
79 const std::vector<double> & atomCharges,
80 const std::vector<double> & smearedChargeRadius,
81 const size_type numElectrons,
82 /* SCF related info */
83 const size_type numWantedEigenvalues,
84 const double smearingTemperature,
85 const double fermiEnergyTolerance,
86 const double fracOccupancyTolerance,
87 const double eigenSolveResidualTolerance,
88 const double scfDensityResidualNormTolerance,
89 const size_type maxChebyshevFilterPass,
90 const size_type maxSCFIter,
91 const bool evaluateEnergyEverySCF,
92 /* Mixing related info */
93 const size_type mixingHistory,
94 const double mixingParameter,
95 const bool isAdaptiveAndersonMixingParameter,
96 /* Electron density related info */
98 &electronChargeDensityInput,
99 /* Basis related info */
100 /* Field boundary */
101 std::shared_ptr<
102 const basis::FEBasisManager<ValueTypeElectrostaticsCoeff,
103 ValueTypeElectrostaticsBasis,
104 memorySpace,
105 dim>> feBMTotalCharge,
106 std::shared_ptr<const basis::FEBasisManager<ValueTypeWaveFunctionCoeff,
107 ValueTypeWaveFunctionBasis,
108 memorySpace,
109 dim>> feBMWaveFn,
110 /* Field data storages poisson solves*/
111 std::shared_ptr<
112 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
113 memorySpace>>
114 feBDTotalChargeStiffnessMatrix,
115 std::shared_ptr<
116 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
117 memorySpace>> feBDNuclearChargeRhs,
118 std::shared_ptr<
119 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
120 memorySpace>> feBDElectronicChargeRhs,
121 /* Field data storages eigen solve*/
122 std::shared_ptr<
123 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
124 memorySpace>> feBDKineticHamiltonian,
125 std::shared_ptr<
126 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
127 memorySpace>>
128 feBDElectrostaticsHamiltonian,
129 std::shared_ptr<
130 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
131 memorySpace>> feBDEXCHamiltonian,
132 /* PSP/AE related info */
133 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
134 /* linAgOperations Context*/
136 linAlgOpContext,
137 /* basis overlap related info */
138 const OpContext &MContextForInv =
141 memorySpace>(),
142 const OpContext &MContext =
145 memorySpace>(),
146 const OpContext &MInvContext =
149 memorySpace>(),
150 bool isResidualChebyshevFilter = true);
151
152
154 /* Atom related info */
155 const std::vector<utils::Point> &atomCoordinates,
156 const std::vector<double> & atomCharges,
157 const std::vector<double> & smearedChargeRadius,
158 const size_type numElectrons,
159 /* SCF related info */
160 const size_type numWantedEigenvalues,
161 const double smearingTemperature,
162 const double fermiEnergyTolerance,
163 const double fracOccupancyTolerance,
164 const double eigenSolveResidualTolerance,
165 const double scfDensityResidualNormTolerance,
166 const size_type maxChebyshevFilterPass,
167 const size_type maxSCFIter,
168 const bool evaluateEnergyEverySCF,
169 /* Mixing related info */
170 const size_type mixingHistory,
171 const double mixingParameter,
172 const bool isAdaptiveAndersonMixingParameter,
173 /* Electron density related info */
175 &electronChargeDensityInput,
176 /* Basis related info */
177 /* Field boundary */
178 std::shared_ptr<
179 const basis::FEBasisManager<ValueTypeElectrostaticsCoeff,
180 ValueTypeElectrostaticsBasis,
181 memorySpace,
182 dim>> feBMTotalCharge,
183 std::shared_ptr<const basis::FEBasisManager<ValueTypeWaveFunctionCoeff,
184 ValueTypeWaveFunctionBasis,
185 memorySpace,
186 dim>> feBMWaveFn,
187 /* Field data storages poisson solves */
188 std::shared_ptr<
189 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
190 memorySpace>>
191 feBDTotalChargeStiffnessMatrix,
192 std::shared_ptr<
193 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
194 memorySpace>> feBDNuclearChargeRhs,
195 std::shared_ptr<
196 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
197 memorySpace>> feBDElectronicChargeRhs,
198 std::shared_ptr<
199 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
200 memorySpace>>
201 feBDNuclChargeStiffnessMatrixNumSol,
202 std::shared_ptr<
203 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
204 memorySpace>> feBDNuclChargeRhsNumSol,
205 /* Field data storages eigen solve*/
206 std::shared_ptr<
207 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
208 memorySpace>> feBDKineticHamiltonian,
209 std::shared_ptr<
210 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
211 memorySpace>>
212 feBDElectrostaticsHamiltonian,
213 std::shared_ptr<
214 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
215 memorySpace>> feBDEXCHamiltonian,
216 /* PSP/AE related info */
217 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
218 /* linAgOperations Context*/
220 linAlgOpContext,
221 /* basis overlap related info */
222 const OpContext &MContextForInv =
225 memorySpace>(),
226 const OpContext &MContext =
229 memorySpace>(),
230 const OpContext &MInvContext =
233 memorySpace>(),
234 bool isResidualChebyshevFilter = true);
235
237 /* Atom related info */
238 const std::vector<utils::Point> &atomCoordinates,
239 const std::vector<double> & atomCharges,
240 const std::vector<double> & smearedChargeRadius,
241 const size_type numElectrons,
242 /* SCF related info */
243 const size_type numWantedEigenvalues,
244 const double smearingTemperature,
245 const double fermiEnergyTolerance,
246 const double fracOccupancyTolerance,
247 const double eigenSolveResidualTolerance,
248 const double scfDensityResidualNormTolerance,
249 const size_type maxChebyshevFilterPass,
250 const size_type maxSCFIter,
251 const bool evaluateEnergyEverySCF,
252 /* Mixing related info */
253 const size_type mixingHistory,
254 const double mixingParameter,
255 const bool isAdaptiveAndersonMixingParameter,
256 /* Basis related info */
258 &electronChargeDensityInput,
259 /* Atomic Field for delta rho */
261 ValueTypeElectrostaticsCoeff,
262 memorySpace> &atomicTotalElecPotNuclearQuad,
264 ValueTypeElectrostaticsCoeff,
265 memorySpace> &atomicTotalElecPotElectronicQuad,
266 /* Field boundary */
267 std::shared_ptr<
268 const basis::FEBasisManager<ValueTypeElectrostaticsCoeff,
269 ValueTypeElectrostaticsBasis,
270 memorySpace,
271 dim>> feBMTotalCharge,
272 std::shared_ptr<const basis::FEBasisManager<ValueTypeWaveFunctionCoeff,
273 ValueTypeWaveFunctionBasis,
274 memorySpace,
275 dim>> feBMWaveFn,
276 /* Field data storages poisson solves*/
277 std::shared_ptr<
278 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
279 memorySpace>>
280 feBDTotalChargeStiffnessMatrix,
281 std::shared_ptr<
282 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
283 memorySpace>> feBDNuclearChargeRhs,
284 std::shared_ptr<
285 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
286 memorySpace>> feBDElectronicChargeRhs,
287 /* Field data storages eigen solve*/
288 std::shared_ptr<
289 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
290 memorySpace>> feBDKineticHamiltonian,
291 std::shared_ptr<
292 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
293 memorySpace>>
294 feBDElectrostaticsHamiltonian,
295 std::shared_ptr<
296 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
297 memorySpace>> feBDEXCHamiltonian,
298 /* PSP/AE related info */
299 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
300 /* linAgOperations Context*/
302 linAlgOpContext,
303 /* basis overlap related info */
304 const OpContext &MContextForInv =
307 memorySpace>(),
308 const OpContext &MContext =
311 memorySpace>(),
312 const OpContext &MInvContext =
315 memorySpace>(),
316 bool isResidualChebyshevFilter = true);
317
318 ~KohnShamDFT() = default;
319
320 void
321 solve();
322
323 double
325
326 private:
328 std::vector<RealType> d_occupation;
329 const double d_SCFTol;
331 std::shared_ptr<
334 std::shared_ptr<DensityCalculator<ValueTypeWaveFunctionBasis,
335 ValueTypeWaveFunctionCoeff,
336 memorySpace,
337 dim>>
341 ValueTypeWaveFunctionBasis,
342 memorySpace,
343 dim>>
345 std::shared_ptr<ExchangeCorrelationFE<ValueTypeWaveFunctionBasis,
346 ValueTypeWaveFunctionCoeff,
347 memorySpace,
348 dim>>
350 std::shared_ptr<ElectrostaticLocalFE<ValueTypeElectrostaticsBasis,
351 ValueTypeElectrostaticsCoeff,
352 ValueTypeWaveFunctionBasis,
353 memorySpace,
354 dim>>
356 std::shared_ptr<KineticFE<ValueTypeWaveFunctionBasis,
357 ValueTypeWaveFunctionCoeff,
358 memorySpace,
359 dim>>
361
362 std::shared_ptr<const basis::FEBasisManager<ValueTypeWaveFunctionCoeff,
363 ValueTypeWaveFunctionBasis,
364 memorySpace,
365 dim>>
367 std::vector<RealType> d_kohnShamEnergies;
382 std::shared_ptr<linearAlgebra::LinAlgOpContext<memorySpace>>
389
390 std::shared_ptr<
391 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
392 memorySpace>>
394
399
400 std::shared_ptr<ElectrostaticExcFE<ValueTypeElectrostaticsCoeff,
401 ValueTypeElectrostaticsBasis,
402 ValueTypeWaveFunctionCoeff,
403 ValueTypeWaveFunctionBasis,
404 memorySpace,
405 dim>>
409
410 }; // end of KohnShamDFT
411 } // end of namespace ksdft
412} // end of namespace dftefe
413#include "KohnShamDFT.t.cpp"
414#endif // dftefeKohnShamDFT_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: DensityCalculator.h:42
Definition: ElectrostaticExcFE.h:54
Definition: ElectrostaticLocalFE.h:57
Definition: ExchangeCorrelationFE.h:51
Definition: Hamiltonian.h:35
Definition: KineticFE.h:48
Definition: KohnShamDFT.h:52
const utils::mpi::MPIComm & d_mpiCommDomain
Definition: KohnShamDFT.h:380
std::vector< RealType > d_kohnShamEnergies
Definition: KohnShamDFT.h:367
linearAlgebra::Vector< ValueTypeWaveFunctionCoeff, memorySpace > d_lanczosGuess
Definition: KohnShamDFT.h:385
linearAlgebra::blasLapack::real_type< ValueType > RealType
Definition: KohnShamDFT.h:69
const size_type d_numElectrons
Definition: KohnShamDFT.h:388
bool d_isOEFEBasis
Definition: KohnShamDFT.h:408
const OpContext * d_MContext
Definition: KohnShamDFT.h:379
const size_type d_numWantedEigenvalues
Definition: KohnShamDFT.h:327
bool d_isSolved
Definition: KohnShamDFT.h:396
std::shared_ptr< const basis::FEBasisManager< ValueTypeWaveFunctionCoeff, ValueTypeWaveFunctionBasis, memorySpace, dim > > d_feBMWaveFn
Definition: KohnShamDFT.h:366
std::vector< RealType > d_occupation
Definition: KohnShamDFT.h:328
linearAlgebra::MultiVector< ValueType, memorySpace > * d_kohnShamWaveFunctions
Definition: KohnShamDFT.h:369
MixingScheme< RealType, RealType > d_mixingScheme
Definition: KohnShamDFT.h:381
linearAlgebra::blasLapack::scalar_type< ValueTypeOperator, ValueTypeOperator > ValueType
Definition: KohnShamDFT.h:68
bool d_isAdaptiveAndersonMixingParameter
Definition: KohnShamDFT.h:373
std::variant< Hamiltonian< float, memorySpace > *, Hamiltonian< double, memorySpace > *, Hamiltonian< std::complex< float >, memorySpace > *, Hamiltonian< std::complex< double >, memorySpace > * > HamiltonianPtrVariant
Definition: KohnShamDFT.h:58
std::shared_ptr< ElectrostaticLocalFE< ValueTypeElectrostaticsBasis, ValueTypeElectrostaticsCoeff, ValueTypeWaveFunctionBasis, memorySpace, dim > > d_hamitonianElec
Definition: KohnShamDFT.h:355
utils::MemoryStorage< RealType, utils::MemorySpace::HOST > d_jxwDataHost
Definition: KohnShamDFT.h:330
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_densityOutQuadValues
Definition: KohnShamDFT.h:376
size_type d_mixingHistory
Definition: KohnShamDFT.h:371
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeWaveFunctionBasis, memorySpace > > d_feBDEXCHamiltonian
Definition: KohnShamDFT.h:393
bool d_isResidualChebyshevFilter
Definition: KohnShamDFT.h:407
double d_mixingParameter
Definition: KohnShamDFT.h:372
RealType d_groundStateEnergy
Definition: KohnShamDFT.h:395
size_type d_numMaxSCFIter
Definition: KohnShamDFT.h:378
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::OpContext OpContext
Definition: KohnShamDFT.h:73
std::shared_ptr< linearAlgebra::LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: KohnShamDFT.h:383
std::shared_ptr< KineticFE< ValueTypeWaveFunctionBasis, ValueTypeWaveFunctionCoeff, memorySpace, dim > > d_hamitonianKin
Definition: KohnShamDFT.h:360
linearAlgebra::blasLapack::scalar_type< ValueTypeElectrostaticsBasis, ValueTypeWaveFunctionBasis > ValueTypeOperator
Definition: KohnShamDFT.h:62
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_densityInQuadValues
Definition: KohnShamDFT.h:376
std::shared_ptr< KohnShamEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace > > d_ksEigSolve
Definition: KohnShamDFT.h:333
bool d_evaluateEnergyEverySCF
Definition: KohnShamDFT.h:374
utils::ConditionalOStream d_rootCout
Definition: KohnShamDFT.h:370
std::shared_ptr< ElectrostaticExcFE< ValueTypeElectrostaticsCoeff, ValueTypeElectrostaticsBasis, ValueTypeWaveFunctionCoeff, ValueTypeWaveFunctionBasis, memorySpace, dim > > d_hamiltonianElectroExc
Definition: KohnShamDFT.h:406
utils::Profiler d_p
Definition: KohnShamDFT.h:397
const double d_SCFTol
Definition: KohnShamDFT.h:329
void solve()
Definition: KohnShamDFT.t.cpp:1110
std::shared_ptr< KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeWaveFunctionBasis, memorySpace, dim > > d_hamitonianOperator
Definition: KohnShamDFT.h:344
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_densityResidualQuadValues
Definition: KohnShamDFT.h:377
bool d_isPSPCalculation
Definition: KohnShamDFT.h:398
const OpContext * d_MInvContext
Definition: KohnShamDFT.h:379
std::shared_ptr< DensityCalculator< ValueTypeWaveFunctionBasis, ValueTypeWaveFunctionCoeff, memorySpace, dim > > d_densCalc
Definition: KohnShamDFT.h:338
double getGroundStateEnergy()
Definition: KohnShamDFT.t.cpp:1474
linearAlgebra::MultiVector< ValueTypeWaveFunctionCoeff, memorySpace > d_waveFunctionSubspaceGuess
Definition: KohnShamDFT.h:387
std::shared_ptr< ExchangeCorrelationFE< ValueTypeWaveFunctionBasis, ValueTypeWaveFunctionCoeff, memorySpace, dim > > d_hamitonianXC
Definition: KohnShamDFT.h:349
linearAlgebra::blasLapack::scalar_type< ValueTypeElectrostaticsCoeff, ValueTypeWaveFunctionCoeff > ValueTypeOperand
Definition: KohnShamDFT.h:65
Definition: KohnShamEigenSolver.h:61
A derived class of linearAlgebra::OperatorContext to encapsulate the action of a discrete Kohn-Sham o...
Definition: KohnShamOperatorContextFE.h:63
This class performs the anderson mixing in a variable agnostic way This class takes can take differen...
Definition: MixingScheme.h:61
Abstract class to encapsulate the action of a discrete operator on vectors, matrices,...
Definition: IdentityOperatorContext.h:53
Definition: LinAlgOpContext.h:38
An class template to encapsulate a MultiVector. A MultiVector is a collection of vectors belonging t...
Definition: MultiVector.h:134
A class that encapsulates a vector. This is a vector in the mathematical sense and not in the sense o...
Definition: Vector.h:122
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
Definition: MemoryStorage.h:38
Definition: Profiler.h:44
blas::scalar_type< ValueType1, ValueType2 > scalar_type
Definition: BlasLapackTypedef.h:70
blas::real_type< ValueType > real_type
Definition: BlasLapackTypedef.h:64
int MPIComm
Definition: MPITypes.h:83
MemorySpace
Definition: MemorySpaceType.h:37
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
unsigned int size_type
Definition: TypeConfig.h:8