Skip to content

Commit ea871f0

Browse files
committed
change ucell in module_ri/ri_2d_comm.cpp
1 parent 14822f8 commit ea871f0

File tree

8 files changed

+44
-28
lines changed

8 files changed

+44
-28
lines changed

source/module_lr/operator_casida/operator_lr_exx.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,17 @@ namespace LR
8989
}
9090

9191
template<typename T>
92-
void OperatorLREXX<T>::act(const int nbands, const int nbasis, const int npol, const T* psi_in, T* hpsi, const int ngk_ik, const bool is_first_node)const
92+
void OperatorLREXX<T>::act(const int nbands,
93+
const int nbasis,
94+
const int npol,
95+
const T* psi_in,
96+
T* hpsi,
97+
const int ngk_ik,
98+
const bool is_first_node)const
9399
{
94100
ModuleBase::TITLE("OperatorLREXX", "act");
95101
// convert parallel info to LibRI interfaces
96-
std::vector<std::tuple<std::set<TA>, std::set<TA>>> judge = RI_2D_Comm::get_2D_judge(this->pmat);
102+
std::vector<std::tuple<std::set<TA>, std::set<TA>>> judge = RI_2D_Comm::get_2D_judge(ucell,this->pmat);
97103

98104
// suppose Cs,Vs, have already been calculated in the ion-step of ground state
99105
// and DM_trans has been calculated in hPsi() outside.
@@ -107,7 +113,7 @@ namespace LR
107113
// if multi-k, DM_trans(TR=double) -> Ds_trans(TR=T=complex<double>)
108114
std::vector<std::map<TA, std::map<TAC, RI::Tensor<T>>>> Ds_trans =
109115
aims_nbasis.empty() ?
110-
RI_2D_Comm::split_m2D_ktoR<T>(this->kv, DMk_trans_pointer, this->pmat, 1)
116+
RI_2D_Comm::split_m2D_ktoR<T>(ucell,this->kv, DMk_trans_pointer, this->pmat, 1)
111117
: RI_Benchmark::split_Ds(DMk_trans_vector, aims_nbasis, ucell); //0.5 will be multiplied
112118
// LR_Util::print_CV(Ds_trans[0], "Ds_trans in OperatorLREXX", 1e-10);
113119
// 2. cal_Hs

source/module_rdmft/rdmft_pot.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ void RDMFT<TK, TR>::cal_V_XC(const UnitCell& ucell)
274274
// transfer the DM_XC to appropriate format
275275
std::vector<std::map<int,std::map<std::pair<int,std::array<int,3>>,RI::Tensor<double>>>>
276276
Ds_XC_d = std::is_same<TK, double>::value //gamma_only_local
277-
? RI_2D_Comm::split_m2D_ktoR<double>(*kv, DM_XC_pointer, *ParaV, nspin)
278-
: RI_2D_Comm::split_m2D_ktoR<double>(*kv, DM_XC_pointer, *ParaV, nspin, this->exx_spacegroup_symmetry);
277+
? RI_2D_Comm::split_m2D_ktoR<double>(ucell,*kv, DM_XC_pointer, *ParaV, nspin)
278+
: RI_2D_Comm::split_m2D_ktoR<double>(ucell,*kv, DM_XC_pointer, *ParaV, nspin, this->exx_spacegroup_symmetry);
279279

280280
// provide the Ds_XC to Vxc_fromRI(V_exx_XC)
281281
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_global.exx_symmetry_realspace)
@@ -302,8 +302,8 @@ void RDMFT<TK, TR>::cal_V_XC(const UnitCell& ucell)
302302
// transfer the DM_XC to appropriate format
303303
std::vector<std::map<int,std::map<std::pair<int,std::array<int,3>>,RI::Tensor<std::complex<double>>>>>
304304
Ds_XC_c = std::is_same<TK, double>::value //gamma_only_local
305-
? RI_2D_Comm::split_m2D_ktoR<std::complex<double>>(*kv, DM_XC_pointer, *ParaV, nspin)
306-
: RI_2D_Comm::split_m2D_ktoR<std::complex<double>>(*kv, DM_XC_pointer, *ParaV, nspin, this->exx_spacegroup_symmetry);
305+
? RI_2D_Comm::split_m2D_ktoR<std::complex<double>>(ucell,*kv, DM_XC_pointer, *ParaV, nspin)
306+
: RI_2D_Comm::split_m2D_ktoR<std::complex<double>>(ucell,*kv, DM_XC_pointer, *ParaV, nspin, this->exx_spacegroup_symmetry);
307307

