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
41namespace dftefe
42{
43 namespace ksdft
44 {
55 template <typename ValueTypeOperator,
56 typename ValueTypeOperand,
57 utils::MemorySpace memorySpace>
59 : public linearAlgebra::HermitianIterativeEigenSolver<ValueTypeOperator,
60 ValueTypeOperand,
61 memorySpace>
62 {
63 public:
70 using ValueType = typename linearAlgebra::HermitianIterativeEigenSolver<
71 ValueTypeOperator,
72 ValueTypeOperand,
73 memorySpace>::ValueType;
74 using RealType = typename linearAlgebra::HermitianIterativeEigenSolver<
75 ValueTypeOperator,
76 ValueTypeOperand,
77 memorySpace>::RealType;
78 using OpContext = typename linearAlgebra::HermitianIterativeEigenSolver<
79 ValueTypeOperator,
80 ValueTypeOperand,
81 memorySpace>::OpContext;
82
83 public:
91 const size_type numElectrons,
92 const double smearingTemperature,
93 const double fermiEnergyTolerance,
94 const double fracOccupancyTolerance,
95 const double eigenSolveResidualTolerance,
96 const size_type maxChebyshevFilterPass,
97 const size_type numWantedEigenvalues,
98 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
99 mpiPatternP2P,
101 linAlgOpContext,
103 bool isResidualChebyshevFilter = true,
104 const size_type waveFunctionBatchSize = 0,
105 const OpContext &MLanczos =
107 ValueTypeOperand,
108 memorySpace>(),
109 const OpContext &MInvLanczos =
111 ValueTypeOperand,
112 memorySpace>(),
113 const bool isGHEP = true,
116 bool storeIntermediateSubspaces = false,
117 bool useSameScratchInEigenSolver = true);
118
124
125 void
127 mpiPatternP2P,
129 linAlgOpContext,
130 const OpContext &MLanczos =
132 ValueTypeOperand,
133 memorySpace>(),
134 const OpContext &MInvLanczos =
136 ValueTypeOperand,
137 memorySpace>());
138
139 void
140 reinitBounds(double wantedSpectrumLowerBound,
141 double wantedSpectrumUpperBound);
142
145
146 std::vector<RealType>
148
149 std::vector<RealType>
151
152 void
153 setChebyPolyScalingFactor(double scalingFactor);
154
155 void
157
158 void
160
162 solve(const OpContext & kohnShamOperator,
163 std::vector<RealType> &kohnShamEnergies,
165 & kohnShamWaveFunctions,
166 bool computeWaveFunctions = false,
167 const OpContext &M =
169 ValueTypeOperand,
170 memorySpace>(),
171 const OpContext &MInv =
173 ValueTypeOperand,
174 memorySpace>()) override;
175
178
181
182 void
184
185 private:
186 std::vector<double>
188 const OpContext &kohnShamOperator,
190 & kohnShamWaveFunctions,
191 const OpContext &M);
192
203 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
205 std::shared_ptr<linearAlgebra::LinAlgOpContext<memorySpace>>
209 std::vector<RealType> d_fracOccupancy;
210 std::vector<RealType> d_eigSolveResNorm;
220
221 std::shared_ptr<
223 ValueTypeOperand,
224 memorySpace>>
226
233
235 std::shared_ptr<linearAlgebra::MultiVector<ValueType, memorySpace>>
240
245
246 std::shared_ptr<linearAlgebra::MultivectorScratch<ValueType, memorySpace>>
248
249 }; // end of class KohnShamEigenSolver
250 } // namespace ksdft
251} // end of namespace dftefe
253#endif // dftefeKohnShamEigenSolver_h
Definition: KohnShamEigenSolver.h:62
RealType getFermiEnergy()
Definition: KohnShamEigenSolver.t.cpp:578
utils::MemoryStorage< ValueType, memorySpace > d_kohnShamEnergiesMemspace
Definition: KohnShamEigenSolver.h:238
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_MXBatchSmall
Definition: KohnShamEigenSolver.h:237
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::OpContext OpContext
Definition: KohnShamEigenSolver.h:81
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_HXBatch
Definition: KohnShamEigenSolver.h:236
bool d_isSolved
Definition: KohnShamEigenSolver.h:212
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::ValueType ValueType
define ValueType as the superior (bigger set) of the ValueTypeOperator and ValueTypeOperand (e....
Definition: KohnShamEigenSolver.h:73
size_type d_maxChebyshevFilterPass
Definition: KohnShamEigenSolver.h:197
const linearAlgebra::ElpaScalapackManager * d_elpaScala
Definition: KohnShamEigenSolver.h:242
std::shared_ptr< linearAlgebra::ChebyshevFilteredEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace > > d_chfsi
Definition: KohnShamEigenSolver.h:225
utils::Profiler< memorySpace > d_pTotal
Definition: KohnShamEigenSolver.h:230
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_HXBatchSmall
Definition: KohnShamEigenSolver.h:236
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:109
double d_eigenSolveResidualTolerance
Definition: KohnShamEigenSolver.h:196
linearAlgebra::OrthogonalizationType d_orthoType
Definition: KohnShamEigenSolver.h:241
const size_type d_numElectrons
Definition: KohnShamEigenSolver.h:213
double d_smearingTemperature
Definition: KohnShamEigenSolver.h:193
bool d_isBoundKnown
Definition: KohnShamEigenSolver.h:217
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:221
void setResidualChebyshevFilterFlag(bool flag)
Definition: KohnShamEigenSolver.t.cpp:211
std::shared_ptr< linearAlgebra::MultivectorScratch< ValueType, memorySpace > > d_scratch
Definition: KohnShamEigenSolver.h:247
const OpContext * d_MInvLanczos
Definition: KohnShamEigenSolver.h:208
void setChebyshevPolynomialDegree(size_type chebyPolyDeg)
Definition: KohnShamEigenSolver.t.cpp:200
utils::ConditionalOStream d_rootCout
Definition: KohnShamEigenSolver.h:214
linearAlgebra::MultiVector< ValueType, memorySpace > & getFilteredSubspace()
Definition: KohnShamEigenSolver.t.cpp:782
std::shared_ptr< linearAlgebra::LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: KohnShamEigenSolver.h:206
std::vector< RealType > getEigenSolveResidualNorm()
Definition: KohnShamEigenSolver.t.cpp:764
const OpContext * d_MLanczos
Definition: KohnShamEigenSolver.h:207
bool d_setChebyPolDegExternally
Definition: KohnShamEigenSolver.h:219
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_MXBatch
Definition: KohnShamEigenSolver.h:236
linearAlgebra::MultiVector< ValueType, memorySpace > & getOrthogonalizedFilteredSubspace()
Definition: KohnShamEigenSolver.t.cpp:800
std::vector< RealType > d_fracOccupancy
Definition: KohnShamEigenSolver.h:209
RealType d_fermiEnergy
Definition: KohnShamEigenSolver.h:211
bool d_useSameScratch
Definition: KohnShamEigenSolver.h:244
std::vector< RealType > d_eigSolveResNorm
Definition: KohnShamEigenSolver.h:210
~KohnShamEigenSolver()=default
Default Destructor.
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_waveFnBatch
Definition: KohnShamEigenSolver.h:236
double d_wantedSpectrumLowerBound
Definition: KohnShamEigenSolver.h:215
void reinitBounds(double wantedSpectrumLowerBound, double wantedSpectrumUpperBound)
Definition: KohnShamEigenSolver.t.cpp:176
void setChebyPolyScalingFactor(double scalingFactor)
Definition: KohnShamEigenSolver.t.cpp:190
double d_chebyPolyScalingFactor
Definition: KohnShamEigenSolver.h:218
size_type d_waveFunctionBatchSize
Definition: KohnShamEigenSolver.h:200
bool d_isResidualChebyFilter
Definition: KohnShamEigenSolver.h:231
linearAlgebra::MultiVector< ValueType, memorySpace > * d_filteredSubspace
Definition: KohnShamEigenSolver.h:229
utils::Profiler< memorySpace > d_p
Definition: KohnShamEigenSolver.h:230
typename linearAlgebra::HermitianIterativeEigenSolver< ValueTypeOperator, ValueTypeOperand, memorySpace >::RealType RealType
Definition: KohnShamEigenSolver.h:77
std::vector< double > getLinearEigenSolveResidual(const OpContext &kohnShamOperator, const linearAlgebra::MultiVector< ValueType, memorySpace > &kohnShamWaveFunctions, const OpContext &M)
Definition: KohnShamEigenSolver.t.cpp:607
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition: KohnShamEigenSolver.h:204
const bool d_storeIntermediateSubspaces
Definition: KohnShamEigenSolver.h:232
bool d_isGHEP
Definition: KohnShamEigenSolver.h:243
double d_fracOccupancyTolerance
Definition: KohnShamEigenSolver.h:195
size_type d_chebyshevPolynomialDegree
Definition: KohnShamEigenSolver.h:198
std::shared_ptr< linearAlgebra::MultiVector< ValueType, memorySpace > > d_waveFnBatchSmall
Definition: KohnShamEigenSolver.h:236
std::vector< RealType > getFractionalOccupancy()
Definition: KohnShamEigenSolver.t.cpp:594
linearAlgebra::MultiVector< ValueTypeOperand, memorySpace > * d_waveFunctionSubspaceGuess
Definition: KohnShamEigenSolver.h:202
double d_fermiEnergyTolerance
Definition: KohnShamEigenSolver.h:194
size_type d_batchSizeSmall
Definition: KohnShamEigenSolver.h:234
linearAlgebra::MultiVector< ValueType, memorySpace > * d_filteredSubspaceOrtho
Definition: KohnShamEigenSolver.h:228
const size_type d_numWantedEigenvalues
Definition: KohnShamEigenSolver.h:199
double d_wantedSpectrumUpperBound
Definition: KohnShamEigenSolver.h:216
utils::MemoryStorage< ValueType, memorySpace > d_nOnes
Definition: KohnShamEigenSolver.h:239
void printTotalInScopeTimings()
Definition: KohnShamEigenSolver.t.cpp:813
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
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:147