ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
xc_functional_libxc.h
Go to the documentation of this file.
1#ifndef XC_FUNCTIONAL_LIBXC_H
2#define XC_FUNCTIONAL_LIBXC_H
3
4#ifdef USE_LIBXC
5
8
9#include <xc.h>
10#include <xc_funcs.h>
11
12#include <tuple>
13#include <vector>
14
15#include <map> // added by jghan, 2024-10-10
16#include <utility>
17
18class Charge;
19
20namespace XC_Functional_Libxc
21{
22//-------------------
23// xc_functional_libxc.cpp
24//-------------------
25
26 // sets functional type, which allows combination of LIBXC keyword connected by "+"
27 // for example, "XC_LDA_X+XC_LDA_C_PZ"
28 extern std::pair<int,std::vector<int>> set_xc_type_libxc(const std::string& xc_func_in);
29
46 extern std::vector<xc_func_type> init_func(const std::vector<int> &func_id,
47 const int xc_polarized);
48
49 extern void finish_func(std::vector<xc_func_type> &funcs);
50
51
52//-------------------
53// xc_functional_libxc_vxc.cpp
54//-------------------
55
56 extern std::tuple<double,double,ModuleBase::matrix> v_xc_libxc(
57 const std::vector<int> &func_id,
58 const int &nrxx, // number of real-space grid
59 const double &omega, // volume of cell
60 const double tpiba,
61 const Charge* const chr, // charge density
62 const std::map<int, double>* scaling_factor = nullptr); // added by jghan, 2024-10-10
63
64 // for mGGA functional
65 extern std::tuple<double,double,ModuleBase::matrix,ModuleBase::matrix> v_xc_meta(
66 const std::vector<int> &func_id,
67 const int &nrxx, // number of real-space grid
68 const double &omega, // volume of cell
69 const double tpiba,
70 const Charge* const chr);
71
72
73//-------------------
74// xc_functional_libxc_tools.cpp
75//-------------------
76
77 // converting rho (abacus=>libxc)
78 extern std::vector<double> convert_rho(
79 const int nspin,
80 const std::size_t nrxx,
81 const Charge* const chr);
82
83 // converting rho (abacus=>libxc)
84 extern std::tuple<std::vector<double>, std::vector<double>> convert_rho_amag_nspin4(
85 const int nspin,
86 const std::size_t nrxx,
87 const Charge* const chr);
88
89 // calculating grho
90 extern std::vector<std::vector<ModuleBase::Vector3<double>>> cal_gdr(
91 const int nspin,
92 const std::size_t nrxx,
93 const std::vector<double> &rho,
94 const double tpiba,
95 const Charge* const chr);
96
97 // converting grho (abacus=>libxc)
98 extern std::vector<double> convert_sigma(
99 const std::vector<std::vector<ModuleBase::Vector3<double>>> &gdr);
100
101 // sgn for threshold mask
102 extern std::vector<double> cal_sgn(
103 const double rho_threshold,
104 const double grho_threshold,
105 const xc_func_type &func,
106 const int nspin,
107 const std::size_t nrxx,
108 const std::vector<double> &rho,
109 const std::vector<double> &sigma);
110
111 // converting etxc from exc (libxc=>abacus)
112 extern double convert_etxc(
113 const int nspin,
114 const std::size_t nrxx,
115 const std::vector<double> &sgn,
116 const std::vector<double> &rho,
117 std::vector<double> exc);
118
119 // converting vtxc and v from vrho and vsigma (libxc=>abacus)
120 extern std::pair<double,ModuleBase::matrix> convert_vtxc_v(
121 const xc_func_type &func,
122 const int nspin,
123 const std::size_t nrxx,
124 const std::vector<double> &sgn,
125 const std::vector<double> &rho,
126 const std::vector<std::vector<ModuleBase::Vector3<double>>> &gdr,
127 const std::vector<double> &vrho,
128 const std::vector<double> &vsigma,
129 const double tpiba,
130 const Charge* const chr);
131
132 // dh for gga v
133 extern std::vector<std::vector<double>> cal_dh(
134 const int nspin,
135 const std::size_t nrxx,
136 const std::vector<double> &sgn,
137 const std::vector<std::vector<ModuleBase::Vector3<double>>> &gdr,
138 const std::vector<double> &vsigma,
139 const double tpiba,
140 const Charge* const chr);
141
142 // convert v for NSPIN=4
143 extern ModuleBase::matrix convert_v_nspin4(
144 const std::size_t nrxx,
145 const Charge* const chr,
146 const std::vector<double> &amag,
147 const ModuleBase::matrix &v);
148
149
150//-------------------
151// xc_functional_libxc_wrapper_xc.cpp
152//-------------------
153
154 extern void xc_spin_libxc(
155 const std::vector<int> &func_id,
156 const double &rhoup, const double &rhodw,
157 double &exc, double &vxcup, double &vxcdw);
158
159
160//-------------------
161// xc_functional_libxc_wrapper_gcxc.cpp
162//-------------------
163
164 // the entire GGA functional, for nspin=1 case
165 extern void gcxc_libxc(
166 const std::vector<int> &func_id,
167 const double &rho, const double &grho,
168 double &sxc, double &v1xc, double &v2xc);
169
170 // the entire GGA functional, for nspin=2 case
171 extern void gcxc_spin_libxc(
172 const std::vector<int> &func_id,
173 const double rhoup, const double rhodw,
175 double &sxc, double &v1xcup, double &v1xcdw, double &v2xcup, double &v2xcdw, double &v2xcud);
176
177
178//-------------------
179// xc_functional_libxc_wrapper_tauxc.cpp
180//-------------------
181
182 // wrapper for the mGGA functionals
183 extern void tau_xc(
184 const std::vector<int> &func_id,
185 const double &rho, const double &grho, const double &atau, double &sxc,
186 double &v1xc, double &v2xc, double &v3xc);
187
188 extern void tau_xc_spin(
189 const std::vector<int> &func_id,
190 double rhoup, double rhodw,
192 double tauup, double taudw,
193 double &sxc, double &v1xcup, double &v1xcdw, double &v2xcup, double &v2xcdw, double &v2xcud,
194 double &v3xcup, double &v3xcdw);
195
196} // namespace XC_Functional_Libxc
197
198#endif // USE_LIBXC
199
200#endif // XC_FUNCTIONAL_LIBXC_H
Definition charge.h:20
3 elements vector
Definition vector3.h:22
Definition matrix.h:19
double func(const Vec3 &r, const std::vector< Vec3 > &R, const std::vector< double > &a, const std::vector< double > &n)
Definition test_partition.cpp:50