@@ -193,6 +193,15 @@ void RDMFT<TK, TR>::init(Gint_Gamma& GG_in, Gint_k& GK_in, Parallel_Orbitals& Pa
193193#ifdef __EXX
194194 if ( GlobalC::exx_info.info_global .cal_exx )
195195 {
196+ exx_spacegroup_symmetry = (PARAM.inp .nspin < 4 && ModuleSymmetry::Symmetry::symm_flag == 1 );
197+ if (exx_spacegroup_symmetry)
198+ {
199+ const std::array<int , 3 >& period = RI_Util::get_Born_vonKarmen_period (*kv);
200+ this ->symrot_exx .find_irreducible_sector (ucell->symm , ucell->atoms , ucell->st ,
201+ RI_Util::get_Born_von_Karmen_cells (period), period, ucell->lat );
202+ this ->symrot_exx .cal_Ms (*kv, *ucell, *ParaV);
203+ }
204+
196205 if (GlobalC::exx_info.info_ri .real_number )
197206 {
198207 Vxc_fromRI_d = new Exx_LRI<double >(GlobalC::exx_info.info_ri );
@@ -571,16 +580,6 @@ void RDMFT<TK, TR>::cal_V_hartree()
571580template <typename TK, typename TR>
572581void RDMFT<TK, TR>::cal_V_XC()
573582{
574- HR_dft_XC->set_zero ();
575- HR_exx_XC->set_zero ();
576-
577- std::vector< std::vector<TK> > DM_XC (nk_total, std::vector<TK>(ParaV->nloc ));
578- std::vector< const std::vector<TK>* > DM_XC_pointer (nk_total);
579- for (int ik=0 ; ik<nk_total; ++ik) { DM_XC_pointer[ik] = &DM_XC[ik];
580- }
581-
582- get_DM_XC (DM_XC);
583-
584583 // // //test
585584 // DM_XC_pass = DM_XC;
586585
@@ -609,6 +608,7 @@ void RDMFT<TK, TR>::cal_V_XC()
609608
610609 if ( !only_exx_type )
611610 {
611+ HR_dft_XC->set_zero ();
612612 if ( PARAM.inp .gamma_only )
613613 {
614614 // this can be optimized, use potXC.update_from_charge()
@@ -661,17 +661,35 @@ void RDMFT<TK, TR>::cal_V_XC()
661661#ifdef __EXX
662662 if (GlobalC::exx_info.info_global .cal_exx )
663663 {
664+ HR_exx_XC->set_zero ();
665+
666+ std::vector< std::vector<TK> > DM_XC (nk_total, std::vector<TK>(ParaV->nloc ));
667+ get_DM_XC (DM_XC);
668+ // get DM_XC of all k points
669+ if ( exx_spacegroup_symmetry )
670+ {
671+ DM_XC = symrot_exx.restore_dm (*this ->kv , DM_XC, *ParaV); // class vector could be auto resize()
672+ }
673+ std::vector< const std::vector<TK>* > DM_XC_pointer (DM_XC.size ());
674+ for (int ik=0 ; ik<DM_XC.size (); ++ik) DM_XC_pointer[ik] = &DM_XC[ik];
675+
664676 if (GlobalC::exx_info.info_ri .real_number )
665677 {
666678 // transfer the DM_XC to appropriate format
667- std::vector<std::map<int ,std::map<std::pair<int ,std::array<int ,3 >>,RI::Tensor<double >>>> Ds_XC_d =
668- RI_2D_Comm::split_m2D_ktoR<double >(*kv, DM_XC_pointer, *ParaV, nspin);
679+ std::vector<std::map<int ,std::map<std::pair<int ,std::array<int ,3 >>,RI::Tensor<double >>>>
680+ Ds_XC_d = std::is_same<TK, double >::value // gamma_only_local
681+ ? RI_2D_Comm::split_m2D_ktoR<double >(*kv, DM_XC_pointer, *ParaV, nspin)
682+ : RI_2D_Comm::split_m2D_ktoR<double >(*kv, DM_XC_pointer, *ParaV, nspin, this ->exx_spacegroup_symmetry );
669683
670684 // provide the Ds_XC to Vxc_fromRI(V_exx_XC)
671- // Vxc_fromRI_d = new Exx_LRI<double>(GlobalC::exx_info.info_ri);
672- // Vxc_fromRI_d->init(MPI_COMM_WORLD, *kv);
673- // Vxc_fromRI_d->cal_exx_ions();
674- Vxc_fromRI_d->cal_exx_elec (Ds_XC_d, *ParaV);
685+ if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
686+ {
687+ Vxc_fromRI_d->cal_exx_elec (Ds_XC_d, *ParaV, &this ->symrot_exx );
688+ }
689+ else
690+ {
691+ Vxc_fromRI_d->cal_exx_elec (Ds_XC_d, *ParaV);
692+ }
675693
676694 // when we doing V_exx_XC.contributeHk(ik), we get HK_XC constructed by the special DM_XC
677695 V_exx_XC = new hamilt::OperatorEXX<hamilt::OperatorLCAO<TK, TR>>(
@@ -682,24 +700,24 @@ void RDMFT<TK, TR>::cal_V_XC()
682700 nullptr ,
683701 hamilt::Add_Hexx_Type::k
684702 );
685- // V_exx_XC = new hamilt::OperatorEXX<hamilt::OperatorLCAO<TK, TR>>(
686- // hsk_exx_XC,
687- // HR_exx_XC,
688- // *kv
689- // );
690-
691703 }
692704 else
693705 {
694706 // transfer the DM_XC to appropriate format
695- std::vector<std::map<int ,std::map<std::pair<int ,std::array<int ,3 >>,RI::Tensor<std::complex <double >>>>> Ds_XC_c =
696- RI_2D_Comm::split_m2D_ktoR<std::complex <double >>(*kv, DM_XC_pointer, *ParaV, nspin);
697-
698- // provide the Ds_XC to Vxc_fromRI(V_exx_XC)
699- // Vxc_fromRI_c = new Exx_LRI<std::complex<double>>(GlobalC::exx_info.info_ri);
700- // Vxc_fromRI_c->init(MPI_COMM_WORLD, *kv);
701- // Vxc_fromRI_c->cal_exx_ions();
702- Vxc_fromRI_c->cal_exx_elec (Ds_XC_c, *ParaV);
707+ std::vector<std::map<int ,std::map<std::pair<int ,std::array<int ,3 >>,RI::Tensor<std::complex <double >>>>>
708+ Ds_XC_c = std::is_same<TK, double >::value // gamma_only_local
709+ ? RI_2D_Comm::split_m2D_ktoR<std::complex <double >>(*kv, DM_XC_pointer, *ParaV, nspin)
710+ : RI_2D_Comm::split_m2D_ktoR<std::complex <double >>(*kv, DM_XC_pointer, *ParaV, nspin, this ->exx_spacegroup_symmetry );
711+
712+ // // provide the Ds_XC to Vxc_fromRI(V_exx_XC)
713+ if (this ->exx_spacegroup_symmetry && GlobalC::exx_info.info_global .exx_symmetry_realspace )
714+ {
715+ Vxc_fromRI_c->cal_exx_elec (Ds_XC_c, *ParaV, &this ->symrot_exx );
716+ }
717+ else
718+ {
719+ Vxc_fromRI_c->cal_exx_elec (Ds_XC_c, *ParaV);
720+ }
703721
704722 // when we doing V_exx_XC.contributeHk(ik), we get HK_XC constructed by the special DM_XC
705723 V_exx_XC = new hamilt::OperatorEXX<hamilt::OperatorLCAO<TK, TR>>(
@@ -840,6 +858,8 @@ void RDMFT<TK, TR>::cal_Energy(const int cal_type)
840858 double E_deband_KS = pelec->f_en .deband ;
841859 double E_deband_harris_KS = pelec->f_en .deband_harris ;
842860
861+ double E_exxType_rdmft = 0.0 ; // delete in the future
862+
843863 if ( cal_type == 1 )
844864 {
845865 // for E_TV
@@ -862,6 +882,7 @@ void RDMFT<TK, TR>::cal_Energy(const int cal_type)
862882 occNum_Mul_wfcHwfc (wk_fun_occNum, wfcHwfc_exx_XC, Exc_n_k, 1 );
863883 E_RDMFT[2 ] = getEnergy (Exc_n_k);
864884 Parallel_Reduce::reduce_all (E_RDMFT[2 ]);
885+ E_exxType_rdmft = E_RDMFT[2 ];
865886 }
866887#endif
867888 E_RDMFT[2 ] += etxc;
@@ -934,7 +955,8 @@ void RDMFT<TK, TR>::cal_Energy(const int cal_type)
934955 << " \n E_descf: " << E_descf
935956 << " \n\n Etotal_RDMFT: " << Etotal
936957 << " \n\n Exc_ksdft: " << E_xc_KS
937- << " \n E_exx_ksdft: " << E_exx_KS
958+ << " \n E_exx_ksdft: " << E_exx_KS
959+ << " \n E_exxType_rdmft: " << E_exxType_rdmft
938960 <<" \n ******\n " << std::endl;
939961 }
940962 std::cout << std::defaultfloat;
0 commit comments