-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathExcSSDFunctionalBaseClass.h
205 lines (178 loc) · 6.92 KB
/
ExcSSDFunctionalBaseClass.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// ---------------------------------------------------------------------
//
// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
// authors.
//
// This file is part of the DFT-FE code.
//
// The DFT-FE code is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the DFT-FE distribution.
//
// ---------------------------------------------------------------------
//
#ifndef DFTFE_EXCSSDFUNCTIONALBASECLASS_H
#define DFTFE_EXCSSDFUNCTIONALBASECLASS_H
#include "AuxDensityMatrix.h"
#include <vector>
#include <fstream>
#include <iostream>
namespace dftfe
{
enum class ExcFamilyType
{
LDA,
GGA,
LLMGGA,
HYBRID,
DFTPlusU,
MGGA
};
enum class densityFamilyType
{
LDA,
GGA,
LLMGGA,
};
/*
* XC attributes for the derivatives for the remainder functional
*
*/
enum class xcRemainderOutputDataAttributes
{
e, // energy density per unit volume for the remainder functional
vSpinUp, // the local multiplicative potential for spin up arising from
// remainder functional
vSpinDown, // the local multiplicative potential for spin down arising from
// remainder functional
pdeDensitySpinUp,
pdeDensitySpinDown,
pdeSigma,
pdeLaplacianSpinUp,
pdeLaplacianSpinDown,
pdeTauSpinUp,
pdeTauSpinDown
};
/**
* @brief This class provides the structure for all
* Exc functionals that can be written as a combination of
* functional of Single Slater determinant that results in a
* non-multiplicative potential plus a remainder functional
* dependent on density and Tau.
*
* Exc = S{\phi} + R [\rho, \tau]
* @author Vishal Subramanian, Sambit Das
*/
template <dftfe::utils::MemorySpace memorySpace>
class ExcSSDFunctionalBaseClass
{
public:
ExcSSDFunctionalBaseClass(const ExcFamilyType excFamType,
const densityFamilyType densityFamType,
const std::vector<DensityDescriptorDataAttributes>
&densityDescriptorAttributesList);
virtual ~ExcSSDFunctionalBaseClass();
const std::vector<DensityDescriptorDataAttributes> &
getDensityDescriptorAttributesList() const;
densityFamilyType
getDensityBasedFamilyType() const;
/*
* @brief The apply function that will be called in HX().
* The distribute() and updateGhostValues() for src
* has to be called before this function.
* Similarly for dst, accumulateLocallyOwned() should be called in HX()
* after this function is called. param[in] src The input vector param[out]
* dst The output vector param[in] inputVecSize The size of the input vector
* param[in] kPointIndex the k point for which the HX() is called
* param[in] spinIndex the spin index for which the HX() is called
*/
virtual void
applyWaveFunctionDependentFuncDerWrtPsi(
const dftfe::linearAlgebra::MultiVector<dataTypes::number, memorySpace>
& src,
dftfe::linearAlgebra::MultiVector<dataTypes::number, memorySpace> &dst,
const unsigned int inputVecSize,
const unsigned int kPointIndex,
const unsigned int spinIndex) = 0;
/*
* @brief The apply function that will be called in HXCheby() with single precision.
* The distribute() and updateGhostValues() for src
* has to be called before this function.
* Similarly for dst, accumulateLocallyOwned() should be called in HX()
* after this function is called. param[in] src The input vector param[out]
* dst The output vector param[in] inputVecSize The size of the input vector
* param[in] kPointIndex the k point for which the HX() is called
* param[in] spinIndex the spin index for which the HX() is called
*/
virtual void
applyWaveFunctionDependentFuncDerWrtPsi(
const dftfe::linearAlgebra::MultiVector<dataTypes::numberFP32,
memorySpace> &src,
dftfe::linearAlgebra::MultiVector<dataTypes::numberFP32, memorySpace>
& dst,
const unsigned int inputVecSize,
const unsigned int kPointIndex,
const unsigned int spinIndex) = 0;
/*
* @brief The function that updates the Wave function dependent part
* of the Exc functional and its derivative wrt \psi
*/
virtual void
updateWaveFunctionDependentFuncDerWrtPsi(
const std::shared_ptr<AuxDensityMatrix<memorySpace>> &auxDensityMatrixPtr,
const std::vector<double> & kPointWeights) = 0;
/*
* @brief The function that computes the Wave function dependent part
* of the Exc functional energy
*/
virtual void
computeWaveFunctionDependentExcEnergy(
const std::shared_ptr<AuxDensityMatrix<memorySpace>> &auxDensityMatrix,
const std::vector<double> & kPointWeights) = 0;
/*
* @brief Returns the Wavefunction dependent part of the Exc energy.
*/
virtual double
getWaveFunctionDependentExcEnergy() = 0;
/*
* @brief Returns the Expectation value of the WaveFunctionDependentExcFuncDerWrtPsi
* While using band energy approach to compute the total free energy
* the expectation of the WaveFunctionDependentExcFuncDerWrtPsi is included
* in the band energy. Hence it has to be subtracted and the correct energy
* has to be added to the free energy.
*/
virtual double
getExpectationOfWaveFunctionDependentExcFuncDerWrtPsi() = 0;
/**
* x and c denotes exchange and correlation respectively.
* This function computes the rho and tau dependent part of
* the Exc functional energy density and its partial derivatives
*/
virtual void
computeRhoTauDependentXCData(
AuxDensityMatrix<memorySpace> &auxDensityMatrix,
const std::vector<double> & quadPoints,
std::unordered_map<xcRemainderOutputDataAttributes, std::vector<double>>
&xDataOut,
std::unordered_map<xcRemainderOutputDataAttributes, std::vector<double>>
&cDataout) const = 0;
ExcFamilyType
getExcFamilyType() const;
virtual void
checkInputOutputDataAttributesConsistency(
const std::vector<xcRemainderOutputDataAttributes> &outputDataAttributes)
const = 0;
virtual void
reinitKPointDependentVariables(unsigned int kPointIndex) = 0;
protected:
const std::vector<DensityDescriptorDataAttributes>
d_densityDescriptorAttributesList;
ExcFamilyType d_ExcFamilyType;
densityFamilyType d_densityFamilyType;
};
} // namespace dftfe
#include "ExcSSDFunctionalBaseClass.t.cc"
#endif // DFTFE_EXCSSDFUNCTIONALBASECLASS_H