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>
37#include <ksdft/MixingScheme.h>
38
39namespace dftefe
40{
41 namespace ksdft
42 {
43 template <typename ValueTypeElectrostaticsCoeff,
44 typename ValueTypeElectrostaticsBasis,
45 typename ValueTypeWaveFunctionCoeff,
46 typename ValueTypeWaveFunctionBasis,
47 utils::MemorySpace memorySpace,
48 size_type dim>
50 {
51 public:
53 std::variant<Hamiltonian<float, memorySpace> *,
55 Hamiltonian<std::complex<float>, memorySpace> *,
56 Hamiltonian<std::complex<double>, memorySpace> *>;
57
59 linearAlgebra::blasLapack::scalar_type<ValueTypeElectrostaticsBasis,
60 ValueTypeWaveFunctionBasis>;
62 linearAlgebra::blasLapack::scalar_type<ValueTypeElectrostaticsCoeff,
63 ValueTypeWaveFunctionCoeff>;
64 using ValueType =
68 using OpContext = typename linearAlgebra::HermitianIterativeEigenSolver<
71 memorySpace>::OpContext;
72
73 public:
75 /* Atom related info */
76 const std::vector<utils::Point> &atomCoordinates,
77 const std::vector<double> & atomCharges,
78 const std::vector<double> & smearedChargeRadius,
79 const size_type numElectrons,
80 /* SCF related info */
81 const size_type numWantedEigenvalues,
82 const double smearingTemperature,
83 const double fermiEnergyTolerance,
84 const double fracOccupancyTolerance,
85 const double eigenSolveResidualTolerance,
86 const double scfDensityResidualNormTolerance,
87 const size_type maxChebyshevFilterPass,
88 const size_type maxSCFIter,
89 const bool evaluateEnergyEverySCF,
90 /* Mixing related info */
91 const size_type mixingHistory,
92 const double mixingParameter,
93 const bool isAdaptiveAndersonMixingParameter,
94 /* Electron density related info */
96 &electronChargeDensityInput,
97 /* Basis related info */
98 /* Field boundary */
99 std::shared_ptr<
100 const basis::FEBasisManager<ValueTypeElectrostaticsCoeff,
101 ValueTypeElectrostaticsBasis,
102 memorySpace,
103 dim>> feBMTotalCharge,
104 std::shared_ptr<const basis::FEBasisManager<ValueTypeWaveFunctionCoeff,
105 ValueTypeWaveFunctionBasis,
106 memorySpace,
107 dim>> feBMWaveFn,
108 /* Field data storages poisson solves*/
109 std::shared_ptr<
110 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
111 memorySpace>>
112 feBDTotalChargeStiffnessMatrix,
113 std::shared_ptr<
114 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
115 memorySpace>> feBDTotalChargeRhs,
116 /* Field data storages eigen solve*/
117 std::shared_ptr<
118 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
119 memorySpace>> feBDKineticHamiltonian,
120 std::shared_ptr<
121 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
122 memorySpace>>
123 feBDElectrostaticsHamiltonian,
124 std::shared_ptr<
125 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
126 memorySpace>> feBDEXCHamiltonian,
127 /* PSP/AE related info */
128 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
129 /* linAgOperations Context*/
131 linAlgOpContext,
132 /* basis overlap related info */
133 const OpContext &MContextForInv =
136 memorySpace>(),
137 const OpContext &MContext =
140 memorySpace>(),
141 const OpContext &MInvContext =
144 memorySpace>());
145
146
148 /* Atom related info */
149 const std::vector<utils::Point> &atomCoordinates,
150 const std::vector<double> & atomCharges,
151 const std::vector<double> & smearedChargeRadius,
152 const size_type numElectrons,
153 /* SCF related info */
154 const size_type numWantedEigenvalues,
155 const double smearingTemperature,
156 const double fermiEnergyTolerance,
157 const double fracOccupancyTolerance,
158 const double eigenSolveResidualTolerance,
159 const double scfDensityResidualNormTolerance,
160 const size_type maxChebyshevFilterPass,
161 const size_type maxSCFIter,
162 const bool evaluateEnergyEverySCF,
163 /* Mixing related info */
164 const size_type mixingHistory,
165 const double mixingParameter,
166 const bool isAdaptiveAndersonMixingParameter,
167 /* Electron density related info */
169 &electronChargeDensityInput,
170 /* Basis related info */
171 /* Field boundary */
172 std::shared_ptr<
173 const basis::FEBasisManager<ValueTypeElectrostaticsCoeff,
174 ValueTypeElectrostaticsBasis,
175 memorySpace,
176 dim>> feBMTotalCharge,
177 std::shared_ptr<const basis::FEBasisManager<ValueTypeWaveFunctionCoeff,
178 ValueTypeWaveFunctionBasis,
179 memorySpace,
180 dim>> feBMWaveFn,
181 /* Field data storages poisson solves */
182 std::shared_ptr<
183 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
184 memorySpace>>
185 feBDTotalChargeStiffnessMatrix,
186 std::shared_ptr<
187 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
188 memorySpace>> feBDTotalChargeRhs,
189 std::shared_ptr<
190 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
191 memorySpace>>
192 feBDNuclearChargeStiffnessMatrix,
193 std::shared_ptr<
194 const basis::FEBasisDataStorage<ValueTypeElectrostaticsBasis,
195 memorySpace>> feBDNuclearChargeRhs,
196 /* Field data storages eigen solve*/
197 std::shared_ptr<
198 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
199 memorySpace>> feBDKineticHamiltonian,
200 std::shared_ptr<
201 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
202 memorySpace>>
203 feBDElectrostaticsHamiltonian,
204 std::shared_ptr<
205 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
206 memorySpace>> feBDEXCHamiltonian,
207 /* PSP/AE related info */
208 const utils::ScalarSpatialFunctionReal &externalPotentialFunction,
209 /* linAgOperations Context*/
211 linAlgOpContext,
212 /* basis overlap related info */
213 const OpContext &MContextForInv =
216 memorySpace>(),
217 const OpContext &MContext =
220 memorySpace>(),
221 const OpContext &MInvContext =
224 memorySpace>());
225
226 ~KohnShamDFT() = default;
227
228 void
229 solve();
230
231 double
233
234 private:
236 std::vector<RealType> d_occupation;
237 const double d_SCFTol;
239 std::shared_ptr<
242 std::shared_ptr<DensityCalculator<ValueTypeWaveFunctionBasis,
243 ValueTypeWaveFunctionCoeff,
244 memorySpace,
245 dim>>
249 ValueTypeWaveFunctionBasis,
250 memorySpace,
251 dim>>
253 std::shared_ptr<ExchangeCorrelationFE<ValueTypeWaveFunctionBasis,
254 ValueTypeWaveFunctionCoeff,
255 memorySpace,
256 dim>>
258 std::shared_ptr<ElectrostaticLocalFE<ValueTypeElectrostaticsBasis,
259 ValueTypeElectrostaticsCoeff,
260 ValueTypeWaveFunctionBasis,
261 memorySpace,
262 dim>>
264 std::shared_ptr<KineticFE<ValueTypeWaveFunctionBasis,
265 ValueTypeWaveFunctionCoeff,
266 memorySpace,
267 dim>>
269
270 std::shared_ptr<const basis::FEBasisManager<ValueTypeWaveFunctionCoeff,
271 ValueTypeWaveFunctionBasis,
272 memorySpace,
273 dim>>
275 std::vector<RealType> d_kohnShamEnergies;
290 std::shared_ptr<linearAlgebra::LinAlgOpContext<memorySpace>>
297
298 std::shared_ptr<
299 const basis::FEBasisDataStorage<ValueTypeWaveFunctionBasis,
300 memorySpace>>
302
305
306 }; // end of KohnShamDFT
307 } // end of namespace ksdft
308} // end of namespace dftefe
309#include "KohnShamDFT.t.cpp"
310#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:53
An abstract class to encapsulate the partitioning of a finite element basis across multiple processor...
Definition: FEBasisManager.h:44
Definition: DensityCalculator.h:42
Definition: ElectrostaticLocalFE.h:55
Definition: ExchangeCorrelationFE.h:51
Definition: Hamiltonian.h:35
Definition: KineticFE.h:48
Definition: KohnShamDFT.h:50
const utils::mpi::MPIComm & d_mpiCommDomain
Definition: KohnShamDFT.h:288
std::vector< RealType > d_kohnShamEnergies
Definition: KohnShamDFT.h:275
linearAlgebra::Vector< ValueTypeWaveFunctionCoeff, memorySpace > d_lanczosGuess
Definition: KohnShamDFT.h:293
linearAlgebra::blasLapack::real_type< ValueType > RealType
Definition: KohnShamDFT.h:67
const size_type d_numElectrons
Definition: KohnShamDFT.h:296
const OpContext * d_MContext
Definition: KohnShamDFT.h:287
const size_type d_numWantedEigenvalues
Definition: KohnShamDFT.h:235
bool d_isSolved
Definition: KohnShamDFT.h:304
std::shared_ptr< const basis::FEBasisManager< ValueTypeWaveFunctionCoeff, ValueTypeWaveFunctionBasis, memorySpace, dim > > d_feBMWaveFn
Definition: KohnShamDFT.h:274
std::vector< RealType > d_occupation
Definition: KohnShamDFT.h:236
linearAlgebra::MultiVector< ValueType, memorySpace > * d_kohnShamWaveFunctions
Definition: KohnShamDFT.h:277
MixingScheme< RealType, RealType > d_mixingScheme
Definition: KohnShamDFT.h:289
linearAlgebra::blasLapack::scalar_type< ValueTypeOperator, ValueTypeOperator > ValueType
Definition: KohnShamDFT.h:66
bool d_isAdaptiveAndersonMixingParameter
Definition: KohnShamDFT.h:281
std::variant< Hamiltonian< float, memorySpace > *, Hamiltonian< double, memorySpace > *, Hamiltonian< std::complex< float >, memorySpace > *, Hamiltonian< std::complex< double >, memorySpace > * > HamiltonianPtrVariant
Definition: KohnShamDFT.h:56
std::shared_ptr< ElectrostaticLocalFE< ValueTypeElectrostaticsBasis, ValueTypeElectrostaticsCoeff, ValueTypeWaveFunctionBasis, memorySpace, dim > > d_hamitonianElec
Definition: KohnShamDFT.h:263
utils::MemoryStorage< RealType, utils::MemorySpace::HOST > d_jxwDataHost
Definition: KohnShamDFT.h:238
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_densityOutQuadValues
Definition: KohnShamDFT.h:284
size_type d_mixingHistory
Definition: KohnShamDFT.h:279
std::shared_ptr< const basis::FEBasisDataStorage< ValueTypeWaveFunctionBasis, memorySpace > > d_feBDEXCHamiltonian
Definition: KohnShamDFT.h:301
double d_mixingParameter
Definition: KohnShamDFT.h:280
RealType d_groundStateEnergy
Definition: KohnShamDFT.h:303
size_type d_numMaxSCFIter
Definition: KohnShamDFT.h:286
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::OpContext OpContext
Definition: KohnShamDFT.h:71
std::shared_ptr< linearAlgebra::LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: KohnShamDFT.h:291
std::shared_ptr< KineticFE< ValueTypeWaveFunctionBasis, ValueTypeWaveFunctionCoeff, memorySpace, dim > > d_hamitonianKin
Definition: KohnShamDFT.h:268
linearAlgebra::blasLapack::scalar_type< ValueTypeElectrostaticsBasis, ValueTypeWaveFunctionBasis > ValueTypeOperator
Definition: KohnShamDFT.h:60
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_densityInQuadValues
Definition: KohnShamDFT.h:284
std::shared_ptr< KohnShamEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace > > d_ksEigSolve
Definition: KohnShamDFT.h:241
bool d_evaluateEnergyEverySCF
Definition: KohnShamDFT.h:282
utils::ConditionalOStream d_rootCout
Definition: KohnShamDFT.h:278
const double d_SCFTol
Definition: KohnShamDFT.h:237
void solve()
Definition: KohnShamDFT.t.cpp:601
std::shared_ptr< KohnShamOperatorContextFE< ValueTypeOperator, ValueTypeOperand, ValueTypeWaveFunctionBasis, memorySpace, dim > > d_hamitonianOperator
Definition: KohnShamDFT.h:252
quadrature::QuadratureValuesContainer< RealType, memorySpace > d_densityResidualQuadValues
Definition: KohnShamDFT.h:285
const OpContext * d_MInvContext
Definition: KohnShamDFT.h:287
std::shared_ptr< DensityCalculator< ValueTypeWaveFunctionBasis, ValueTypeWaveFunctionCoeff, memorySpace, dim > > d_densCalc
Definition: KohnShamDFT.h:246
double getGroundStateEnergy()
Definition: KohnShamDFT.t.cpp:947
linearAlgebra::MultiVector< ValueTypeWaveFunctionCoeff, memorySpace > d_waveFunctionSubspaceGuess
Definition: KohnShamDFT.h:295
std::shared_ptr< ExchangeCorrelationFE< ValueTypeWaveFunctionBasis, ValueTypeWaveFunctionCoeff, memorySpace, dim > > d_hamitonianXC
Definition: KohnShamDFT.h:257
linearAlgebra::blasLapack::scalar_type< ValueTypeElectrostaticsCoeff, ValueTypeWaveFunctionCoeff > ValueTypeOperand
Definition: KohnShamDFT.h:63
Definition: KohnShamEigenSolver.h:59
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:45
Definition: Function.h:10
Definition: MemoryStorage.h:38
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