DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
hubbardClass.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
4// authors.
5//
6// This file is part of the DFT-FE code.
7//
8// The DFT-FE code is free software; you can use it, redistribute
9// it, and/or modify it under the terms of the GNU Lesser General
10// Public License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12// The full text of the license can be found in the file LICENSE at
13// the top level of the DFT-FE distribution.
14//
15// ---------------------------------------------------------------------
16//
17
18#ifndef DFTFE_EXE_HUBBARDCLASS_H
19#define DFTFE_EXE_HUBBARDCLASS_H
20
21#include "headers.h"
22#include "FEBasisOperations.h"
25#include "AuxDensityMatrix.h"
27
28namespace dftfe
29{
30 /**
31 * @brief This structure provides the
32 * relevant information pertaining to hubbard
33 * correction such as U value, orbital Ids and so on
34 * for each hubbard species.
35 */
36
49
50 /**
51 * @brief This enum class provides the
52 * tags for the occupation matrices.
53 * This will be relevant during mixing.
54 */
61
62
63 /**
64 * @brief This class provides the Hubbard correction.
65 * This class is an object of ExcDFTPluU Class.
66 * @author Vishal Subramanian
67 */
68 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
69 class hubbard
70 {
71 public:
72 /*
73 * @brief The constructor of the Hubbard class.
74 * This class takes the relevant mpi communicators.
75 * param[in] mpi_comm_parent The global mpi communicator
76 * param[in] mpi_comm_domain The mpi communicator for domain decomposition
77 * param[in] mpi_comm_interPool The mpi communicator for the k point
78 * parallelisation
79 */
80 hubbard(const MPI_Comm &mpi_comm_parent,
81 const MPI_Comm &mpi_comm_domain,
82 const MPI_Comm &mpi_comm_interPool,
83 const MPI_Comm &mpi_comm_interBandGroup);
84
85 /*
86 * @brief The init function that initialises the relevant data members of the class
87 * This class takes the relevant mpi communicators.
88 * param[in] basisOperationsMemPtr The basis Operation class templated to
89 * memory space param[in] basisOperationsHostPtr The basis Operation class
90 * templated to HOST memory space param[in] BLASWrapperMemPtr The Blas
91 * wrapper for performing the Blas operations in memory space param[in]
92 * BLASWrapperHostPtr The Blas wrapper for performing the Blas operations in
93 * HOST memory space param[in] matrixFreeVectorComponent The matrix vector
94 * component corresponding to wavefunctions param[in] densityQuadratureId --
95 * the d_nlpspQuadratureId. This cant be changed as it has to compatible
96 * with oncv class as that is required to for the force class param[in]
97 * sparsityPatternQuadratureId - quadrature required for the class atomic
98 * non local operator param[in] numberWaveFunctions - total number of
99 * wavefunctions param[in] numSpins - number of spins param[in] dftParam -
100 * dft parameters for input condition param[in] scratchFolderName - the
101 * path required to read the atomic orbitals param[in] atomLocations- the
102 * atomic locations (cartesian) for all the atoms ( including the atoms with
103 * no hubbard corrections)
104 *
105 */
106 void
108 std::shared_ptr<
110 basisOperationsMemPtr,
111 std::shared_ptr<
113 FEBasisOperations<ValueType, double, dftfe::utils::MemorySpace::HOST>>
114 basisOperationsHostPtr,
116 BLASWrapperMemPtr,
117 std::shared_ptr<
119 BLASWrapperHostPtr,
120 const dftfe::uInt matrixFreeVectorComponent,
121 const dftfe::uInt densityQuadratureId,
122 const dftfe::uInt sparsityPatternQuadratureId,
123 const dftfe::uInt numberWaveFunctions,
124 const dftfe::uInt numSpins,
125 const dftParameters &dftParam,
126 const std::string &scratchFolderName,
127 const bool singlePrecNonLocalOperator,
128 const bool updateNonlocalSparsity,
129 const std::vector<std::vector<double>> &atomLocations,
130 const std::vector<std::vector<double>> &atomLocationsFrac,
131 const std::vector<dftfe::Int> &imageIds,
132 const std::vector<std::vector<double>> &imagePositions,
133 const std::vector<double> &kPointCoordinates,
134 const std::vector<double> &kPointWeights,
135 const std::vector<std::vector<double>> &domainBoundaries);
136
137 /*
138 * @brief This function computes the hubbard energy
139 *
140 * E_U = \sum_I \sum_{\sigma} 0.5* U \Big( \sum_m( n^{\sigma}_{mm}) -
141 * \sum_{m,m'}( n^{\sigma}_{mm'} n^{\sigma}_{m'm})\Big)
142 *
143 */
144
145 void
147
148 /*
149 * @brief This function computes the occupation matrix at the end of the SCF iteration.
150 * The output is stored in HubbardOccFieldType::Out
151 * n^{I,\sigma}_{m'm} = \sum_k \sum_i f_k f_i < \psi^{\sigma}_i| \phi^{I}_m> < \phi^{I}_m' | \psi^{\sigma}_i >
152 */
153 void
156 const std::vector<std::vector<double>> &orbitalOccupancy);
157
158 /*
159 * @brief This function computes the action of the hubbard potential
160 * V_h \psi^{\sigma}_i = \sum_{I} | \phi^{I}_m> A^{I \sigma}_{m m'} < \phi^{I}_m' | \psi^{\sigma}_i >
161 * Where A is the coupling matrix. In the case of hubbard, it is a dense
162 * matrix for each atom I.
163 */
164
165 void
169 const dftfe::uInt inputVecSize,
170 const dftfe::uInt kPointIndex,
171 const dftfe::uInt spinIndex);
172
173 void
177 memorySpace> &src,
180 memorySpace> &dst,
181 const dftfe::uInt inputVecSize,
182 const dftfe::uInt kPointIndex,
183 const dftfe::uInt spinIndex);
184
185 void
187
188 void
190
191
192 /*
193 * @brief Functions that returns the coupling matrix A required in the apply().
194 *
195 * A^{I \sigma}_{m m'} = 0.5*U (\delta_{m m'} - n^{I \sigma}_{m m'})
196 *
197 */
200
201 /*
202 * @brief Functions that returns the occupation matrices.
203 * This is required for the mixing classes
204 */
207
210
213
216
217 /*
218 * @brief Function that sets the occupation matrix
219 * obtained from the output of the mixing class
220 */
221 void
224 &inputOccMatrix);
225
226 /*
227 * @brief Returns the Hubbard energy
228 */
229 double
231
232
233 /*
234 * @brief Returns the Expectation of the Hubbard potential
235 * While using band energy approach to compute the total free energy
236 * the expectation of the hubbard potential is included in the band energy.
237 * Hence it has to be subtracted and hubbard energy has to be added to the
238 * free energy.
239 */
240 double
242
243
244 /*
245 * @brief Get the underlying Atomic nonlocal operator
246
247 */
248 const std::shared_ptr<
251
254
257
258
259 /*
260 * @brief Write the hubbard occupation numbers to a
261 * file. Used for nscf calculations.
262 */
263 void
265
266 /*
267 * @brief Read the hubbard occupation numbers from a file.
268 * Used for nscf calculations.
269 */
270 void
272
273
274 private:
275 std::map<dftfe::uInt, dftfe::uInt> d_mapHubbardAtomToGlobalAtomId;
276
278 void
280
281 void
283 const dftfe::uInt vectorBlockSize,
284 const dftfe::uInt spinIndex,
285 const dftfe::uInt kpointIndex);
286
287 void
289
290 void
292
293 void
295
296 void
297 readHubbardInput(const std::vector<std::vector<double>> &atomLocations,
298 const std::vector<dftfe::Int> &imageIds,
299 const std::vector<std::vector<double>> &imagePositions);
300
301
302 std::shared_ptr<
305 std::shared_ptr<
306 dftfe::basis::
307 FEBasisOperations<ValueType, double, dftfe::utils::MemorySpace::HOST>>
309
310 std::shared_ptr<AtomicCenteredNonLocalOperator<ValueType, memorySpace>>
312
313 std::shared_ptr<
316
318
319 std::shared_ptr<dftfe::linearAlgebra::BLASWrapper<memorySpace>>
321
322 std::shared_ptr<
325 std::map<dftfe::uInt, hubbardSpecies> d_hubbardSpeciesData;
326 std::map<std::pair<dftfe::uInt, dftfe::uInt>,
327 std::shared_ptr<AtomCenteredSphericalFunctionBase>>
329
330 std::shared_ptr<AtomCenteredSphericalFunctionContainer>
332
333 std::vector<double> d_kPointWeights;
334 std::vector<std::vector<double>> d_domainBoundaries;
336 std::vector<double> d_kPointCoordinates;
337
339
341
342 const MPI_Comm d_mpi_comm_parent;
343 const MPI_Comm d_mpi_comm_domain;
344 const MPI_Comm d_mpi_comm_interPool;
345 const MPI_Comm d_mpi_comm_interBand;
346
348
349 std::vector<dftfe::uInt> d_bandGroupLowHighPlusOneIndices;
350
352 std::vector<dftfe::uInt> d_procLocalAtomId;
353
354 dealii::ConditionalOStream pcout;
355
356 std::vector<double> d_atomicCoords;
357 std::vector<double> d_initialAtomicSpin;
358 std::vector<std::vector<double>> d_periodicImagesCoords;
359 std::vector<dftfe::Int> d_imageIds;
360 std::vector<dftfe::uInt> d_mapAtomToHubbardIds;
361 std::vector<dftfe::uInt> d_mapAtomToAtomicNumber;
362
366
367 std::vector<dftfe::utils::MemoryStorage<ValueType, memorySpace>>
369
370 std::vector<dftfe::utils::MemoryStorage<
372 memorySpace>>
374 std::map<
379
381
383 std::vector<dftfe::uInt> d_OccMatrixEntryStartForAtom;
384
387
390 memorySpace>
392
393
396
399
402
404 };
405} // namespace dftfe
406
407#endif // DFTFE_EXE_HUBBARDCLASS_H
Definition AtomicCenteredNonLocalOperator.h:58
Definition FEBasisOperations.h:85
Namespace which declares the input parameters and the functions to parse them from the input paramete...
Definition dftParameters.h:36
dftfe::linearAlgebra::MultiVector< typename dftfe::dataTypes::singlePrecType< ValueType >::type, memorySpace > d_hubbNonLocalProjectorTimesVectorBlockSinglePrec
Definition hubbardClass.h:391
void applyPotentialDueToHubbardCorrection(const dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &src, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &dst, const dftfe::uInt inputVecSize, const dftfe::uInt kPointIndex, const dftfe::uInt spinIndex)
std::shared_ptr< AtomicCenteredNonLocalOperator< dataTypes::numberFP32, memorySpace > > d_nonLocalOperatorSinglePrec
Definition hubbardClass.h:315
dftfe::uInt d_noOfSpin
Definition hubbardClass.h:364
std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< memorySpace > > d_BLASWrapperMemPtr
Definition hubbardClass.h:320
const MPI_Comm d_mpi_comm_parent
Definition hubbardClass.h:342
void computeResidualOccMat()
dftfe::uInt getTotalNumberOfSphericalFunctionsForAtomId(dftfe::uInt iAtom)
dftfe::uInt d_numTotalOccMatrixEntriesPerSpin
Definition hubbardClass.h:382
std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< dftfe::utils::MemorySpace::HOST > > d_BLASWrapperHostPtr
Definition hubbardClass.h:324
void initialiseFlattenedDataStructure(dftfe::uInt numVectors)
dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > d_hubbOccMatAfterMixing
Definition hubbardClass.h:398
std::vector< double > d_kPointWeights
Definition hubbardClass.h:333
void writeHubbOccToFile()
bool d_useSinglePrec
Definition hubbardClass.h:317
double d_spinPolarizedFactor
Definition hubbardClass.h:363
std::vector< dftfe::uInt > d_bandGroupLowHighPlusOneIndices
Definition hubbardClass.h:349
std::shared_ptr< AtomCenteredSphericalFunctionContainer > d_atomicProjectorFnsContainer
Definition hubbardClass.h:331
void computeOccupationMatrix(const dftfe::utils::MemoryStorage< ValueType, memorySpace > *X, const std::vector< std::vector< double > > &orbitalOccupancy)
dealii::ConditionalOStream pcout
Definition hubbardClass.h:354
dftfe::uInt getGlobalAtomId(dftfe::uInt iAtom)
std::map< HubbardOccFieldType, dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > d_occupationMatrix
Definition hubbardClass.h:377
void init(std::shared_ptr< dftfe::basis::FEBasisOperations< ValueType, double, memorySpace > > basisOperationsMemPtr, std::shared_ptr< dftfe::basis::FEBasisOperations< ValueType, double, dftfe::utils::MemorySpace::HOST > > basisOperationsHostPtr, std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< memorySpace > > BLASWrapperMemPtr, std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< dftfe::utils::MemorySpace::HOST > > BLASWrapperHostPtr, const dftfe::uInt matrixFreeVectorComponent, const dftfe::uInt densityQuadratureId, const dftfe::uInt sparsityPatternQuadratureId, const dftfe::uInt numberWaveFunctions, const dftfe::uInt numSpins, const dftParameters &dftParam, const std::string &scratchFolderName, const bool singlePrecNonLocalOperator, const bool updateNonlocalSparsity, const std::vector< std::vector< double > > &atomLocations, const std::vector< std::vector< double > > &atomLocationsFrac, const std::vector< dftfe::Int > &imageIds, const std::vector< std::vector< double > > &imagePositions, const std::vector< double > &kPointCoordinates, const std::vector< double > &kPointWeights, const std::vector< std::vector< double > > &domainBoundaries)
std::vector< std::vector< double > > d_domainBoundaries
Definition hubbardClass.h:334
std::map< dftfe::uInt, hubbardSpecies > d_hubbardSpeciesData
Definition hubbardClass.h:325
std::vector< dftfe::uInt > d_OccMatrixEntryStartForAtom
Definition hubbardClass.h:383
std::shared_ptr< dftfe::basis::FEBasisOperations< ValueType, double, memorySpace > > d_BasisOperatorMemPtr
Definition hubbardClass.h:304
dftfe::uInt d_cellsBlockSizeApply
Definition hubbardClass.h:394
std::vector< dftfe::uInt > d_mapAtomToAtomicNumber
Definition hubbardClass.h:361
dftfe::uInt d_noSpecies
Definition hubbardClass.h:378
dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > & getOccMatRes()
double d_hubbardEnergy
Definition hubbardClass.h:400
std::vector< std::vector< double > > d_periodicImagesCoords
Definition hubbardClass.h:358
std::vector< dftfe::uInt > d_procLocalAtomId
Definition hubbardClass.h:352
void computeCouplingMatrix()
dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > & getOccMatOut()
double getHubbardEnergy()
std::map< std::pair< dftfe::uInt, dftfe::uInt >, std::shared_ptr< AtomCenteredSphericalFunctionBase > > d_atomicProjectorFnsMap
Definition hubbardClass.h:328
dftfe::uInt this_mpi_process
Definition hubbardClass.h:347
void setInOccMatrix(const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &inputOccMatrix)
std::shared_ptr< dftfe::basis::FEBasisOperations< ValueType, double, dftfe::utils::MemorySpace::HOST > > d_BasisOperatorHostPtr
Definition hubbardClass.h:308
void createAtomCenteredSphericalFunctionsForProjectors()
dftfe::uInt d_totalNumHubbAtoms
Definition hubbardClass.h:277
void setInitialOccMatrix()
dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > d_hubbNonLocalProjectorTimesVectorBlock
Definition hubbardClass.h:386
const MPI_Comm d_mpi_comm_interBand
Definition hubbardClass.h:345
void computeHubbardOccNumberFromCTransOnX(const bool isOccOut, const dftfe::uInt vectorBlockSize, const dftfe::uInt spinIndex, const dftfe::uInt kpointIndex)
const dftParameters * d_dftParamsPtr
Definition hubbardClass.h:335
double d_expectationOfHubbardPotential
Definition hubbardClass.h:401
dftfe::uInt d_numberWaveFunctions
Definition hubbardClass.h:380
std::map< dftfe::uInt, dftfe::uInt > d_mapHubbardAtomToGlobalAtomId
Definition hubbardClass.h:275
std::shared_ptr< AtomicCenteredNonLocalOperator< ValueType, memorySpace > > d_nonLocalOperator
Definition hubbardClass.h:311
dftfe::uInt d_numSpins
Definition hubbardClass.h:351
dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > & getOccMatIn()
hubbard(const MPI_Comm &mpi_comm_parent, const MPI_Comm &mpi_comm_domain, const MPI_Comm &mpi_comm_interPool, const MPI_Comm &mpi_comm_interBandGroup)
dftfe::uInt n_mpi_processes
Definition hubbardClass.h:347
const std::shared_ptr< AtomicCenteredNonLocalOperator< ValueType, memorySpace > > getNonLocalOperator()
void readHubbardInput(const std::vector< std::vector< double > > &atomLocations, const std::vector< dftfe::Int > &imageIds, const std::vector< std::vector< double > > &imagePositions)
dftfe::uInt d_maxOccMatSizePerAtom
Definition hubbardClass.h:403
std::vector< dftfe::uInt > d_mapAtomToHubbardIds
Definition hubbardClass.h:360
std::vector< double > d_initialAtomicSpin
Definition hubbardClass.h:357
void applyPotentialDueToHubbardCorrection(const dftfe::linearAlgebra::MultiVector< typename dftfe::dataTypes::singlePrecType< ValueType >::type, memorySpace > &src, dftfe::linearAlgebra::MultiVector< typename dftfe::dataTypes::singlePrecType< ValueType >::type, memorySpace > &dst, const dftfe::uInt inputVecSize, const dftfe::uInt kPointIndex, const dftfe::uInt spinIndex)
dftfe::uInt d_numKPoints
Definition hubbardClass.h:338
dftfe::uInt d_verbosity
Definition hubbardClass.h:395
void computeEnergyFromOccupationMatrix()
std::vector< double > d_kPointCoordinates
Definition hubbardClass.h:336
const dftfe::utils::MemoryStorage< ValueType, memorySpace > & getCouplingMatrix(dftfe::uInt spinIndex)
double d_atomOrbitalMaxLength
Definition hubbardClass.h:340
void readHubbOccFromFile()
double getExpectationOfHubbardPotential()
std::string d_dftfeScratchFolderName
Definition hubbardClass.h:365
const MPI_Comm d_mpi_comm_interPool
Definition hubbardClass.h:344
void initialiseOperatorActionOnX(dftfe::uInt kPointIndex)
std::vector< dftfe::Int > d_imageIds
Definition hubbardClass.h:359
std::vector< double > d_atomicCoords
Definition hubbardClass.h:356
dftfe::uInt d_densityQuadratureId
Definition hubbardClass.h:380
const MPI_Comm d_mpi_comm_domain
Definition hubbardClass.h:343
std::vector< dftfe::utils::MemoryStorage< ValueType, memorySpace > > d_couplingMatrixEntries
Definition hubbardClass.h:368
dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > & getHubbMatrixForMixing()
std::vector< dftfe::utils::MemoryStorage< typename dftfe::dataTypes::singlePrecType< ValueType >::type, memorySpace > > d_couplingMatrixEntriesSinglePrec
Definition hubbardClass.h:373
Definition BLASWrapper.h:35
An class template to encapsulate a MultiVector. A MultiVector is a collection of vectors belonging t...
Definition MultiVector.h:127
Definition MemoryStorage.h:33
Definition FEBasisOperations.h:30
Definition pseudoPotentialToDftfeConverter.cc:34
HubbardOccFieldType
This enum class provides the tags for the occupation matrices. This will be relevant during mixing.
Definition hubbardClass.h:56
@ Out
Definition hubbardClass.h:58
@ Residual
Definition hubbardClass.h:59
@ In
Definition hubbardClass.h:57
std::uint32_t uInt
Definition TypeConfig.h:10
T type
Definition dftfeDataTypes.h:113
This structure provides the relevant information pertaining to hubbard correction such as U value,...
Definition hubbardClass.h:38
dftfe::uInt numberSphericalFuncSq
Definition hubbardClass.h:44
double initialOccupation
Definition hubbardClass.h:45
std::vector< dftfe::uInt > nQuantumNum
Definition hubbardClass.h:46
double hubbardValue
Definition hubbardClass.h:41
dftfe::uInt atomicNumber
Definition hubbardClass.h:40
dftfe::uInt numProj
Definition hubbardClass.h:42
std::vector< dftfe::uInt > lQuantumNum
Definition hubbardClass.h:47
dftfe::uInt numberSphericalFunc
Definition hubbardClass.h:43