Skip to content

Commit f6ac787

Browse files
authored
DFT+DMFT and DFT+U (#98)
* DFT+DMFT * DFT+DMFT; HR for DFT+U * DFT+DMFT update * DFT+DMFT update * DFT+DMFT * DFT+DMFT and DFT+U
1 parent a2bd6bf commit f6ac787

File tree

13 files changed

+653
-56
lines changed

13 files changed

+653
-56
lines changed

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ variable_cell.o\
278278
dftu.o\
279279
dftu_yukawa.o\
280280
dftu_relax.o\
281+
dmft.o \
281282

282283
OBJS_COMMON=atom_spec.o \
283284
unitcell.o \

source/input.cpp

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,11 @@ void Input::Default(void)
468468
omc = false;
469469
dftu_type = 2;
470470

471+
//==========================================================
472+
// DFT+DMFT Xin Qu added on 2020-08
473+
//==========================================================
474+
dft_plus_dmft = false;
475+
471476
return;
472477
}
473478

@@ -1842,7 +1847,14 @@ bool Input::Read(const std::string &fn)
18421847
else if(strcmp("orbital_corr",word)==0) ifs.ignore(150,'\n');
18431848
else if(strcmp("omc",word)==0) ifs.ignore(150,'\n');
18441849
else if(strcmp("yukawa_lambda",word)==0) ifs.ignore(150,'\n');
1845-
//---------------------------------------------------------------------------------
1850+
//----------------------------------------------------------------------------------
1851+
// Xin Qu added on 2020-08 for DFT+DMFT
1852+
//----------------------------------------------------------------------------------
1853+
else if(strcmp("dft_plus_dmft",word)==0)
1854+
{
1855+
ifs >> dft_plus_dmft;
1856+
}
1857+
//----------------------------------------------------------------------------------
18461858
else
18471859
{
18481860
//xiaohui add 2015-09-15
@@ -1988,7 +2000,7 @@ bool Input::Read(const std::string &fn)
19882000
exit(0);
19892001
}
19902002

1991-
if( (orbital_corr[i]==-1) && (orbital_corr[i]==0) && (orbital_corr[i]!=1) && (orbital_corr[i]!=2) && (orbital_corr[i]!=3) )
2003+
if( (orbital_corr[i]!=-1) && (orbital_corr[i]!=0) && (orbital_corr[i]!=1) && (orbital_corr[i]!=2) && (orbital_corr[i]!=3) )
19922004
{
19932005
std::cout << " WRONG ARGUMENTS OF orbital_corr " << std::endl;
19942006
exit(0);
@@ -2015,6 +2027,99 @@ bool Input::Read(const std::string &fn)
20152027

20162028
}
20172029