308308
// // provide the Ds_XC to Vxc_fromRI(V_exx_XC)
309309
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_global.exx_symmetry_realspace)

source/module_ri/Exx_LRI.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void Exx_LRI<Tdata>::cal_exx_elec(const std::vector<std::map<TA, std::map<TAC, R
198198
ModuleBase::TITLE("Exx_LRI","cal_exx_elec");
199199
ModuleBase::timer::tick("Exx_LRI", "cal_exx_elec");
200200

201-
const std::vector<std::tuple<std::set<TA>, std::set<TA>>> judge = RI_2D_Comm::get_2D_judge(pv);
201+
const std::vector<std::tuple<std::set<TA>, std::set<TA>>> judge = RI_2D_Comm::get_2D_judge(ucell,pv);
202202

203203
this->Hexxs.resize(PARAM.inp.nspin);
204204
this->Eexx = 0;

source/module_ri/Exx_LRI_interface.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
131131
else { this->mix_DMk_2D.mix(dm_in.get_DMK_vector(), flag_restart); }
132132
const std::vector<std::map<int,std::map<std::pair<int, std::array<int, 3>>,RI::Tensor<Tdata>>>>
133133
Ds = PARAM.globalv.gamma_only_local
134-
? RI_2D_Comm::split_m2D_ktoR<Tdata>(*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_gamma_out(), *dm_in.get_paraV_pointer(), PARAM.inp.nspin)
135-
: RI_2D_Comm::split_m2D_ktoR<Tdata>(*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_k_out(), *dm_in.get_paraV_pointer(), PARAM.inp.nspin, this->exx_spacegroup_symmetry);
134+
? RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_gamma_out(), *dm_in.get_paraV_pointer(), PARAM.inp.nspin)
135+
: RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_k_out(), *dm_in.get_paraV_pointer(), PARAM.inp.nspin, this->exx_spacegroup_symmetry);
136136
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_global.exx_symmetry_realspace)
137137
{
138138
this->exx_ptr->cal_exx_elec(Ds, ucell,*dm_in.get_paraV_pointer(), &this->symrot_);
@@ -323,8 +323,8 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
323323
// GlobalC::exx_lcao.cal_exx_elec(p_esolver->LOC, p_esolver->LOWF.wfc_k_grid);
324324
const std::vector<std::map<int, std::map<std::pair<int, std::array<int, 3>>, RI::Tensor<Tdata>>>>
325325
Ds = std::is_same<T, double>::value //gamma_only_local
326-
? RI_2D_Comm::split_m2D_ktoR<Tdata>(*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_gamma_out(), *dm.get_paraV_pointer(), nspin)
327-
: RI_2D_Comm::split_m2D_ktoR<Tdata>(*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_k_out(), *dm.get_paraV_pointer(), nspin, this->exx_spacegroup_symmetry);
326+
? RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_gamma_out(), *dm.get_paraV_pointer(), nspin)
327+
: RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_k_out(), *dm.get_paraV_pointer(), nspin, this->exx_spacegroup_symmetry);
328328

329329
// check the rotation of Ds
330330
// this->symrot_.test_HR_rotation(ucell.symm, ucell.atoms, ucell.st, 'D', Ds[0]);

source/module_ri/RI_2D_Comm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <stdexcept>
1313

