Skip to content

Commit 80ada9e

Browse files
Flying-dragon-boxingzhangzh-pkuWHUweiqingzhoukirk0830haozhihan
authored
Feature: Spin-polarized calculations for EXX PW (#6260)
* feat pexsi * fix : diag not completed * feat * feat: pexsi hsolver * CMake building implemented * Works * adapt to the new container * Turn off USE_PEXSI * Update LibRI to 553c91c * modify include files * namespace-ize * new inputs added * Configure Makefile Compiling, fix typos * Fix Makefile Intel toolchains compile errors * Fix even more PEXSI related Makefile compiling issues * Modify inputs and update to latest version (#2) * run INPUT.Default() in every process in InputParaTest (#3490) Co-authored-by: kirk0830 <67682086+kirk0830@users.noreply.github.com> * add blas support for FindLAPACK.cmake (#3497) * more unittest of QO: towards orbital selection (#3499) * Fix: fix bug in mulliken charge calculation (#3503) * fix phase * fix case test * Refactor: namespace Conv_Coulomb_Pot_K (#3446) * Refactor: namespace Conv_Coulomb_Pot_K * Refactor: namespace Conv_Coulomb_Pot_K --------- Co-authored-by: wqzhou <33364058+WHUweiqingzhou@users.noreply.github.com> * enable the computation of all zeros in one function call (#3449) Co-authored-by: wqzhou <33364058+WHUweiqingzhou@users.noreply.github.com> * replace ios.eof() by ios.good() to avoid meeting badbit and failbit in reading STRU (#3506) * Build: add ccache to accelerate the testing process (#3509) * Build: add ccache to accelerate the testing process * Update test.yml * Update test.yml * Update test.yml * Docs: to avoid the misunderstanding in docs (#3518) * to avoid the misunderstanding in docs * Update docs/quick_start/hands_on.md Co-authored-by: Chun Cai <amoycaic@gmail.com> --------- Co-authored-by: Chun Cai <amoycaic@gmail.com> * Docs: fix a missing depencency in conda build env (#3508) * Feature: Add ENABLE_RAPIDJSON option to control the output of abacus.json (#3519) Add ENABLE_RAPIDJSON option to control the output of abacus.json * Feature: add python wrapper for math sphbes (#3475) * recommit for review * add python wrapper * remove timer since performace tests add * Feature: support segment split in kline mode in KPT file and `out_band` band output precision control, `8` as default (#3493) * add precision control * correct serial version of nscf_band function * fix issue 3482 * update unit and integrated test * update document * correct unittest and make compatible with false and true * fix: bug in Autotest.sh when result.ref has no totaltimeref (#3523) * Fix : unit test of module_xc (#3524) * Fix: omit small magnetic moments to avoid numerical instability (#3530) * update deltalambda * avoid numerical error in orbMulP * add constrain on Mi * change case reference value * Fix: fix multiple compiler warnings (#3515) * Fix: add noreturn attribute to warning_quit * Add type conversion * fix string literal * fix small number trunctuation * Fix system call returned value not checked * fix missing braket * Refactor parameter_pool.cpp and parameter_pool.h * remove duplicated return statements * Change WARNING_QUIT occurances in tests * Add warning message to help debug UT * output the default precision flag (#3496) Co-authored-by: kirk0830 <67682086+kirk0830@users.noreply.github.com> * Build: Improving CMake performance for finding LibXC and ELPA (#3478) * Fix for finding LibXC and ELPA * For compatibility to previous routines * syntax fix for FindELPA.cmake * Update cmake/FindELPA.cmake Co-authored-by: Chun Cai <amoycaic@gmail.com> * Using CMake interface as default for finding LibXC * update docs * fix for FindLibxc: changing imcompatible if statement * fix for FindLibxc: changing imcompatible if statement * fix for FindLibxc: changing imcompatible if statement * update docs for installing pkg-config * Update FindLibxc.cmake * Update FindLibxc.cmake * remove previous LibXC routine in CMakeLists.txt Co-authored-by: Chun Cai <amoycaic@gmail.com> * Update easy_install.md with Makefile-built LibXC supported * Update easy_install.md to include different behavior in different version on finding ELPA --------- Co-authored-by: Chun Cai <amoycaic@gmail.com> * Docs: correct some docs about mp2 smearing method (#3533) * correct some docs about mp2 smearing method * add docs about mv method * Feature : printing band density (#3501) Co-authored-by: wenfei-li <liwenfei@gmail.com> Co-authored-by: wqzhou <33364058+WHUweiqingzhou@users.noreply.github.com> * add some docs for PR#3501 (#3537) * Feature: enable restart charge density mixing during SCF (#3542) * add a new parameter mixing_restart * do not update rho if iter==mixing_restart * do not update rho if iter==mixing_restart-1 * reset mix and rho_mdata if iter==mixing_restart * fix SCF exit directly since drho=0 if iter=GlobalV::MIXING_RESTART * re-set_mixing in eachiterinit for PW and LCAO * enable SCF restarts in esolver_ks::RUN * add some UnitTests * add some Docs * new inputs added * Update input-main.md (#3551) Solve the format problem mentioned in issue 3543 * Build: fix compatibility issue against toolchain install (#3540) * Fix for finding LibXC and ELPA * For compatibility to previous routines * syntax fix for FindELPA.cmake * Update cmake/FindELPA.cmake Co-authored-by: Chun Cai <amoycaic@gmail.com> * Using CMake interface as default for finding LibXC * update docs * fix for FindLibxc: changing imcompatible if statement * fix for FindLibxc: changing imcompatible if statement * fix for FindLibxc: changing imcompatible if statement * update docs for installing pkg-config * Update FindLibxc.cmake * Update FindLibxc.cmake * remove previous LibXC routine in CMakeLists.txt Co-authored-by: Chun Cai <amoycaic@gmail.com> * Update easy_install.md with Makefile-built LibXC supported * Update easy_install.md to include different behavior in different version on finding ELPA * fix compatibility issue against toolchain * Change default ELPA install routine to old one --------- Co-authored-by: Chun Cai <amoycaic@gmail.com> * Test: Configure performance tests for math libraries (#3511) * add performace test of sphbes functions. * fix benchmark cmake errors * add dependencies for docker * update docs * add performance tests for sphbes * add google benchmark * rewrite benchmark tests in fixtures * disable internal testing in benchmark * merge benchmark into integration test --------- Co-authored-by: StarGrys <771582678@qq.com> * Configure Makefile Compiling, fix typos * Fix Makefile Intel toolchains compile errors * Fix even more PEXSI related Makefile compiling issues * Update hsolver_pw.cpp (#3556) when use_uspp==false, overlap matrix should be E. * Fix: cuda build target (#3276) * Fix: cuda buid target * Update CMakeLists.txt --------- Co-authored-by: Denghui Lu <denghuilu@pku.edu.cn> --------- Co-authored-by: wqzhou <33364058+WHUweiqingzhou@users.noreply.github.com> Co-authored-by: kirk0830 <67682086+kirk0830@users.noreply.github.com> Co-authored-by: Haozhi Han <haozhi.han@outlook.com> Co-authored-by: Zhao Tianqi <hongriTianqi@users.noreply.github.com> Co-authored-by: PeizeLin <78645006+PeizeLin@users.noreply.github.com> Co-authored-by: jinzx10 <jzx016@hotmail.com> Co-authored-by: Chun Cai <amoycaic@gmail.com> Co-authored-by: Peng Xingliang <91927439+pxlxingliang@users.noreply.github.com> Co-authored-by: Jie Li <76780849+jieli-matrix@users.noreply.github.com> Co-authored-by: Wenfei Li <38569667+wenfei-li@users.noreply.github.com> Co-authored-by: Denghui Lu <denghuilu@pku.edu.cn> Co-authored-by: YI Zeping <18586016708@163.com> Co-authored-by: wenfei-li <liwenfei@gmail.com> Co-authored-by: jingan-181 <78459531+jingan-181@users.noreply.github.com> Co-authored-by: StarGrys <771582678@qq.com> Co-authored-by: Haozhi Han <haozhi.han@stu.pku.edu.cn> * Revert "Modify inputs and update to latest version" * Update FindPEXSI.cmake to fix Comments * Fix CI errors * Fix CI Errors and Merge with Upstream * Resolve Pull Request Reviews * Fix parallel communication related issue * Fix vars in Makefile.vars, add input tests and comments for pexsi vars * Fix nspin > 1 cases * Improvement: take calculated mu as new initial guess, may slightly improve performance * Fix mistakes in the last commit * Fix: params and features - set default pexsi_temp - fix md in pexsi * fix empty lines * Fix: move params to pexsi_solver, rename USE_PEXSI to ENABLE_PEXSI * Tests: Modify Dockerfile and GitHub Workflows * Fix: wrong abacus link for dockerfile * Docs: added docs for pexsi inputs * Tests: three tests added for pexsi * Fix unit test issues in input_conv * Very good unit test, making my laptop fan spin * Change default pexsi_npole from 80 to 40 * Place pexsi_EDM in DensityMatrix, set size of pexsi_dm = 1 when GlobalV::NSPIN==4, and add comments for dmToRho * An unit test added for DiagoPexsi * modify for changed gint interface * correct nspin related behaviors * add efermi passthrough * Revert "add efermi passthrough" This reverts commit d7b402d. * commits to resolve conversations related to codes * DM and EDM pointers in pexsi now handled by diagopexsi, and copying h s matrices no longer needed * add pexsi examples * fix pexsi unit test (original version shouldn't run) * add building docs for pexsi * set cxx standard to c++14, which is required in make_unique * Fix: Fix typo related to pexsi * update to PPEXSIDFTDriver2 * default npoints to 1, so single core pexsi will work * Feature: exx operator for pw basis, single kpt * apply pexsi changes(?) * q-e style exx_div * Correct exxdiv * Fix Compile errors * refactor to abandon `pdiagh` * Fix mu_buffer and nspin * HSE examples * Feature: Multi-K exx * Feature: Multi-K exx * Updates with latest * Remove redundant global vars * Update to v3.9.0 * Update to v3.9.0, now code works * Remove Redundant cal_exx_energy in esolver_ks_pw.cpp * Some mess * Minor Fixes * Fix separate loop and screening * Add EXX stress * EXX Energy??? * Multi-K is broken??? * Fix: Multi-K and stress * Feature: ACE for single-K * Feature: ACE should work for multi-K, but not for sure * Feature: ACE works. Next step is ACE energy. * Fix: adapt to the latest instruction for variable `conv_esolver` * Reconstruct: move exx_helper to hamilt_pwdft * Fix: Now EXX PW doesn't depend on LibRI * Fix: Add input constraints for EXX PW * Fix: Remove redundant mpi barrier * Fix: Clean irrelevant files * Fix: Clean irrelevant files * Feature: add ace flag, exit on using gpu * Refactor: Phase 1 for refactoring exx energy * Feature: now ace calculates energy * Feature: enable exx energy * Fix: fix makefile compilation error * Fix: One minor fix for a segmentation fault * Tests: one integrate test for exx pw, only for verifying whether exx pw works * Revert "Tests: one integrate test for exx pw, only for verifying whether exx pw works" This reverts commit e7b606f. * Fix: EXX PW ACE open only when separate_loop is on * add timer * Feature: Double Grid method of EXX PW * Feature: Double Grid method of EXX PW Stress * Fix: Double Grid method of EXX PW Stress * Feature: add double grid variable * Feature: add double grid variable * Fis: HSE stress * Fix: HSE Stress * Fix: Timer * Fix: Timer * For non mp sampling, disable extrapolation * Modify test * Modify mp * Format * Format * Feature: nspin == 2 scf * Fix: nspin == 2 scf * Docs: EXX PW Docs * Feature: EXX PW for nspin=2 --------- Co-authored-by: zhangzhihao <1900017707@pku.edu.cn> Co-authored-by: zhangzh-pku <64026312+zhangzh-pku@users.noreply.github.com> Co-authored-by: wqzhou <33364058+WHUweiqingzhou@users.noreply.github.com> Co-authored-by: kirk0830 <67682086+kirk0830@users.noreply.github.com> Co-authored-by: Haozhi Han <haozhi.han@outlook.com> Co-authored-by: Zhao Tianqi <hongriTianqi@users.noreply.github.com> Co-authored-by: PeizeLin <78645006+PeizeLin@users.noreply.github.com> Co-authored-by: jinzx10 <jzx016@hotmail.com> Co-authored-by: Chun Cai <amoycaic@gmail.com> Co-authored-by: Peng Xingliang <91927439+pxlxingliang@users.noreply.github.com> Co-authored-by: Jie Li <76780849+jieli-matrix@users.noreply.github.com> Co-authored-by: Wenfei Li <38569667+wenfei-li@users.noreply.github.com> Co-authored-by: Denghui Lu <denghuilu@pku.edu.cn> Co-authored-by: YI Zeping <18586016708@163.com> Co-authored-by: wenfei-li <liwenfei@gmail.com> Co-authored-by: jingan-181 <78459531+jingan-181@users.noreply.github.com> Co-authored-by: StarGrys <771582678@qq.com> Co-authored-by: Haozhi Han <haozhi.han@stu.pku.edu.cn> Co-authored-by: Mohan Chen <mohan.chen.chen.mohan@gmail.com>
1 parent 9cfa31f commit 80ada9e

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

source/module_hamilt_pw/hamilt_pwdft/operator_pw/op_exx_pw.cpp

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ OperatorEXXPW<T, Device>::OperatorEXXPW(const int* isk_in,
8080
// allocate h_psi recip space memory
8181
resmem_complex_op()(h_psi_recip, wfcpw->npwk_max);
8282
// resmem_complex_op()(this->ctx, psi_all_real, wfcpw->nrxx * GlobalV::NBANDS);
83+
8384
int nks = wfcpw->nks;
84-
// std::cout << "nks: " << nks << std::endl;
85+
int nk_fac = PARAM.inp.nspin == 2 ? 2 : 1;
8586
resmem_real_op()(pot, rhopw->npw * nks * nks);
8687

8788
tpiba = ucell->tpiba;
@@ -168,6 +169,12 @@ void OperatorEXXPW<T, Device>::act_op(const int nbands,
168169
const int ngk_ik,
169170
const bool is_first_node) const
170171
{
172+
// std::cout << "nbands: " << nbands
173+
// << " nbasis: " << nbasis
174+
// << " npol: " << npol
175+
// << " ngk_ik: " << ngk_ik
176+
// << " is_first_node: " << is_first_node
177+
// << std::endl;
171178
if (!potential_got)
172179
{
173180
get_potential();
@@ -199,6 +206,7 @@ void OperatorEXXPW<T, Device>::act_op(const int nbands,
199206
Real nqs = q_points.size();
200207
for (int iq: q_points)
201208
{
209+
// std::cout << "ik" << this->ik << " iq" << iq << std::endl;
202210
for (int m_iband = 0; m_iband < psi.get_nbands(); m_iband++)
203211
{
204212
// double wg_mqb_real = GlobalC::exx_helper.wg(iq, m_iband);
@@ -518,7 +526,23 @@ std::vector<int> OperatorEXXPW<T, Device>::get_q_points(const int ik) const
518526
{
519527
for (int iq = 0; iq < wfcpw->nks; iq++)
520528
{
521-
q_points_ik.push_back(iq);
529+
if (PARAM.inp.nspin ==1 )
530+
{
531+
q_points_ik.push_back(iq);
532+
}
533+
else if (PARAM.inp.nspin == 2)
534+
{
535+
int nk_fac = 2;
536+
int nk = wfcpw->nks / nk_fac;
537+
if (iq / nk == ik / nk)
538+
{
539+
q_points_ik.push_back(iq);
540+
}
541+
}
542+
else
543+
{
544+
ModuleBase::WARNING_QUIT("OperatorEXXPW", "nspin == 4 not supported");
545+
}
522546
}
523547
}
524548
// else
@@ -539,6 +563,8 @@ void OperatorEXXPW<T, Device>::multiply_potential(T *density_recip, int ik, int
539563
ModuleBase::timer::tick("OperatorEXXPW", "multiply_potential");
540564
int npw = rhopw->npw;
541565
int nks = wfcpw->nks;
566+
int nk_fac = PARAM.inp.nspin == 2 ? 2 : 1;
567+
int nk = nks / nk_fac;
542568

543569
#ifdef _OPENMP
544570
#pragma omp parallel for schedule(static)
@@ -635,6 +661,8 @@ void OperatorEXXPW<T, Device>::get_potential() const
635661
}
636662
}
637663

664+
const int nk_fac = PARAM.inp.nspin == 2 ? 2 : 1;
665+
const int nk = nks / nk_fac;
638666
const int ig_kq = ik * nks * npw + iq * npw + ig;
639667

640668
Real gg = (k_c - q_c + rhopw->gcar[ig]).norm2() * tpiba2;
@@ -689,6 +717,8 @@ void OperatorEXXPW<T, Device>::exx_divergence()
689717
Real nqs_half2 = 0.5 * kv->nmp[1];
690718
Real nqs_half3 = 0.5 * kv->nmp[2];
691719

720+
int nk_fac = PARAM.inp.nspin == 2 ? 2 : 1;
721+
692722
// here we follow the exx_divergence subroutine in q-e (PW/src/exx_base.f90)
693723
double alpha = 10.0 / wfcpw->gk_ecut;
694724
double tpiba2 = tpiba * tpiba;
@@ -766,6 +796,7 @@ void OperatorEXXPW<T, Device>::exx_divergence()
766796
}
767797

768798
div *= ModuleBase::e2 * ModuleBase::FOUR_PI / tpiba2 / wfcpw->nks;
799+
// std::cout << "div: " << div << std::endl;
769800

770801
// numerically value the mean value of F(q) in the reciprocal space
771802
// This means we need to calculate the average of F(q) in the first brillouin zone
@@ -793,8 +824,9 @@ void OperatorEXXPW<T, Device>::exx_divergence()
793824
// printf("ucell: %p\n", ucell);
794825
double omega = ucell->omega;
795826
div -= ModuleBase::e2 * omega * aa;
796-
exx_div = div * wfcpw->nks;
797-
// std::cout << "EXX divergence: " << exx_div << std::endl;
827+
exx_div = div * wfcpw->nks / nk_fac;
828+
// exx_div = 0;
829+
// std::cout << "EXX divergence: " << exx_div << std::endl;
798830

799831
return;
800832
}
@@ -862,8 +894,7 @@ double OperatorEXXPW<T, Device>::cal_exx_energy_op(psi::Psi<T, Device> *ppsi_) c
862894
T* density_recip = new T[rhopw->npw];
863895

864896
if (wg == nullptr) return 0.0;
865-
// evaluate the Eexx
866-
// T Eexx_ik = 0.0;
897+
const int nk_fac = PARAM.inp.nspin == 2 ? 2 : 1;
867898
double Eexx_ik_real = 0.0;
868899
for (int ik = 0; ik < wfcpw->nks; ik++)
869900
{
@@ -884,8 +915,6 @@ double OperatorEXXPW<T, Device>::cal_exx_energy_op(psi::Psi<T, Device> *ppsi_) c
884915
continue;
885916
}
886917

887-
// std::cout << "ik = " << ik << " nb = " << n_iband << " wg_ikb = " << wg_ikb_real << std::endl;
888-
889918
// const T *psi_nk = get_pw(n_iband, ik);
890919
psi.fix_kb(ik, n_iband);
891920
const T* psi_nk = psi.get_pointer();
@@ -901,7 +930,6 @@ double OperatorEXXPW<T, Device>::cal_exx_energy_op(psi::Psi<T, Device> *ppsi_) c
901930
}
902931
double nqs = q_points.size();
903932

904-
// std::cout << "ik = " << ik << " ib = " << n_iband << " wg_kb = " << wg_ikb_real << " wk_ik = " << kv->wk[ik] << std::endl;
905933
for (int iq: q_points)
906934
{
907935
for (int m_iband = 0; m_iband < psi.get_nbands(); m_iband++)
@@ -914,8 +942,6 @@ double OperatorEXXPW<T, Device>::cal_exx_energy_op(psi::Psi<T, Device> *ppsi_) c
914942
continue;
915943
}
916944

917-
// std::cout << "iq = " << iq << " mb = " << m_iband << " wg_iqb = " << wg_iqb_real << std::endl;
918-
919945
psi_.fix_kb(iq, m_iband);
920946
const T* psi_mq = psi_.get_pointer();
921947
// const T* psi_mq = get_pw(m_iband, iq);
@@ -945,6 +971,7 @@ double OperatorEXXPW<T, Device>::cal_exx_energy_op(psi::Psi<T, Device> *ppsi_) c
945971
{
946972
int nks = wfcpw->nks;
947973
int npw = rhopw->npw;
974+
int nk = nks / nk_fac;
948975
Real Fac = pot[ik * nks * npw + iq * npw + ig];
949976
Eexx_ik_real += Fac * (density_recip[ig] * std::conj(density_recip[ig])).real()
950977
* wg_iqb_real / nqs * wg_ikb_real / kv->wk[ik];

source/module_io/input_conv.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ void Input_Conv::Convert()
419419
ModuleSymmetry::Symmetry::symm_flag = -1;
420420
}
421421

422-
if (PARAM.inp.nspin != 1)
422+
if (PARAM.inp.nspin != 1 && PARAM.inp.nspin != 2)
423423
{
424-
ModuleBase::WARNING_QUIT("Input_Conv", "EXX PW works only with nspin=1");
424+
ModuleBase::WARNING_QUIT("Input_Conv", "EXX PW works only with nspin=1 and 2");
425425
}
426426

427427
if (PARAM.inp.device != "cpu")

0 commit comments

Comments
 (0)