2030+
//----------------------------------------------------------
2031+
// DFT+DMFT Xin Qu added on 2020-08
2032+
//----------------------------------------------------------
2033+
if(dft_plus_dmft)
2034+
{
2035+
ifs.clear();
2036+
ifs.seekg(0); //move to the beginning of the file
2037+
ifs.rdstate();
2038+
while (ifs.good())
2039+
{
2040+
ifs >> word1;
2041+
strtolower(word1, word); //convert uppercase std::string to lower case; word1 --> word
2042+
2043+
if(strcmp("hubbard_u", word)==0)
2044+
{
2045+
for(int i=0; i<ntype; i++)
2046+
{
2047+
ifs >> hubbard_u[i];
2048+
hubbard_u[i] /= ModuleBase::Ry_to_eV;
2049+
}
2050+
}
2051+
else if (strcmp("hund_j", word)==0)
2052+
{
2053+
for(int i=0;i<ntype;i++)
2054+
{
2055+
ifs >> hund_j[i];
2056+
hund_j[i] /= ModuleBase::Ry_to_eV;
2057+
}
2058+
}
2059+
else if(strcmp("orbital_corr", word)==0)
2060+
{
2061+
for(int i=0;i<ntype;i++)
2062+
{
2063+
ifs >> orbital_corr[i];
2064+
}
2065+
}
2066+
else ifs.ignore(150, '\n');
2067+
2068+
if (ifs.eof() != 0) break;
2069+
}
2070+
2071+
for(int i=0; i<ntype; i++)
2072+
{
2073+
2074+
if(hubbard_u[i]<-1.0e-3)
2075+
{
2076+
std::cout << " WRONG ARGUMENTS OF hubbard_u " << std::endl;
2077+
exit(0);
2078+
}
2079+
2080+
if(hund_j[i]<-1.0e-3)
2081+
{
2082+
std::cout << " WRONG ARGUMENTS OF hund_j " << std::endl;
2083+
exit(0);
2084+
}
2085+
2086+
if( (orbital_corr[i]!=-1) && (orbital_corr[i]!=0) && (orbital_corr[i]!=1) && (orbital_corr[i]!=2) && (orbital_corr[i]!=3) )
2087+
{
2088+
std::cout << " WRONG ARGUMENTS OF orbital_corr " << std::endl;
2089+
exit(0);
2090+
}
2091+
}
2092+
2093+
bool dmft_flag = false;
2094+
for(int i=0; i<ntype; i++)
2095+
{
2096+
if(orbital_corr[i] != -1)
2097+
{
2098+
dmft_flag = true;
2099+
break;
2100+
}
2101+
}
2102+
2103+
if(!dmft_flag)
2104+
{
2105+
std::cout << "No atoms are correlated!!!" << std::endl;
2106+
exit(0);
2107+
}
2108+
2109+
if(strcmp("lcao", basis_type.c_str())!=0)
2110+
{
2111+
std::cout << " WRONG ARGUMENTS OF basis_type, only lcao is support " << std::endl;
2112+
exit(0);
2113+
}
2114+
2115+
if(strcmp("genelpa", ks_solver.c_str())!=0)
2116+
{
2117+
std::cout << " WRONG ARGUMENTS OF ks_solver in DFT+DMFT routine, only genelpa is support " << std::endl;
2118+
exit(0);
2119+
}
2120+
2121+
}
2122+
20182123
if (basis_type == "pw") // pengfei Li add 2015-1-31
20192124
{
20202125
gamma_only = 0;
@@ -2451,7 +2556,7 @@ void Input::Bcast()
24512556
//-----------------------------------------------------------------------------------
24522557
//DFT+U (added by Quxin 2020-10-29)
24532558
//-----------------------------------------------------------------------------------
2454-
Parallel_Common::bcast_bool( dft_plus_u );
2559+
Parallel_Common::bcast_bool( dft_plus_u );
24552560
Parallel_Common::bcast_bool( yukawa_potential );
24562561
Parallel_Common::bcast_bool( omc );
24572562
Parallel_Common::bcast_int(dftu_type);
@@ -2471,6 +2576,11 @@ void Input::Bcast()
24712576
Parallel_Common::bcast_int(orbital_corr[i]);
24722577
}
24732578

2579+
//-----------------------------------------------------------------------------------
2580+
//DFT+DMFT (added by Quxin 2020-08)
2581+
//-----------------------------------------------------------------------------------
2582+
Parallel_Common::bcast_bool( dft_plus_dmft );
2583+
24742584
return;
24752585
}
24762586
#endif

source/input.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ class Input
449449
int dftu_type; //1:rotationally invarient formalism; 2:simplified form(default)
450450
int double_counting; // 1:FLL(fully localized limit)(default); 2:AMF(around mean field)
451451

452+
//==========================================================
453+
// DFT+DMFT Xin Qu added on 2021-08
454+
//==========================================================
455+
bool dft_plus_dmft; //true:DFT+U correction; false:standard DFT calcullation(default)
456+
452457
//==========================================================
453458
// DeepKS -- added by caoyu and mohan
454459
//==========================================================

source/src_io/write_HS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ void HS_Matrix::save_SR_sparse(
12051205
}
12061206

12071207
std::stringstream sss;
1208-
sss << GlobalV::global_out_dir << SR_filename;
1208+
sss << SR_filename;
12091209
std::ofstream g2;
12101210

12111211
if(GlobalV::DRANK==0)

source/src_lcao/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ add_library(
5959
wavefunc_in_pw.cpp
6060
H_TDDFT_pw.cpp
6161
run_md_lcao.cpp
62+
dmft.cpp
6263
)
6364

6465
if(ENABLE_DEEPKS)

source/src_lcao/ELEC_cbands_k.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void ELEC_cbands_k::cal_bands(const int &istep, LCAO_Hamilt &uhm)
104104
{
105105
GlobalC::restart.load_disk("H", ik);
106106
GlobalC::restart.info_load.load_H_finish = true;
107-
}
107+
}
108108
if(GlobalC::restart.info_save.save_H)
109109
{
110110
GlobalC::restart.save_disk("H", ik);

source/src_lcao/LOOP_cell.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "LOOP_ions.h"
33

44
#include "dftu.h" //Quxin add for DFT+U on 20201029
5+
#include "dmft.h"
56

67
// delete in near future
78
#include "../src_pw/global.h"
@@ -63,6 +64,8 @@ void LOOP_cell::opt_cell(void)
6364
GlobalC::dftu.init(GlobalC::ucell, GlobalC::ParaO);
6465
}
6566