1414
// judge[is] = {s0, s1}
15-
auto RI_2D_Comm::get_2D_judge(const Parallel_2D& pv)
15+
auto RI_2D_Comm::get_2D_judge(const UnitCell& ucell, const Parallel_2D& pv)
1616
-> std::vector<std::tuple<std::set<TA>, std::set<TA>>>
1717
{
1818
ModuleBase::TITLE("RI_2D_Comm","get_2D_judge");
@@ -24,7 +24,7 @@ auto RI_2D_Comm::get_2D_judge(const Parallel_2D& pv)
2424
{
2525
const int iwt0 = pv.local2global_row(iwt0_2D);
2626
int iat0=0;int iw0_b=0;int is0_b=0;
27-
std::tie(iat0,iw0_b,is0_b) = RI_2D_Comm::get_iat_iw_is_block(iwt0);
27+
std::tie(iat0,iw0_b,is0_b) = RI_2D_Comm::get_iat_iw_is_block(ucell,iwt0);
2828
iat0_list[is0_b].insert(iat0);
2929
}
3030

@@ -33,7 +33,7 @@ auto RI_2D_Comm::get_2D_judge(const Parallel_2D& pv)
3333
{
3434
const int iwt1 = pv.local2global_col(iwt1_2D);
3535
int iat1=0;int iw1_b=0;int is1_b=0;
36-
std::tie(iat1,iw1_b,is1_b) = RI_2D_Comm::get_iat_iw_is_block(iwt1);
36+
std::tie(iat1,iw1_b,is1_b) = RI_2D_Comm::get_iat_iw_is_block(ucell,iwt1);
3737
iat1_list[is1_b].insert(iat1);
3838
}
3939

source/module_ri/RI_2D_Comm.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ namespace RI_2D_Comm
3131
//public:
3232
template<typename Tdata, typename Tmatrix>
3333
extern std::vector<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>>
34-
split_m2D_ktoR(const K_Vectors& kv, const std::vector<const Tmatrix*>& mks_2D, const Parallel_2D& pv, const int nspin, const bool spgsym = false);
34+
split_m2D_ktoR(const UnitCell& ucell,
35+
const K_Vectors& kv,
36+
const std::vector<const Tmatrix*>& mks_2D,
37+
const Parallel_2D& pv,
38+
const int nspin,
39+
const bool spgsym = false);
3540

3641
// judge[is] = {s0, s1}
3742
extern std::vector<std::tuple<std::set<TA>, std::set<TA>>>
38-
get_2D_judge(const Parallel_2D& pv);
43+
get_2D_judge(const UnitCell& ucell, const Parallel_2D& pv);
3944

4045
template<typename Tdata, typename TK>
4146
extern void add_Hexx(
@@ -72,7 +77,7 @@ namespace RI_2D_Comm
7277

7378
//private:
7479
extern std::vector<int> get_ik_list(const K_Vectors &kv, const int is_k);
75-
extern inline std::tuple<int,int,int> get_iat_iw_is_block(const int iwt);
80+
extern inline std::tuple<int,int,int> get_iat_iw_is_block(const UnitCell& ucell,const int& iwt);
7681
extern inline int get_is_block(const int is_k, const int is_row_b, const int is_col_b);
7782
extern inline std::tuple<int,int> split_is_block(const int is_b);
7883
extern inline int get_iwt(const int iat, const int iw_b, const int is_b);

source/module_ri/RI_2D_Comm.hpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ inline RI::Tensor<std::complex<double>> tensor_conj(const RI::Tensor<std::comple
2929
return r;
3030
}
3131
template<typename Tdata, typename Tmatrix>
32-
auto RI_2D_Comm::split_m2D_ktoR(const K_Vectors & kv, const std::vector<const Tmatrix*>&mks_2D, const Parallel_2D & pv, const int nspin, const bool spgsym)
32+
auto RI_2D_Comm::split_m2D_ktoR(const UnitCell& ucell,
33+
const K_Vectors & kv,
34+
const std::vector<const Tmatrix*>&mks_2D,
35+
const Parallel_2D & pv,
36+
const int nspin,
37+
const bool spgsym)
3338
-> std::vector<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>>
3439
{
3540
ModuleBase::TITLE("RI_2D_Comm","split_m2D_ktoR");
@@ -63,7 +68,7 @@ auto RI_2D_Comm::split_m2D_ktoR(const K_Vectors & kv, const std::vector<const Tm
6368
RI::Tensor<Tdata_m> mk_2D = RI_Util::Vector_to_Tensor<Tdata_m>(*mks_2D[ik], pv.get_col_size(), pv.get_row_size());
6469
const Tdata_m frac = SPIN_multiple
6570
* RI::Global_Func::convert<Tdata_m>(std::exp(
66-
-ModuleBase::TWO_PI * ModuleBase::IMAG_UNIT * (kv.kvec_c[ik] * (RI_Util::array3_to_Vector3(cell) * GlobalC::ucell.latvec))));
71+
-ModuleBase::TWO_PI * ModuleBase::IMAG_UNIT * (kv.kvec_c[ik] * (RI_Util::array3_to_Vector3(cell) * ucell.latvec))));
6772
if (static_cast<int>(std::round(SPIN_multiple * kv.wk[ik] * kv.get_nkstot_full())) == 2)
6873
{ set_mR_2D(mk_2D * (frac * 0.5) + tensor_conj(mk_2D * (frac * 0.5))); }
6974
else { set_mR_2D(mk_2D * frac); }
@@ -75,7 +80,7 @@ auto RI_2D_Comm::split_m2D_ktoR(const K_Vectors & kv, const std::vector<const Tm
7580
RI::Tensor<Tdata_m> mk_2D = RI_Util::Vector_to_Tensor<Tdata_m>(*mks_2D[ik_full + is_k * kv.get_nkstot_full()], pv.get_col_size(), pv.get_row_size());
7681
const Tdata_m frac = SPIN_multiple
7782
* RI::Global_Func::convert<Tdata_m>(std::exp(
78-
-ModuleBase::TWO_PI * ModuleBase::IMAG_UNIT * ((isym_kvd.second * GlobalC::ucell.G) * (RI_Util::array3_to_Vector3(cell) * GlobalC::ucell.latvec))));
83+
-ModuleBase::TWO_PI * ModuleBase::IMAG_UNIT * ((isym_kvd.second * ucell.G) * (RI_Util::array3_to_Vector3(cell) * ucell.latvec))));
7984
set_mR_2D(mk_2D * frac);
8085
++ik_full;
8186
}
@@ -87,24 +92,24 @@ auto RI_2D_Comm::split_m2D_ktoR(const K_Vectors & kv, const std::vector<const Tm
8792
? pv.local2global_col(iwt0_2D)
8893
: pv.local2global_row(iwt0_2D);
8994
int iat0, iw0_b, is0_b;
90-
std::tie(iat0,iw0_b,is0_b) = RI_2D_Comm::get_iat_iw_is_block(iwt0);
95+
std::tie(iat0,iw0_b,is0_b) = RI_2D_Comm::get_iat_iw_is_block(ucell,iwt0);
9196
const int it0 = GlobalC::ucell.iat2it[iat0];
9297
for(int iwt1_2D=0; iwt1_2D!=mR_2D.shape[1]; ++iwt1_2D)
9398
{
9499
const int iwt1 =ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER(PARAM.inp.ks_solver)
95100
? pv.local2global_row(iwt1_2D)
96101
: pv.local2global_col(iwt1_2D);
97102
int iat1, iw1_b, is1_b;
98-
std::tie(iat1,iw1_b,is1_b) = RI_2D_Comm::get_iat_iw_is_block(iwt1);
103+
std::tie(iat1,iw1_b,is1_b) = RI_2D_Comm::get_iat_iw_is_block(ucell,iwt1);
99104
const int it1 = GlobalC::ucell.iat2it[iat1];
100105

101106
const int is_b = RI_2D_Comm::get_is_block(is_k, is0_b, is1_b);
102107
RI::Tensor<Tdata> &mR_a2D = mRs_a2D[is_b][iat0][{iat1,cell}];
103108
if (mR_a2D.empty()) {
104109
mR_a2D = RI::Tensor<Tdata>(
105-
{static_cast<size_t>(GlobalC::ucell.atoms[it0].nw),
110+
{static_cast<size_t>(ucell.atoms[it0].nw),
106111
static_cast<size_t>(
107-
GlobalC::ucell.atoms[it1].nw)});
112+
ucell.atoms[it1].nw)});
108113
}
109114
mR_a2D(iw0_b,iw1_b) = mR_2D(iwt0_2D, iwt1_2D);
110115
}
@@ -165,7 +170,7 @@ void RI_2D_Comm::add_Hexx(
165170
}
166171

