Skip to content

Commit cdc1942

Browse files
committed
Update supported xc functionals from develop branch
1 parent 85a8671 commit cdc1942

File tree

3 files changed

+101
-67
lines changed

3 files changed

+101
-67
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -995,12 +995,24 @@ calculations.
995995

996996
- **Type**: String
997997
- **Description**: In our package, the XC functional can either be set explicitly using the `dft_functional` keyword in `INPUT` file. If `dft_functional` is not specified, ABACUS will use the xc functional indicated in the pseudopotential file.
998-
On the other hand, if dft_functional is specified, it will overwrite the functional from pseudopotentials and performs calculation with whichever functional the user prefers. We further offer two ways of supplying exchange-correlation functional. The first is using 'short-hand' names such as 'LDA', 'PBE', 'SCAN'. A complete list of 'short-hand' expressions can be found in [the source code](../../../source/module_hamilt_general/module_xc/xc_functional.cpp). The other way is only available when ***compiling with LIBXC***, and it allows for supplying exchange-correlation functionals as combinations of LIBXC keywords for functional components, joined by a plus sign, for example, dft_functional='LDA_X_1D_EXPONENTIAL+LDA_C_1D_CSC'. The list of LIBXC keywords can be found on its [website](https://libxc.gitlab.io/functionals/). In this way, **we support all the LDA,GGA and mGGA functionals provided by LIBXC**.
999-
1000-
Furthermore, the old INPUT parameter exx_hybrid_type for hybrid functionals has been absorbed into dft_functional. Options are `hf` (pure Hartree-Fock), `pbe0`(PBE0), `hse` (Note: in order to use HSE functional, LIBXC is required). Note also that HSE has been tested while PBE0 has NOT been fully tested yet, and the maximum CPU cores for running exx in parallel is $N(N+1)/2$, with N being the number of atoms. And forces for hybrid functionals are not supported yet.
1001-
1002-
If set to `opt_orb`, the program will not perform hybrid functional calculation. Instead, it is going to generate opt-ABFs as discussed in this [article](https://pubs.acs.org/doi/abs/10.1021/acs.jpclett.0c00481).
1003-
- **Default**: same as UPF file.
998+
On the other hand, if dft_functional is specified, it will overwrite the functional from pseudopotentials and performs calculation with whichever functional the user prefers. We further offer two ways of supplying exchange-correlation functional. The first is using 'short-hand' names. A complete list of 'short-hand' expressions can be found in [the source code](../../../source/source_hamilt/module_xc/xc_functional.cpp). Supported density functionals are:
999+
- LDA functionals
1000+
- LDA (equivalent with PZ and SLAPZNOGXNOGC), PWLDA
1001+
- GGA functionals
1002+
- PBE (equivalent with SLAPWPBXPBC), PBESOL, REVPBE, WC, BLYP, BP(referred to BP86), PW91, HCTH, OLYP, BLYP_LR
1003+
- meta-GGA functionals
1004+
- SCAN (require LIBXC)
1005+
- Hybrid functionals
1006+
- PBE0, HF
1007+
- If LIBXC is avaliale, additional short-hand names of hybrid functionals are supported: HSE(referred to HSE06), B3LYP, LC_PBE, LC_WPBE, LRC_WPBE, LRC_WPBEH, CAM_PBEH, WP22, CWP22, MULLER (equivalent with POWER)
1008+
- Hybrid meta-GGA functionals
1009+
- SCAN0 (require LIBXC)
1010+
1011+
The other way is only available when ***compiling with LIBXC***, and it allows for supplying exchange-correlation functionals as combinations of LIBXC keywords for functional components, joined by a plus sign, for example, dft_functional='LDA_X_1D_EXPONENTIAL+LDA_C_1D_CSC'. The list of LIBXC keywords can be found on its [website](https://libxc.gitlab.io/functionals/). In this way, **we support all the LDA,GGA and mGGA functionals provided by LIBXC**. Some popular functionals and their usage are: RPBE of [Hammer et al.](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.59.7413), set `dft_functional` to 'GGA_X_RPBE+GGA_C_PBE', and [r$^{2}$SCAN](https://pubs.acs.org/doi/10.1021/acs.jpclett.0c02405), set `dft_functional` to 'MGGA_X_R2SCAN+MGGA_C_R2SCAN'.
1012+
1013+
Furthermore, the old INPUT parameter exx_hybrid_type for hybrid functionals has been absorbed into dft_functional. Options are `hf` (pure Hartree-Fock), `pbe0`(PBE0), `hse` (Note: in order to use HSE functional, LIBXC is required). Note also that HSE has been tested while PBE0 has NOT been fully tested yet, and the maximum CPU cores for running exx in parallel is $N(N+1)/2$, with N being the number of atoms.
1014+
1015+
- **Default**: Used the same as DFT functional as specified in the pseudopotential files.
10041016

10051017
### xc_temperature
10061018

source/module_hamilt_general/module_xc/xc_functional.cpp

Lines changed: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
#include "module_hamilt_pw/hamilt_pwdft/global.h"
33
#include "module_parameter/parameter.h"
44
#include "module_base/global_function.h"
5-
#ifdef USE_PAW
6-
#include "module_cell/module_paw/paw_cell.h"
7-
#endif
85

96
#ifdef USE_LIBXC
107
#include "xc_functional_libxc.h"
@@ -16,6 +13,7 @@ XC_Functional::~XC_Functional(){}
1613

1714
std::vector<int> XC_Functional::func_id(1);
1815
int XC_Functional::func_type = 0;
16+
bool XC_Functional::ked_flag = false;
1917
bool XC_Functional::use_libxc = true;
2018
double XC_Functional::hybrid_alpha = 0.25;
2119
std::map<int, double> XC_Functional::scaling_factor_xc = { {1, 1.0} }; // added by jghan, 2024-10-10
@@ -25,29 +23,24 @@ void XC_Functional::set_hybrid_alpha(const double alpha_in)
2523
hybrid_alpha = alpha_in;
2624
}
2725

28-
double XC_Functional::get_hybrid_alpha()
29-
{
30-
return hybrid_alpha;
31-
}
32-
33-
int XC_Functional::get_func_type()
34-
{
35-
return func_type;
36-
}
3726
void XC_Functional::set_xc_first_loop(const UnitCell& ucell)
3827
{
3928
/** In the special "two-level" calculation case,
4029
the first scf iteration only calculate the functional without exact
4130
exchange. but in "nscf" calculation, there is no need of "two-level"
4231
method. */
43-
if (ucell.atoms[0].ncpp.xc_func == "HF"
44-
|| ucell.atoms[0].ncpp.xc_func == "PBE0"
45-
|| ucell.atoms[0].ncpp.xc_func == "HSE") {
32+
if (ucell.atoms[0].ncpp.xc_func == "HF" || ucell.atoms[0].ncpp.xc_func == "HSE"
33+
|| ucell.atoms[0].ncpp.xc_func == "PBE0"|| ucell.atoms[0].ncpp.xc_func == "LC_PBE"
34+
|| ucell.atoms[0].ncpp.xc_func == "LC_WPBE" || ucell.atoms[0].ncpp.xc_func == "LRC_WPBEH"
35+
|| ucell.atoms[0].ncpp.xc_func == "CAM_PBEH") {
4636
XC_Functional::set_xc_type("pbe");
4737
}
4838
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0") {
4939
XC_Functional::set_xc_type("scan");
5040
}
41+
else if (ucell.atoms[0].ncpp.xc_func == "B3LYP") {
42+
XC_Functional::set_xc_type("blyp");
43+
}
5144
}
5245

5346
// The setting values of functional id according to the index in LIBXC
@@ -71,41 +64,20 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
7164
func_id.push_back(XC_LDA_C_PZ);
7265
func_type = 1;
7366
use_libxc = false;
74-
#ifdef USE_PAW
75-
if(PARAM.inp.use_paw)
76-
{
77-
if(PARAM.inp.nspin != 1)
78-
{
79-
ModuleBase::WARNING_QUIT("set_xc_type","paw does not support pz with spin polarization");
80-
}
81-
else
82-
{
83-
GlobalC::paw_cell.set_libpaw_xc(1,2);
84-
}
85-
}
86-
#endif
8767
}
8868
else if (xc_func == "PWLDA")
8969
{
9070
func_id.push_back(XC_LDA_X);
9171
func_id.push_back(XC_LDA_C_PW);
9272
func_type = 1;
9373
use_libxc = false;
94-
#ifdef USE_PAW
95-
if(PARAM.inp.use_paw) { GlobalC::paw_cell.set_libpaw_xc(1,7);
96-
}
97-
#endif
9874
}
9975
else if ( xc_func == "PBE" || xc_func == "SLAPWPBXPBC") //PBX+PBC
10076
{
10177
func_id.push_back(XC_GGA_X_PBE);
10278
func_id.push_back(XC_GGA_C_PBE);
10379
func_type = 2;
10480
use_libxc = false;
105-
#ifdef USE_PAW
106-
if(PARAM.inp.use_paw) { GlobalC::paw_cell.set_libpaw_xc(2,11);
107-
}
108-
#endif
10981
}
11082
else if ( xc_func == "PBESOL") //PBX_S+PBC_S
11183
{
@@ -120,10 +92,6 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
12092
func_id.push_back(XC_GGA_C_PBE);
12193
func_type = 2;
12294
use_libxc = false;
123-
#ifdef USE_PAW
124-
if(PARAM.inp.use_paw) { GlobalC::paw_cell.set_libpaw_xc(2,14);
125-
}
126-
#endif
12795
}
12896
else if ( xc_func == "WC") //WC+PBC
12997
{
@@ -182,6 +150,36 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
182150
func_type = 5;
183151
use_libxc = true;
184152
}
153+
else if( xc_func == "LC_PBE")
154+
{
155+
func_id.push_back(XC_HYB_GGA_XC_LC_PBEOP);
156+
func_type = 4;
157+
use_libxc = true;
158+
}
159+
else if( xc_func == "LC_WPBE")
160+
{
161+
func_id.push_back(XC_HYB_GGA_XC_LC_WPBE);
162+
func_type = 4;
163+
use_libxc = true;
164+
}
165+
else if( xc_func == "LRC_WPBE")
166+
{
167+
func_id.push_back(XC_HYB_GGA_XC_LRC_WPBE);
168+
func_type = 4;
169+
use_libxc = true;
170+
}
171+
else if( xc_func == "LRC_WPBEH")
172+
{
173+
func_id.push_back(XC_HYB_GGA_XC_LRC_WPBEH);
174+
func_type = 4;
175+
use_libxc = true;
176+
}
177+
else if( xc_func == "CAM_PBEH")
178+
{
179+
func_id.push_back(XC_HYB_GGA_XC_CAM_PBEH);
180+
func_type = 4;
181+
use_libxc = true;
182+
}
185183
#endif
186184
else if( xc_func == "HF")
187185
{
@@ -252,6 +250,12 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
252250
func_type = 2;
253251
use_libxc = true;
254252
}
253+
else if (xc_func == "B3LYP")
254+
{
255+
func_id.push_back(XC_HYB_GGA_XC_B3LYP);
256+
func_type = 4;
257+
use_libxc = true;
258+
}
255259
#endif
256260
else
257261
{
@@ -270,38 +274,45 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
270274
#endif
271275
}
272276

273-
if (func_id[0] == XC_GGA_X_OPTX)
274-
{
275-
std::cerr << "\n OPTX untested please test,";
276-
}
277+
if (func_type == 3 || func_type == 5)
278+
{
279+
ked_flag = true;
280+
}
281+
else
282+
{
283+
ked_flag = false;
284+
}
277285

278-
if((func_type == 4 || func_type == 5) && PARAM.inp.basis_type == "pw")
286+
if (func_id[0] == XC_GGA_X_OPTX)
279287
{
280-
ModuleBase::WARNING_QUIT("set_xc_type","hybrid functional not realized for planewave yet");
288+
std::cerr << "\n OPTX untested please test,";
281289
}
290+
291+
// if((func_type == 4 || func_type == 5) && PARAM.inp.basis_type == "pw")
292+
// {
293+
// ModuleBase::WARNING_QUIT("set_xc_type","hybrid functional not realized for planewave yet");
294+
// }
282295
if((func_type == 3 || func_type == 5) && PARAM.inp.nspin==4)
283296
{
284297
ModuleBase::WARNING_QUIT("set_xc_type","meta-GGA has not been implemented for nspin = 4 yet");
285298
}
286-
//if((func_type == 3 || func_type == 5) && PARAM.inp.cal_stress == 1 && PARAM.inp.nspin!=1)
287-
//{
288-
// ModuleBase::WARNING_QUIT("set_xc_type","mgga stress not implemented for polarized case yet");
289-
//}
290299

291300
#ifndef __EXX
292-
if(func_type == 4 || func_type == 5)
301+
if((func_type == 4 || func_type == 5) && PARAM.inp.basis_type == "lcao")
293302
{
294-
ModuleBase::WARNING_QUIT("set_xc_type","compile with libri to use hybrid functional");
303+
ModuleBase::WARNING_QUIT("set_xc_type","compile with libri to use hybrid functional in lcao basis");
295304
}
296305
#endif
297306

298307
#ifndef USE_LIBXC
299308
if(xc_func == "SCAN" || xc_func == "HSE" || xc_func == "SCAN0"
300-
|| xc_func == "MULLER" || xc_func == "POWER" || xc_func == "WP22" || xc_func == "CWP22")
309+
|| xc_func == "MULLER" || xc_func == "POWER" || xc_func == "WP22" || xc_func == "CWP22" ||
310+
xc_func == "LC_PBE" || xc_func == "LC_WPBE" || xc_func == "LRC_WPBE" ||
311+
xc_func == "LRC_PBEH" || xc_func == "CAM_PBEH")
301312
{
302-
ModuleBase::WARNING_QUIT("set_xc_type","to use SCAN, SCAN0, or HSE, LIBXC is required");
313+
ModuleBase::WARNING_QUIT("set_xc_type","to use SCAN, SCAN0, HSE, long-range corrected (LC_PBE, LC_WPBE...) or CAM_PBEH LIBXC is required");
303314
}
304315
use_libxc = false;
305316
#endif
306317

