Skip to content

Commit 4ce66ba

Browse files
Fix: Now EXX PW doesn't depend on LibRI
1 parent 155f47a commit 4ce66ba

File tree

11 files changed

+37
-53
lines changed

11 files changed

+37
-53
lines changed

source/module_elecstate/elecstate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,8 @@ class ElecState
132132
bool vnew_exist = false;
133133
void cal_converged();
134134
void cal_energies(const int type);
135-
#ifdef __EXX
136-
#ifdef __LCAO
137135
void set_exx(const double& Eexx);
138136
void set_exx(const std::complex<double>& Eexx);
139-
#endif //__LCAO
140-
#endif //__EXX
141137

142138
double get_hartree_energy();
143139
double get_etot_efield();

source/module_elecstate/elecstate_exx.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace elecstate
44
{
55

6-
#ifdef __EXX
7-
#ifdef __LCAO
86
/// @brief calculation if converged
97
/// @date Peize Lin add 2016-12-03
108
void ElecState::set_exx(const double& Eexx)
@@ -17,7 +15,5 @@ void ElecState::set_exx(const double& Eexx)
1715
}
1816
return;
1917
}
20-
#endif //__LCAO
21-
#endif //__EXX
2218

2319
}

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
221221
}
222222

223223

224-
// EXX Todo: Fix the control flow
225-
#ifdef __EXX
226224
// 10) initialize exx pw
227225
if (PARAM.inp.calculation == "scf"
228226
|| PARAM.inp.calculation == "relax"
@@ -241,7 +239,6 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
241239
exx_helper.set_psi(this->kspw_psi[0]);
242240
}
243241
}
244-
#endif
245242

246243
}
247244

@@ -276,7 +273,6 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
276273
// allocate HamiltPW
277274
this->allocate_hamilt(ucell);
278275

279-
#ifdef __EXX
280276
if (PARAM.inp.calculation == "scf"
281277
|| PARAM.inp.calculation == "relax"
282278
|| PARAM.inp.calculation == "cell-relax"
@@ -289,7 +285,6 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
289285
}
290286

291287
}
292-
#endif
293288

294289

295290
//----------------------------------------------------------
@@ -538,12 +533,10 @@ void ESolver_KS_PW<T, Device>::update_pot(UnitCell& ucell, const int istep, cons
538533
template <typename T, typename Device>
539534
void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& iter, bool& conv_esolver)
540535
{
541-
#ifdef __EXX
542536
if (GlobalC::exx_info.info_global.cal_exx && !exx_helper.first_iter)
543537
{
544538
this->pelec->set_exx(exx_helper.cal_exx_energy(this->ctx, this->kspw_psi[0], this->pw_wfc, this->pw_rho, &ucell, &this->kv));
545539
}
546-
#endif
547540

548541
// deband is calculated from "output" charge density calculated
549542
// in sum_band
@@ -563,20 +556,19 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
563556
this->ppcell.cal_effective_D(veff, this->pw_rhod, ucell);
564557
}
565558

566-
#ifdef __EXX
567559
if (GlobalC::exx_info.info_global.cal_exx)
568560
{
569561
if (GlobalC::exx_info.info_global.separate_loop)
570562
{
571563
if (conv_esolver)
572564
{
573-
std::cout << " setting psi for exx inner loop" << std::endl;
574565
exx_helper.set_psi(this->kspw_psi[0]);
575566

576567
conv_esolver = exx_helper.exx_after_converge(iter);
577568

578569
if (!conv_esolver)
579570
{
571+
std::cout << " Setting Psi for EXX PW Inner Loop" << std::endl;
580572
exx_helper.first_iter = false;
581573
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);
582574
update_pot(ucell, istep, iter, conv_esolver);
@@ -590,7 +582,6 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
590582
}
591583

592584
}
593-
#endif // __EXX
594585

595586
// 3) Print out electronic wavefunctions in pw basis
596587
if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2)

source/module_esolver/esolver_ks_pw.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ class ESolver_KS_PW : public ESolver_KS<T, Device>
3333

3434
void after_all_runners(UnitCell& ucell) override;
3535