167172
std::tuple<int,int,int>
168-
RI_2D_Comm::get_iat_iw_is_block(const int iwt)
173+
RI_2D_Comm::get_iat_iw_is_block(const UnitCell& ucell,const int& iwt)
169174
{
170175
const int iat = GlobalC::ucell.iwt2iat[iwt];
171176
const int iw = GlobalC::ucell.iwt2iw[iwt];

source/module_ri/RPA_LRI.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ void RPA_LRI<T, Tdata>::cal_postSCF_exx(const elecstate::DensityMatrix<T, Tdata>
100100

101101
const std::vector<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>>
102102
Ds = PARAM.globalv.gamma_only_local
103-
? RI_2D_Comm::split_m2D_ktoR<Tdata>(kv, mix_DMk_2D.get_DMk_gamma_out(), *dm.get_paraV_pointer(), PARAM.inp.nspin)
104-
: RI_2D_Comm::split_m2D_ktoR<Tdata>(kv, mix_DMk_2D.get_DMk_k_out(), *dm.get_paraV_pointer(), PARAM.inp.nspin, exx_spacegroup_symmetry);
103+
? RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,kv, mix_DMk_2D.get_DMk_gamma_out(), *dm.get_paraV_pointer(), PARAM.inp.nspin)
104+
: RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,kv, mix_DMk_2D.get_DMk_k_out(), *dm.get_paraV_pointer(), PARAM.inp.nspin, exx_spacegroup_symmetry);
105105

106106
// set parameters for bare Coulomb potential
107107
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hf;

0 commit comments

Comments
 (0)