67+
if(INPUT.dft_plus_dmft) GlobalC::dmft.init(INPUT, GlobalC::ucell);
68+
6669
LOOP_ions ions;
6770
ions.opt_ions();
6871

source/src_lcao/LOOP_ions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "../src_pw/vdwd3.h"
1818
#include "../src_pw/vdwd2_parameters.h"
1919
#include "../src_pw/vdwd3_parameters.h"
20+
#include "dmft.h"
2021
#ifdef __DEEPKS
2122
#include "LCAO_descriptor.h" //caoyu add 2021-07-26
2223
#endif
@@ -170,10 +171,20 @@ void LOOP_ions::opt_ions(void)
170171
GlobalC::pot.write_elecstat_pot(ssp.str(), ssp_ave.str()); //output 'Hartree + local pseudopot'
171172
}
172173

174+
if(INPUT.dft_plus_dmft)
175+
{
176+
// Output sparse overlap matrix S(R)
177+
this->output_SR("outputs_to_DMFT/overlap_matrix/SR.csr");
178+
179+
// Output wave functions, bands, k-points information, and etc.
180+
GlobalC::dmft.out_to_dmft();
181+
}
182+
173183
if(GlobalC::ParaO.out_hsR)
174184
{
175185
this->output_HS_R(); //LiuXh add 2019-07-15
176186
}
187+
177188
//caoyu add 2021-03-31
178189
#ifdef __DEEPKS
179190
if (GlobalV::out_descriptor)
@@ -545,3 +556,4 @@ void LOOP_ions::final_scf(void)
545556

546557
return;
547558
}
559+

source/src_lcao/LOOP_ions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "../src_pw/charge_extra.h"
77
#include "../src_ions/lattice_change_methods.h"
88