307-
}
318+
}

source/module_hamilt_general/module_xc/xc_functional.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,34 @@ class XC_Functional
6464
// func_type, which is as specified in get_func_type
6565
// use_libxc, whether to use LIBXC. The rule is to NOT use it for functionals that we already have.
6666

67-
static int get_func_type();
67+
static int get_func_type()
68+
{
69+
return func_type;
70+
};
6871
static void set_xc_type(const std::string xc_func_in);
6972

7073
// For hybrid functional
7174
static void set_hybrid_alpha(const double alpha_in);
72-
static double get_hybrid_alpha();
75+
static double get_hybrid_alpha()
76+
{
77+
return hybrid_alpha;
78+
};
79+
static bool get_ked_flag()
80+
{
81+
return ked_flag;
82+
};
7383
/// Usually in exx caculation, the first SCF loop should be converged with PBE
7484
static void set_xc_first_loop(const UnitCell& ucell);
7585

7686
private:
7787

7888
static std::vector<int> func_id; // libxc id of functional
7989
static int func_type; //0:none, 1:lda, 2:gga, 3:mgga, 4:hybrid lda/gga, 5:hybrid mgga
80-
static bool use_libxc;
90+
static bool ked_flag; // whether the functional has kinetic energy density
91+
static bool use_libxc;
8192

82-
//exx_hybrid_alpha for mixing exx in hybrid functional:
83-
static double hybrid_alpha;
93+
// exx_hybrid_alpha for mixing exx in hybrid functional:
94+
static double hybrid_alpha;
8495

8596
// added by jghan, 2024-07-07
8697
// as a scaling factor for different xc-functionals
@@ -316,4 +327,4 @@ class XC_Functional
316327

317328
};
318329

319-
#endif //XC_FUNCTION_H
330+
#endif //XC_FUNCTION_H

0 commit comments

Comments
 (0)