DFT-EFE
 
Loading...
Searching...
No Matches
KohnShamEigenSolver.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 dftefeKohnShamEigenSolver_h
27#define dftefeKohnShamEigenSolver_h
28
36#include <memory>
38#include <utils/Profiler.h>
40#include <ksdft/KSAttributes.h>
41
42namespace dftefe
43{
44 namespace ksdft
45 {
56 template <typename ValueTypeOperator,
57 typename ValueTypeOperand,
58 utils::MemorySpace memorySpace>
60 : public linearAlgebra::HermitianIterativeEigenSolver<ValueTypeOperator,
61 ValueTypeOperand,
62 memorySpace>
63 {
64 public:
71 using ValueType = typename linearAlgebra::HermitianIterativeEigenSolver<
72 ValueTypeOperator,
73 ValueTypeOperand,
74 memorySpace>::ValueType;
75 using RealType = typename linearAlgebra::HermitianIterativeEigenSolver<
76 ValueTypeOperator,
77 ValueTypeOperand,
78 memorySpace>::RealType;
79 using OpContext = typename linearAlgebra::HermitianIterativeEigenSolver<
80 ValueTypeOperator,
81 ValueTypeOperand,
82 memorySpace>::OpContext;
83
84 public:
92 const size_type numElectrons,
93 const double smearingTemperature,
94 const double fermiEnergyTolerance,
95 const double fracOccupancyTolerance,
96 const double eigenSolveResidualTolerance,
97 const size_type maxChebyshevFilterPass,
98 const size_type numWantedEigenvalues,
99 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
100 mpiPatternP2P,
102 linAlgOpContext,
104 bool isResidualChebyshevFilter = true,
105 const size_type waveFunctionBatchSize = 0,
106 const OpContext &MLanczos =
108 ValueTypeOperand,
109 memorySpace>(),
110 const OpContext &MInvLanczos =
112 ValueTypeOperand,
113 memorySpace>(),
114 const bool isGHEP = true,
117 bool storeIntermediateSubspaces = false,
118 bool useSameScratchInEigenSolver = true,
120 CalculationType calculationType = CalculationType::PSP);
121
127
128 void
130 mpiPatternP2P,
132 linAlgOpContext,
133 const OpContext &MLanczos =
135 ValueTypeOperand,
136 memorySpace>(),
137 const OpContext &MInvLanczos =
139 ValueTypeOperand,
140 memorySpace>());
141
142 void
143 reinitBounds(double wantedSpectrumLowerBound,
144 double wantedSpectrumUpperBound);
145
148
149 std::vector<RealType>
151
152 std::vector<RealType>
154
155 void
156 setChebyPolyScalingFactor(double scalingFactor);
157
158 void
160
161 void
163
165 solve(const OpContext & kohnShamOperator,
166 std::vector<RealType> &kohnShamEnergies,
168 & kohnShamWaveFunctions,
169 bool computeWaveFunctions = false,
170 const OpContext &M =
172 ValueTypeOperand,
173 memorySpace>(),
174 const OpContext &MInv =
176 ValueTypeOperand,
177 memorySpace>()) override;
178
181
184
185 void
187
188 private:
189 std::vector<double>
191 const OpContext &kohnShamOperator,
193 & kohnShamWaveFunctions,
194 const OpContext &M);
195
208 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
210 std::shared_ptr<linearAlgebra::LinAlgOpContext<memorySpace>>
214 std::vector<RealType> d_fracOccupancy;
215 std::vector<RealType> d_eigSolveResNorm;
227
228 std::shared_ptr<
230 ValueTypeOperand,
231 memorySpace>>
233
240
242 std::shared_ptr<linearAlgebra::MultiVector<ValueType, memorySpace>>
247
252
253 std::shared_ptr<linearAlgebra::MultivectorScratch<ValueType, memorySpace>>
255
256 }; // end of class KohnShamEigenSolver
257 } // namespace ksdft
258} // end of namespace dftefe
260#endif // dftefeKohnShamEigenSolver_h
Definition: KohnShamEigenSolver.h:63
RealType getFermiEnergy()
Definition: KohnShamEigenSolver.t.cpp:803
utils::MemoryStorage< ValueType, memorySpace > d_kohnShamEnergiesMemspace
Definition: KohnShamEigenSolver.h:245
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_MXBatchSmall
Definition: KohnShamEigenSolver.h:244
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::OpContext OpContext
Definition: KohnShamEigenSolver.h:82
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_HXBatch
Definition: KohnShamEigenSolver.h:243
bool d_isSolved
Definition: KohnShamEigenSolver.h:217
const size_type d_S
Definition: KohnShamEigenSolver.h:197
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::ValueType ValueType
define ValueType as the superior (bigger set) of the ValueTypeOperator and ValueTypeOperand (e....
Definition: KohnShamEigenSolver.h:74
size_type d_maxChebyshevFilterPass
Definition: KohnShamEigenSolver.h:202
const linearAlgebra::ElpaScalapackManager * d_elpaScala
Definition: KohnShamEigenSolver.h:249
std::shared_ptr< linearAlgebra::ChebyshevFilteredEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace > > d_chfsi
Definition: KohnShamEigenSolver.h:232
utils::Profiler< memorySpace > d_pTotal
Definition: KohnShamEigenSolver.h:237
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_HXBatchSmall
Definition: KohnShamEigenSolver.h:243
void reinitBasis(std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > mpiPatternP2P, std::shared_ptr< linearAlgebra::LinAlgOpContext< memorySpace > > linAlgOpContext, const OpContext &MLanczos=linearAlgebra::IdentityOperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace >(), const OpContext &MInvLanczos=linearAlgebra::IdentityOperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace >())
Definition: KohnShamEigenSolver.t.cpp:182
double d_eigenSolveResidualTolerance
Definition: KohnShamEigenSolver.h:201
linearAlgebra::OrthogonalizationType d_orthoType
Definition: KohnShamEigenSolver.h:248
const size_type d_numElectrons
Definition: KohnShamEigenSolver.h:218
bool d_isChebyPolDegComputed
Definition: KohnShamEigenSolver.h:225
double d_smearingTemperature
Definition: KohnShamEigenSolver.h:198
bool d_isBoundKnown
Definition: KohnShamEigenSolver.h:222
linearAlgebra::EigenSolverError solve(const OpContext &kohnShamOperator, std::vector< RealType > &kohnShamEnergies, linearAlgebra::MultiVector< ValueType, memorySpace > &kohnShamWaveFunctions, bool computeWaveFunctions=false, const OpContext &M=linearAlgebra::IdentityOperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace >(), const OpContext &MInv=linearAlgebra::IdentityOperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace >()) override
Definition: KohnShamEigenSolver.t.cpp:297
void setResidualChebyshevFilterFlag(bool flag)
Definition: KohnShamEigenSolver.t.cpp:287
std::shared_ptr< linearAlgebra::MultivectorScratch< ValueType, memorySpace > > d_scratch
Definition: KohnShamEigenSolver.h:254
const OpContext * d_MInvLanczos
Definition: KohnShamEigenSolver.h:213
void setChebyshevPolynomialDegree(size_type chebyPolyDeg)
Definition: KohnShamEigenSolver.t.cpp:276
utils::ConditionalOStream d_rootCout
Definition: KohnShamEigenSolver.h:219
linearAlgebra::MultiVector< ValueType, memorySpace > & getFilteredSubspace()
Definition: KohnShamEigenSolver.t.cpp:1005
std::shared_ptr< linearAlgebra::LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: KohnShamEigenSolver.h:211
std::vector< RealType > getEigenSolveResidualNorm()
Definition: KohnShamEigenSolver.t.cpp:987
SpinMode d_spinMode
Definition: KohnShamEigenSolver.h:196
const OpContext * d_MLanczos
Definition: KohnShamEigenSolver.h:212
bool d_setChebyPolDegExternally
Definition: KohnShamEigenSolver.h:224
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_MXBatch
Definition: KohnShamEigenSolver.h:243
linearAlgebra::MultiVector< ValueType, memorySpace > & getOrthogonalizedFilteredSubspace()
Definition: KohnShamEigenSolver.t.cpp:1023
std::vector< RealType > d_fracOccupancy
Definition: KohnShamEigenSolver.h:214
RealType d_fermiEnergy
Definition: KohnShamEigenSolver.h:216
bool d_useSameScratch
Definition: KohnShamEigenSolver.h:251
std::vector< RealType > d_eigSolveResNorm
Definition: KohnShamEigenSolver.h:215
~KohnShamEigenSolver()=default
Default Destructor.
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_waveFnBatch
Definition: KohnShamEigenSolver.h:243
double d_wantedSpectrumLowerBound
Definition: KohnShamEigenSolver.h:220
void reinitBounds(double wantedSpectrumLowerBound, double wantedSpectrumUpperBound)
Definition: KohnShamEigenSolver.t.cpp:252
void setChebyPolyScalingFactor(double scalingFactor)
Definition: KohnShamEigenSolver.t.cpp:266
double d_chebyPolyScalingFactor
Definition: KohnShamEigenSolver.h:223
size_type d_waveFunctionBatchSize
Definition: KohnShamEigenSolver.h:205
bool d_isResidualChebyFilter
Definition: KohnShamEigenSolver.h:238
linearAlgebra::MultiVector< ValueType, memorySpace > * d_filteredSubspace
Definition: KohnShamEigenSolver.h:236
CalculationType d_calculationType
Definition: KohnShamEigenSolver.h:226
utils::Profiler< memorySpace > d_p
Definition: KohnShamEigenSolver.h:237
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::RealType RealType
Definition: KohnShamEigenSolver.h:78
std::vector< double > getLinearEigenSolveResidual(const OpContext &kohnShamOperator, const linearAlgebra::MultiVector< ValueType, memorySpace > &kohnShamWaveFunctions, const OpContext &M)
Definition: KohnShamEigenSolver.t.cpp:832
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition: KohnShamEigenSolver.h:209
const bool d_storeIntermediateSubspaces
Definition: KohnShamEigenSolver.h:239
bool d_isGHEP
Definition: KohnShamEigenSolver.h:250
double d_fracOccupancyTolerance
Definition: KohnShamEigenSolver.h:200
size_type d_chebyshevPolynomialDegree
Definition: KohnShamEigenSolver.h:203
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_waveFnBatchSmall
Definition: KohnShamEigenSolver.h:243
std::vector< RealType > getFractionalOccupancy()
Definition: KohnShamEigenSolver.t.cpp:819
linearAlgebra::MultiVector< ValueTypeOperand, memorySpace > * d_waveFunctionSubspaceGuess
Definition: KohnShamEigenSolver.h:207
double d_fermiEnergyTolerance
Definition: KohnShamEigenSolver.h:199
size_type d_batchSizeSmall
Definition: KohnShamEigenSolver.h:241
linearAlgebra::MultiVector< ValueType, memorySpace > * d_filteredSubspaceOrtho
Definition: KohnShamEigenSolver.h:235
const size_type d_numWantedEigenvalues
Definition: KohnShamEigenSolver.h:204
double d_wantedSpectrumUpperBound
Definition: KohnShamEigenSolver.h:221
utils::MemoryStorage< ValueType, memorySpace > d_nOnes
Definition: KohnShamEigenSolver.h:246
void printTotalInScopeTimings()
Definition: KohnShamEigenSolver.t.cpp:1036
A derived class of OperatorContext to encapsulate the action of a discrete operator on vectors,...
Definition: ChebyshevFilteredEigenSolver.h:71
Manager class for ELPA and ScaLAPACK.
Definition: ElpaScalapackManager.h:43
Abstract class to encapsulate the action of a discrete operator on vectors, matrices,...
Definition: IdentityOperatorContext.h:53
Definition: LinAlgOpContext.h:52
An class template to encapsulate a MultiVector. A MultiVector is a collection of vectors belonging t...
Definition: MultiVector.h:134
Provides an interface to print based on whether a certain condition is met or not....
Definition: ConditionalOStream.h:47
Definition: MemoryStorage.h:38
Definition: Profiler.h:50
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition: MPIPatternP2P.h:197
SpinMode
Definition: KSAttributes.h:55
CalculationType
Definition: KSAttributes.h:66
OrthogonalizationType
Definition: ChebyshevFilteredEigenSolver.h:47
MemorySpace
Definition: MemorySpaceType.h:37
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9
Definition: LinearAlgebraTypes.h:154