36-
// EXX Todo: verify current implementation for after_converge
37-
// virtual bool do_after_converge(int &iter) override;
38-
#ifdef __EXX
3936
Exx_Helper<T, Device> exx_helper;
40-
#endif
41-
4237

4338
protected:
4439
virtual void before_scf(UnitCell& ucell, const int istep) override;

source/module_hamilt_general/module_xc/xc_functional.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
287287
}
288288

289289
#ifndef __EXX
290-
if(func_type == 4 || func_type == 5)
290+
if((func_type == 4 || func_type == 5) && PARAM.inp.basis_type == "lcao")
291291
{
292-
ModuleBase::WARNING_QUIT("set_xc_type","compile with libri to use hybrid functional");
292+
ModuleBase::WARNING_QUIT("set_xc_type","compile with libri to use hybrid functional in lcao basis");
293293
}
294294
#endif
295295

source/module_hamilt_pw/hamilt_pwdft/global.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ static const char* _hipfftGetErrorString(hipfftResult_t error)
255255
//==========================================================
256256
namespace GlobalC
257257
{
258-
#ifdef __EXX
258+
//#ifdef __EXX
259259
extern Exx_Info exx_info;
260-
#endif
260+
//#endif
261261
} // namespace GlobalC
262262

263263
#include "module_cell/parallel_kpoints.h"

source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ class HamiltPW : public Hamilt<T, Device>
3737
const int nbands // number of bands
3838
) const override;
3939

40-
#ifdef __EXX
4140
void set_exx_helper(Exx_Helper<T, Device>* exx_helper_in);
4241
Exx_Helper<T, Device>* p_exx_helper;
43-
#endif
4442

4543
protected:
4644
// used in sPhi, which are calculated in hPsi or sPhi

source/module_hamilt_pw/hamilt_pwdft/module_exx_helper/exx_helper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,12 @@ template class Exx_Helper<std::complex<double>, base_device::DEVICE_CPU>;
249249
#if ((defined __CUDA) || (defined __ROCM))
250250
template class Exx_Helper<std::complex<float>, base_device::DEVICE_GPU>;
251251
template class Exx_Helper<std::complex<double>, base_device::DEVICE_GPU>;
252+
#endif
253+
254+
#ifndef __EXX
255+
#include "module_hamilt_general/module_xc/exx_info.h"
256+
namespace GlobalC
257+
{
258+
Exx_Info exx_info;
259+
}
252260
#endif

source/module_hamilt_pw/hamilt_pwdft/operator_pw/op_exx_pw.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ extern "C"
2222
//extern "C" void zpotrf_(char* uplo, const int* n, std::complex<double>* A, const int* lda, int* info);
2323
//extern "C" void cpotrf_(char* uplo, const int* n, std::complex<float>* A, const int* lda, int* info);
2424

25-
#ifdef __EXX
26-
#define __EXX_PW
27-
#endif
28-
29-
#ifdef __EXX_PW
3025
#include "op_exx_pw.h"
3126
#include "module_hamilt_pw/hamilt_pwdft/global.h"
3227

@@ -118,7 +113,7 @@ void OperatorEXXPW<T, Device>::act(const int nbands,
118113
if (p_exx_helper->construct_ace)
119114
{
120115
construct_ace();
121-
std::cout << "ACE constructed" << std::endl;
116+
// std::cout << "ACE constructed" << std::endl;
122117
p_exx_helper->construct_ace = false;
123118
}
124119

@@ -787,5 +782,3 @@ template class OperatorEXXPW<std::complex<double>, base_device::DEVICE_CPU>;
787782
#endif
788783

789784
} // namespace hamilt
790-
791-
#endif

source/module_hamilt_pw/hamilt_pwdft/operator_pw/op_exx_pw.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#include <utility>
1717
#include <vector>
1818

19-
#ifdef __EXX
20-
#define __EXX_PW
21-
#endif
22-
23-
#ifdef __EXX_PW
2419
namespace hamilt
2520
{
2621

@@ -145,6 +140,4 @@ class OperatorEXXPW : public OperatorPW<T, Device>
145140

146141
} // namespace hamilt
147142

148-
#endif // __EXX_PW
149-
150143
#endif // OPEXXPW_H

0 commit comments

Comments
 (0)