@@ -48,19 +48,18 @@ void Exx_LRI<Tdata>::init(const MPI_Comm &mpi_comm_in,
48
48
{ this ->abfs = Exx_Abfs::IO::construct_abfs ( abfs_same_atom, orb, this ->info .files_abfs , this ->info .kmesh_times ); }
49
49
Exx_Abfs::Construct_Orbs::print_orbs_size (ucell, this ->abfs , GlobalV::ofs_running);
50
50
51
- const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
52
-
53
- coulomb_param_updated = RI_Util::update_coulomb_param (this ->info .coulomb_param , ucell.omega , this ->p_kv ->get_nkstot_full ());
54
- this ->abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp (this ->abfs , coulomb_param_updated, this ->info .ccp_rmesh_times );
55
-
56
51
for ( size_t T=0 ; T!=this ->abfs .size (); ++T )
57
52
{ GlobalC::exx_info.info_ri .abfs_Lmax = std::max ( GlobalC::exx_info.info_ri .abfs_Lmax , static_cast <int >(this ->abfs [T].size ())-1 ); }
58
53
59
- this ->cv .set_orbitals (
60
- ucell,
61
- orb,
62
- this ->lcaos , this ->abfs , this ->abfs_ccp ,
63
- this ->info .kmesh_times , this ->info .ccp_rmesh_times );
54
+ for (const auto &settings_list : this ->info .coulomb_settings )
55
+ {
56
+ const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
57
+ coulomb_param_updated = RI_Util::update_coulomb_param (settings_list.second .second , ucell.omega , this ->p_kv ->get_nkstot_full ());
58
+ this ->exx_objs [settings_list.first ].abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp (this ->abfs , coulomb_param_updated, this ->info .ccp_rmesh_times );
59
+ this ->exx_objs [settings_list.first ].cv .set_orbitals (ucell, orb,
60
+ this ->lcaos , this ->abfs , this ->exx_objs [settings_list.first ].abfs_ccp ,
61
+ this ->info .kmesh_times , this ->info .ccp_rmesh_times );
62
+ }
64
63
65
64
ModuleBase::timer::tick (" Exx_LRI" , " init" );
66
65
}
@@ -96,26 +95,39 @@ void Exx_LRI<Tdata>::cal_exx_ions(const UnitCell& ucell,
96
95
const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
97
96
list_As_Vs = RI::Distribute_Equally::distribute_atoms_periods (this ->mpi_comm , atoms, period_Vs, 2 , false );
98
97
99
- std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
100
- Vs = this ->cv .cal_Vs (ucell,
101
- list_As_Vs.first , list_As_Vs.second [0 ],
102
- {{" writable_Vws" ,true }});
103
- this ->cv .Vws = LRI_CV_Tools::get_CVws (ucell,Vs);
98
+ std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Vs;
99
+ std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>> dVs;
100
+ for (const auto &settings_list : this ->info .coulomb_settings )
101
+ {
102
+ std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
103
+ Vs_temp = this ->exx_objs [settings_list.first ].cv .cal_Vs (ucell,
104
+ list_As_Vs.first , list_As_Vs.second [0 ],
105
+ {{" writable_Vws" ,true }});
106
+ this ->exx_objs [settings_list.first ].cv .Vws = LRI_CV_Tools::get_CVws (ucell,Vs_temp);
107
+ Vs = Vs.empty () ? Vs_temp : LRI_CV_Tools::add (Vs, Vs_temp);
108
+
109
+ if (PARAM.inp .cal_force || PARAM.inp .cal_stress )
110
+ {
111
+ std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>>
112
+ dVs_temp = this ->exx_objs [settings_list.first ].cv .cal_dVs (ucell,
113
+ list_As_Vs.first , list_As_Vs.second [0 ],
114
+ {{" writable_dVws" ,true }});
115
+ this ->exx_objs [settings_list.first ].cv .dVws = LRI_CV_Tools::get_dCVws (ucell,dVs_temp);
116
+ dVs = dVs.empty () ? dVs_temp : LRI_CV_Tools::add (dVs, dVs_temp);
117
+ }
118
+ }
104
119
if (write_cv && GlobalV::MY_RANK == 0 )
105
120
{ LRI_CV_Tools::write_Vs_abf (Vs, PARAM.globalv .global_out_dir + " Vs" ); }
106
121
this ->exx_lri .set_Vs (std::move (Vs), this ->info .V_threshold );
107
122
108
123
if (PARAM.inp .cal_force || PARAM.inp .cal_stress )
109
124
{
110
- std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3 >
111
- dVs = this ->cv .cal_dVs (ucell,
112
- list_As_Vs.first , list_As_Vs.second [0 ],
113
- {{" writable_dVws" ,true }});
114
- this ->cv .dVws = LRI_CV_Tools::get_dCVws (ucell,dVs);
115
- this ->exx_lri .set_dVs (std::move (dVs), this ->info .V_grad_threshold );
125
+ std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, Ndim>
126
+ dVs_order = LRI_CV_Tools::change_order (std::move (dVs));
127
+ this ->exx_lri .set_dVs (std::move (dVs_order), this ->info .V_grad_threshold );
116
128
if (PARAM.inp .cal_stress )
117
129
{
118
- std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3 >,3 > dVRs = LRI_CV_Tools::cal_dMRs (ucell,dVs );
130
+ std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3 >,3 > dVRs = LRI_CV_Tools::cal_dMRs (ucell,dVs_order );
119
131
this ->exx_lri .set_dVRs (std::move (dVRs), this ->info .V_grad_R_threshold );
120
132
}
121
133
}
@@ -124,26 +136,43 @@ void Exx_LRI<Tdata>::cal_exx_ions(const UnitCell& ucell,
124
136
const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
125
137
list_As_Cs = RI::Distribute_Equally::distribute_atoms_periods (this ->mpi_comm , atoms, period_Cs, 2 , false );
126
138
127
- std::pair<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>, std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3 >>
128
- Cs_dCs = this ->cv .cal_Cs_dCs (
129
- ucell,
130
- list_As_Cs.first , list_As_Cs.second [0 ],
131
- {{" cal_dC" ,PARAM.inp .cal_force ||PARAM.inp .cal_stress },
132
- {" writable_Cws" ,true }, {" writable_dCws" ,true }, {" writable_Vws" ,false }, {" writable_dVws" ,false }});
133
- std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> &Cs = std::get<0 >(Cs_dCs);
134
- this ->cv .Cws = LRI_CV_Tools::get_CVws (ucell,Cs);
139
+ std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Cs;
140
+ std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3 >>> dCs;
141
+ for (const auto &settings_list : this ->info .coulomb_settings )
142
+ {
143
+ if (settings_list.second .first )
144
+ {
145
+ std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
146
+ std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3 >>>>
147
+ Cs_dCs = this ->exx_objs [settings_list.first ].cv .cal_Cs_dCs (
148
+ ucell,
149
+ list_As_Cs.first , list_As_Cs.second [0 ],
150
+ {{" cal_dC" ,PARAM.inp .cal_force ||PARAM.inp .cal_stress },
151
+ {" writable_Cws" ,true }, {" writable_dCws" ,true }, {" writable_Vws" ,false }, {" writable_dVws" ,false }});
152
+ std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> &Cs_temp = std::get<0 >(Cs_dCs);
153
+ this ->exx_objs [settings_list.first ].cv .Cws = LRI_CV_Tools::get_CVws (ucell,Cs_temp);
154
+ Cs = Cs.empty () ? Cs_temp : LRI_CV_Tools::add (Cs, Cs_temp);
155
+
156
+ if (PARAM.inp .cal_force || PARAM.inp .cal_stress )
157
+ {
158
+ std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3 >>> &dCs_temp = std::get<1 >(Cs_dCs);
159
+ this ->exx_objs [settings_list.first ].cv .dCws = LRI_CV_Tools::get_dCVws (ucell,dCs_temp);
160
+ dCs = dCs.empty () ? dCs_temp : LRI_CV_Tools::add (dCs, dCs_temp);
161
+ }
162
+ }
163
+ }
135
164
if (write_cv && GlobalV::MY_RANK == 0 )
136
165
{ LRI_CV_Tools::write_Cs_ao (Cs, PARAM.globalv .global_out_dir + " Cs" ); }
137
166
this ->exx_lri .set_Cs (std::move (Cs), this ->info .C_threshold );
138
167
139
168
if (PARAM.inp .cal_force || PARAM.inp .cal_stress )
140
169
{
141
- std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3 > &dCs = std::get< 1 >(Cs_dCs);
142
- this -> cv . dCws = LRI_CV_Tools::get_dCVws (ucell, dCs);
143
- this ->exx_lri .set_dCs (std::move (dCs ), this ->info .C_grad_threshold );
170
+ std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, Ndim>
171
+ dCs_order = LRI_CV_Tools::change_order ( std::move ( dCs) );
172
+ this ->exx_lri .set_dCs (std::move (dCs_order ), this ->info .C_grad_threshold );
144
173
if (PARAM.inp .cal_stress )
145
174
{
146
- std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3 >,3 > dCRs = LRI_CV_Tools::cal_dMRs (ucell,dCs );
175
+ std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3 >,3 > dCRs = LRI_CV_Tools::cal_dMRs (ucell,dCs_order );
147
176
this ->exx_lri .set_dCRs (std::move (dCRs), this ->info .C_grad_R_threshold );
148
177
}
149
178
}
0 commit comments