Skip to content

Commit fc672d7

Browse files
committed
Merge branch 'develop' of https://github.com/deepmodeling/abacus-develop into hotfix2
2 parents 9d041c5 + 7198ec1 commit fc672d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2736
-36
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@ if(ENABLE_LCAO)
725725
hcontainer
726726
deltaspin
727727
numerical_atomic_orbitals
728-
lr)
728+
lr
729+
rdmft)
729730
if(USE_ELPA)
730731
target_link_libraries(${ABACUS_BIN_NAME} genelpa)
731732
endif()

docs/advanced/input_files/input-main.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@
435435
- [abs\_broadening](#abs_broadening)
436436
- [ri\_hartree\_benchmark](#ri_hartree_benchmark)
437437
- [aims\_nbasis](#aims_nbasis)
438+
- [Reduced Density Matrix Functional Theory](#Reduced-Density-Matrix-Functional-Theory)
439+
- [rdmft](#rdmft)
440+
- [rdmft\_power\_alpha](#rdmft_power_alpha)
438441

439442
[back to top](#full-list-of-input-keywords)
440443
## System variables
@@ -4031,4 +4034,21 @@ The output files are `OUT.${suffix}/Excitation_Energy.dat` and `OUT.${suffix}/Ex
40314034
- **Description**: Atomic basis set size for each atom type (with the same order as in `STRU`) in FHI-aims.
40324035
- **Default**: {} (empty list, where ABACUS use its own basis set size)
40334036

4037+
## Reduced Density Matrix Functional Theory
4038+
4039+
ab-initio methods and the xc-functional parameters used in RDMFT.
4040+
The physical quantities that RDMFT temporarily expects to output are the kinetic energy, total energy, and 1-RDM of the system in the ground state, etc.
4041+
4042+
### rdmft
4043+
4044+
- **Type**: Boolean
4045+
- **Description**: Whether to perform rdmft calculation (reduced density matrix funcional theory)
4046+
- **Default**: false
4047+
4048+
### rdmft_power_alpha
4049+
4050+
- **Type**: Real
4051+
- **Description**: The alpha parameter of power-functional(or other exx-type/hybrid functionals) which used in RDMFT, g(occ_number) = occ_number^alpha
4052+
- **Default**: 0.656
4053+
40344054
[back to top](#full-list-of-input-keywords)

source/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ add_subdirectory(module_ri)
1818
add_subdirectory(module_parameter)
1919
add_subdirectory(module_lr)
2020

21+
# add by jghan
22+
add_subdirectory(module_rdmft)
23+
2124
add_library(
2225
driver
2326
OBJECT

source/Makefile.Objects

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ VPATH=./src_global:\
7474
./module_lr/operator_casida:\
7575
./module_lr/potentials:\
7676
./module_lr/utils:\
77+
./module_rdmft:\
7778
./\
7879

7980
OBJS_ABACUS_PW=${OBJS_MAIN}\
@@ -115,6 +116,7 @@ ${OBJS_DELTASPIN}\
115116
${OBJS_TENSOR}\
116117
${OBJS_HSOLVER_PEXSI}\
117118
${OBJS_LR}\
119+
${OBJS_RDMFT}
118120

119121
OBJS_MAIN=main.o\
120122
driver.o\
@@ -726,3 +728,8 @@ OBJS_TENSOR=tensor.o\
726728
lr_spectrum.o\
727729
hamilt_casida.o\
728730
esolver_lrtd_lcao.o\
731+
732+
OBJS_RDMFT=rdmft.o\
733+
rdmft_tools.o\
734+
rdmft_pot.o\
735+
update_state_rdmft.o\

source/module_esolver/esolver_gets.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h"
99
#include "module_io/print_info.h"
1010
#include "module_io/write_HS_R.h"
11+
#include "module_io/cal_r_overlap_R.h"
1112

1213
namespace ModuleESolver
1314
{
@@ -127,6 +128,13 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
127128
std::cout << " The file is saved in " << fn << std::endl;
128129
ModuleIO::output_SR(pv, GlobalC::GridD, this->p_hamilt, fn);
129130

131+
if (PARAM.inp.out_mat_r)
132+
{
133+
cal_r_overlap_R r_matrix;
134+
r_matrix.init(pv, orb_);
135+
r_matrix.out_rR(istep);
136+
}
137+
130138
ModuleBase::timer::tick("ESolver_GetS", "runner");
131139
}
132140

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
// #include "module_elecstate/cal_dm.h"
6464
//---------------------------------------------------
6565

66+
// test RDMFT
67+
#include "module_rdmft/rdmft.h"
68+
#include <iostream>
69+
6670
namespace ModuleESolver
6771
{
6872

@@ -251,6 +255,13 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
251255
}
252256
}
253257

258+
// 14) initialize rdmft, added by jghan
259+
if( PARAM.inp.rdmft == true )
260+
{
261+
rdmft_solver.init( this->GG, this->GK, this->pv, ucell, this->kv, *(this->pelec),
262+
this->orb_, two_center_bundle_, PARAM.inp.dft_functional, PARAM.inp.rdmft_power_alpha);
263+
}
264+
254265
ModuleBase::timer::tick("ESolver_KS_LCAO", "before_all_runners");
255266
return;
256267
}
@@ -841,6 +852,7 @@ void ESolver_KS_LCAO<TK, TR>::update_pot(UnitCell& ucell, const int istep, const
841852
{
842853
this->pelec->cal_converged();
843854
}
855+
844856
}
845857

846858
//------------------------------------------------------------------------------
@@ -1044,6 +1056,23 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
10441056
ModuleBase::timer::tick("ESolver_KS_LCAO", "out_deepks_labels");
10451057
#endif
10461058

1059+
/******** test RDMFT *********/
1060+
if ( PARAM.inp.rdmft == true ) // rdmft, added by jghan, 2024-10-17
1061+
{
1062+
ModuleBase::matrix occ_number_ks(this->pelec->wg);
1063+
for(int ik=0; ik < occ_number_ks.nr; ++ik) { for(int inb=0; inb < occ_number_ks.nc; ++inb) occ_number_ks(ik, inb) /= this->kv.wk[ik]; }
1064+
this->rdmft_solver.update_elec(occ_number_ks, *(this->psi));
1065+
1066+
//initialize the gradients of Etotal on occupation numbers and wfc, and set all elements to 0.
1067+
ModuleBase::matrix dE_dOccNum(this->pelec->wg.nr, this->pelec->wg.nc, true);
1068+
psi::Psi<TK> dE_dWfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis());
1069+
dE_dWfc.zero_out();
1070+
1071+
double Etotal_RDMFT = this->rdmft_solver.run(dE_dOccNum, dE_dWfc);
1072+
}
1073+
/******** test RDMFT *********/
1074+
1075+
10471076
#ifdef __EXX
10481077
// 11) write rpa information
10491078
if (PARAM.inp.rpa)
@@ -1230,6 +1259,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12301259
}
12311260
}
12321261

1262+
12331263
//------------------------------------------------------------------------------
12341264
//! the 20th,21th,22th functions of ESolver_KS_LCAO
12351265
//! mohan add 2024-05-11

source/module_esolver/esolver_ks_lcao.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "module_basis/module_nao/two_center_bundle.h"
1313
#include "module_io/output_mat_sparse.h"
1414

15+
// added by jghan for rdmft calculation
16+
#include "module_rdmft/rdmft.h"
17+
1518
#include <memory>
1619

1720
namespace LR
@@ -68,6 +71,8 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
6871

6972
TwoCenterBundle two_center_bundle_;
7073

74+
rdmft::RDMFT<TK, TR> rdmft_solver; // added by jghan for rdmft calculation, 2024-03-16
75+
7176
// temporary introduced during removing GlobalC::ORB
7277
LCAO_Orbitals orb_;
7378

source/module_esolver/lcao_before_scf.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,14 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
370370
}
371371

372372
this->p_hamilt->non_first_scf = istep;
373+
374+
// update in ion-step
375+
if( PARAM.inp.rdmft == true )
376+
{
377+
// necessary operation of these parameters have be done with p_esolver->Init() in source/driver_run.cpp
378+
rdmft_solver.update_ion(ucell, *(this->pw_rho), GlobalC::ppcell.vloc, this->sf.strucFac); // add by jghan, 2024-03-16/2024-10-08
379+
}
380+
373381
return;
374382
}
375383

source/module_hamilt_general/module_xc/xc_functional.cpp

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ std::vector<int> XC_Functional::func_id(1);
1818
int XC_Functional::func_type = 0;
1919
bool XC_Functional::use_libxc = true;
2020
double XC_Functional::hybrid_alpha = 0.25;
21+
std::map<int, double> XC_Functional::scaling_factor_xc = { {1, 1.0} }; // added by jghan, 2024-10-10
2122

2223
void XC_Functional::set_hybrid_alpha(const double alpha_in)
2324
{
@@ -61,6 +62,7 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
6162
// func_id.push_back(XC_GGA_C_PBE);
6263

6364
func_id.clear();
65+
scaling_factor_xc.clear(); // added by jghan, 2024-07-07
6466
std::string xc_func = xc_func_in;
6567
std::transform(xc_func.begin(), xc_func.end(), xc_func.begin(), (::toupper));
6668
if( xc_func == "LDA" || xc_func == "PZ" || xc_func == "SLAPZNOGXNOGC") //SLA+PZ
@@ -196,13 +198,60 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
196198
{
197199
// not doing anything
198200
}
201+
else if( xc_func == "MULLER" || xc_func == "POWER" ) // added by jghan, 2024-07-06
202+
{
203+
func_type = 4;
204+
use_libxc = false;
205+
}
199206
#ifdef USE_LIBXC
200207
else if( xc_func == "HSE")
201208
{
202209
func_id.push_back(XC_HYB_GGA_XC_HSE06);
203210
func_type = 4;
204211
use_libxc = true;
205212
}
213+
// added by jghan, 2024-07-06
214+
else if( xc_func == "WP22")
215+
{
216+
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
217+
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
218+
func_type = 4;
219+
use_libxc = true;
220+
}
221+
else if( xc_func == "CWP22")
222+
{
223+
// BLYP_XC_lr = -BLYP_XC_sr + BLYP_XC, the realization of it is in v_xc_libxc() function, xc_functional_libxc_vxc.cpp
224+
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
225+
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
226+
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
227+
func_id.push_back(XC_GGA_C_LYP); // complete LYP_C, id=131
228+
229+
// the scaling factor of CWP22-functionals
230+
scaling_factor_xc[XC_GGA_X_ITYH] = -1.0;
231+
scaling_factor_xc[XC_GGA_C_LYPR] = -1.0;
232+
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
233+
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
234+
235+
func_type = 4;
236+
use_libxc = true;
237+
}
238+
else if( xc_func == "BLYP_LR")
239+
{
240+
// BLYP_XC_lr = -BLYP_XC_sr + BLYP_XC, the realization of it is in v_xc_libxc() function, xc_functional_libxc_vxc.cpp
241+
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
242+
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
243+
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
244+
func_id.push_back(XC_GGA_C_LYP); // complete LYP_C, id=131
245+
246+
// the scaling factor of BLYP_LR-functionals
247+
scaling_factor_xc[XC_GGA_X_ITYH] = -1.0;
248+
scaling_factor_xc[XC_GGA_C_LYPR] = -1.0;
249+
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
250+
scaling_factor_xc[XC_GGA_X_B88] = 1.0;
251+
252+
func_type = 2;
253+
use_libxc = true;
254+
}
206255
#endif
207256
else
208257
{
@@ -243,7 +292,8 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
243292
#endif
244293

245294
#ifndef USE_LIBXC
246-
if(xc_func == "SCAN" || xc_func == "HSE" || xc_func == "SCAN0")
295+
if(xc_func == "SCAN" || xc_func == "HSE" || xc_func == "SCAN0"
296+
|| xc_func == "MULLER" || xc_func == "POWER" || xc_func == "WP22" || xc_func == "CWP22")
247297
{
248298
ModuleBase::WARNING_QUIT("set_xc_type","to use SCAN, SCAN0, or HSE, LIBXC is required");
249299
}

source/module_hamilt_general/module_xc/xc_functional.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "module_elecstate/module_charge/charge.h"
2121
#include "module_cell/unitcell.h"
2222

23+
#include <map> // added by jghan, 2024-10-10
24+
2325
class XC_Functional
2426
{
2527
public:
@@ -80,6 +82,10 @@ class XC_Functional
8082
//exx_hybrid_alpha for mixing exx in hybrid functional:
8183
static double hybrid_alpha;
8284

85+
// added by jghan, 2024-07-07
86+
// as a scaling factor for different xc-functionals
87+
static std::map<int, double> scaling_factor_xc;
88+
8389
public:
8490
static std::vector<int> get_func_id() { return func_id; }
8591

@@ -162,7 +168,7 @@ class XC_Functional
162168
ModulePW::PW_Basis* rhopw,
163169
const UnitCell* ucell,
164170
std::vector<double>& stress_gga,
165-
const bool is_stress = 0);
171+
const bool is_stress = false);
166172
template <typename T, typename Device,
167173
typename Real = typename GetTypeReal<T>::type>
168174
static void grad_wfc(

0 commit comments

Comments
 (0)