9+
#include <fstream>
10+
911
class LOOP_ions
1012
{
1113

source/src_lcao/dftu.cpp

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void DFTU::init(
222222
this->J_Yukawa.resize(cell.ntype);
223223

224224
for(int it=0; it<cell.ntype; it++)
225-
{
225+
{
226226
const int NL = cell.atoms[it].nwl + 1;
227227

228228
this->Fk.at(it).resize(NL);
@@ -246,7 +246,7 @@ void DFTU::init(
246246
// {
247247
// this->cal_slater_Fk(l, it);
248248
// this->cal_slater_UJ(it, l);
249-
// }
249+
// }
250250
}
251251
}
252252
}
@@ -1437,66 +1437,60 @@ void DFTU::output()
14371437

14381438
void DFTU::cal_eff_pot_mat_R_double(const int ispin, double* SR, double* HR)
14391439
{
1440-
const char transN = 'N', transT = 'T';
1441-
const int one_int = 1;
1442-
const double alpha = 1.0, beta = 0.0, one=1.0, half=0.5;
1443-
1444-
for(int i=0; i<GlobalC::ParaO.nloc; i++) HR[i] = 0.0;
1440+
const char transN = 'N', transT = 'T';
1441+
const int one_int = 1;
1442+
const double alpha = 1.0, beta = 0.0, one=1.0, half=0.5;
14451443

14461444
std::vector<double> VU(GlobalC::ParaO.nloc);
14471445
this->cal_VU_pot_mat_real(ispin, 1, &VU[0]);
14481446

1449-
pdgemm_(&transN, &transN,
1450-
&GlobalV::NLOCAL, &GlobalV::NLOCAL, &GlobalV::NLOCAL,
1451-
&half,
1452-
ModuleBase::GlobalFunc::VECTOR_TO_PTR(VU), &one_int, &one_int, GlobalC::ParaO.desc,
1453-
SR, &one_int, &one_int, GlobalC::ParaO.desc,
1454-
&beta,
1455-
HR, &one_int, &one_int, GlobalC::ParaO.desc);
1456-
1457-
for(int irc=0; irc<GlobalC::ParaO.nloc; irc++)
1458-
VU[irc] = HR[irc];
1459-
1460-
pdtran_(&GlobalV::NLOCAL, &GlobalV::NLOCAL,
1461-
&one,
1462-
&VU[0], &one_int, &one_int, GlobalC::ParaO.desc,
1463-
&one,
1464-
HR, &one_int, &one_int, GlobalC::ParaO.desc);
1447+
pdgemm_(&transN, &transN,
1448+
&GlobalV::NLOCAL, &GlobalV::NLOCAL, &GlobalV::NLOCAL,
1449+
&half,
1450+
ModuleBase::GlobalFunc::VECTOR_TO_PTR(VU), &one_int, &one_int, GlobalC::ParaO.desc,
1451+
SR, &one_int, &one_int, GlobalC::ParaO.desc,
1452+
&beta,
1453+
HR, &one_int, &one_int, GlobalC::ParaO.desc);
1454+
1455+
pdgemm_(&transN, &transN,
1456+
&GlobalV::NLOCAL, &GlobalV::NLOCAL, &GlobalV::NLOCAL,
1457+
&half,
1458+
SR, &one_int, &one_int, GlobalC::ParaO.desc,
1459+
ModuleBase::GlobalFunc::VECTOR_TO_PTR(VU), &one_int, &one_int, GlobalC::ParaO.desc,
1460+
&one,
1461+
HR, &one_int, &one_int, GlobalC::ParaO.desc);
14651462

14661463
return;
14671464
}
14681465

14691466
void DFTU::cal_eff_pot_mat_R_complex_double(
14701467
const int ispin, std::complex<double>* SR, std::complex<double>* HR)
14711468
{
1472-
const char transN = 'N', transT = 'T';
1473-
const int one_int = 1;
1474-
const std::complex<double> alpha(1.0,0.0), beta(0.0,0.0);
1475-
const std::complex<double> zero(0.0,0.0), half(0.5,0.0), one(1.0,0.0);
1476-
1477-
for(int i=0; i<GlobalC::ParaO.nloc; i++) HR[i] = zero;
1469+
const char transN = 'N', transT = 'T';
1470+
const int one_int = 1;
1471+
const std::complex<double> alpha(1.0,0.0), beta(0.0,0.0);
1472+
const std::complex<double> zero(0.0,0.0), half(0.5,0.0), one(1.0,0.0);
1473+
1474+
std::vector<std::complex<double>> VU(GlobalC::ParaO.nloc);
1475+
this->cal_VU_pot_mat_complex(ispin, 1, &VU[0]);
1476+
1477+
pzgemm_(&transN, &transN,
1478+
&GlobalV::NLOCAL, &GlobalV::NLOCAL, &GlobalV::NLOCAL,
1479+
&half,
1480+
ModuleBase::GlobalFunc::VECTOR_TO_PTR(VU), &one_int, &one_int, GlobalC::ParaO.desc,
1481+
SR, &one_int, &one_int, GlobalC::ParaO.desc,
1482+
&beta,
1483+
HR, &one_int, &one_int, GlobalC::ParaO.desc);
1484+
1485+
pzgemm_(&transN, &transN,
1486+
&GlobalV::NLOCAL, &GlobalV::NLOCAL, &GlobalV::NLOCAL,
1487+
&half,
1488+
SR, &one_int, &one_int, GlobalC::ParaO.desc,
1489+
ModuleBase::GlobalFunc::VECTOR_TO_PTR(VU), &one_int, &one_int, GlobalC::ParaO.desc,
1490+
&one,
1491+
HR, &one_int, &one_int, GlobalC::ParaO.desc);
14781492

1479-
std::vector<std::complex<double>> VU(GlobalC::ParaO.nloc);
1480-
this->cal_VU_pot_mat_complex(ispin, 1, &VU[0]);
1481-
1482-
pzgemm_(&transN, &transN,
1483-
&GlobalV::NLOCAL, &GlobalV::NLOCAL, &GlobalV::NLOCAL,
1484-
&half,
1485-
ModuleBase::GlobalFunc::VECTOR_TO_PTR(VU), &one_int, &one_int, GlobalC::ParaO.desc,
1486-
SR, &one_int, &one_int, GlobalC::ParaO.desc,
1487-
&beta,
1488-
HR, &one_int, &one_int, GlobalC::ParaO.desc);
1489-
1490-
for(int irc=0; irc<GlobalC::ParaO.nloc; irc++)
1491-
VU[irc] = HR[irc];
1492-
1493-
pztranc_(&GlobalV::NLOCAL, &GlobalV::NLOCAL,
1494-
&one,
1495-
&VU[0], &one_int, &one_int, GlobalC::ParaO.desc,
1496-
&one,
1497-
HR, &one_int, &one_int, GlobalC::ParaO.desc);
1498-
1499-
return;
1493+
return;
15001494
}
15011495

15021496
void DFTU::folding_overlap_matrix(const int ik, std::complex<double>* Sk)

0 commit comments

Comments
 (0)