27#include <RI/distribute/Distribute_Equally.h>
28#include <RI/global/Map_Operator-3.h>
38template<
typename Tdata>
43 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in)
54template <
typename Tdata>
56 const MPI_Comm &mpi_comm_in,
60 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &abfs_in,
75 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>
77 if(this->
info.files_abfs.empty())
78 { this->
abfs = abfs_same_atom;}
89 for(
size_t T=0;
T!=this->
abfs.size(); ++
T )
96 this->
MGT = std::make_shared<ORB_gaunt_table>();
105 std::size_t workspace_bytes = 0;
108 workspace_bytes += table.release_workspace();
110 std::cout <<
" Bessel table workspace released (bytes): " << workspace_bytes << std::endl;
115template <
typename Tdata>
125 for (
auto object = this->
exx_objs.begin();
object != this->exx_objs.end();)
127 if (settings.count(object->first) == 0)
129 object = this->
exx_objs.erase(
object);
136 for (
const auto& settings_list : settings)
140 && previous->second == settings_list.second;
141 if (unchanged && this->
exx_objs.count(settings_list.first) != 0)
148 this->
exx_objs.erase(settings_list.first);
149 auto&
object = this->
exx_objs[settings_list.first];
151 this->
abfs, settings_list.second.second, this->info.ccp_rmesh_times);
152 object.cv.set_orbitals(
158 this->
info.kmesh_times,
160 settings_list.second.first,
162 object.cv.set_info_ri(&this->
info);
167 settings_list.second.second, this->MGT, this->info.ccp_rmesh_times,
168 this->info.kmesh_times, evq_abfs_Lmax);
176template <
typename Tdata>
178 const MPI_Comm& mpi_comm_in,
182 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>& abfs_in)
196 const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_same_atom
198 ucell, orb, this->
lcaos, this->
info.kmesh_times, this->info.pca_threshold);
199 if (this->
info.files_abfs.empty())
200 { this->
abfs = abfs_same_atom; }
206 this->
abfs = abfs_in;
211 for (
size_t T = 0;
T != this->
abfs.size(); ++
T)
221 this->
MGT = std::make_shared<ORB_gaunt_table>();
224 {
throw std::invalid_argument(
"Exx_LRI::init_spencer failed to prepare Center2 settings."); }
228 center2_settings->second.second,
229 this->info.ccp_rmesh_times);
236 this->
info.kmesh_times,
238 center2_settings->second.first,
246template<
typename Tdata>
258 std::vector<TA> atoms(ucell.
nat);
259 for(
int iat=0; iat<ucell.
nat; ++iat)
260 { atoms[iat] = iat; }
261 std::map<TA,TatomR> atoms_pos;
262 for(
int iat=0; iat<ucell.
nat; ++iat)
264 const std::array<TatomR,Ndim> latvec
268 const std::array<Tcell,Ndim> period = {this->
p_kv->nmp[0], this->
p_kv->nmp[1], this->
p_kv->nmp[2]};
274 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
275 list_As_Vs = RI::Distribute_Equally::distribute_atoms_periods(this->
mpi_comm, atoms, period_Vs, 2,
false);
277 std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Vs;
278 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>,
Ndim>>> dVs;
279 const bool calculate_stress =
PARAM.inp.cal_stress;
280 const bool cal_dCV = (
PARAM.inp.cal_force || calculate_stress) && !this->
info.unfold_hybrid_images;
281 if (this->
info.unfold_hybrid_images && calculate_stress)
283 throw std::invalid_argument(
"Unfolded hybrid RI stress is not yet implemented");
287 std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
288 Vs_temp = this->
exx_objs[settings_list.first].cv.cal_Vs(ucell,
289 list_As_Vs.first, list_As_Vs.second[0],
290 {{
"writable_Vws",true}});
294 this->
exx_objs[settings_list.first].evq.init_ions(ucell, period_Vs);
295 const auto &coulomb_param = settings_list.second.second;
296 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_ewald;
297 for(
const auto ¶m_list : coulomb_param)
299 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_ewald_temp;
300 switch(param_list.first)
304 double chi = this->
exx_objs[settings_list.first].evq.get_singular_chi(ucell, param_list.second, 2.0);
305 Vs_ewald_temp = this->
exx_objs[settings_list.first].evq.cal_Vs(ucell, chi, Vs_temp);
310 throw std::invalid_argument( std::string(__FILE__) +
" line " + std::to_string(__LINE__) );
314 Vs_ewald = Vs_ewald.empty() ? Vs_ewald_temp :
LRI_CV_Tools::add(Vs_ewald, Vs_ewald_temp);
322 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>,
Ndim>>>
323 dVs_temp = this->
exx_objs[settings_list.first].cv.cal_dVs(ucell,
324 list_As_Vs.first, list_As_Vs.second[0],
325 {{
"writable_dVws",true}});
332 if (!this->info.unfold_hybrid_images)
334 this->exx_lri.set_Vs(std::move(Vs), this->info.V_threshold);
339 std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, Ndim>
341 this->exx_lri.set_dVs(std::move(dVs_order), this->info.V_grad_threshold);
344 std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dVRs =
LRI_CV_Tools::cal_dMRs(ucell,dVs_order);
345 this->exx_lri.set_dVRs(std::move(dVRs), this->info.V_grad_R_threshold);
350 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
351 list_As_Cs = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2,
false);
353 std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Cs;
354 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>> dCs;
355 for(
const auto &settings_list : this->coulomb_settings)
357 if(settings_list.second.first)
359 std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
360 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
361 Cs_dCs = this->exx_objs[settings_list.first].cv.cal_Cs_dCs(
363 list_As_Cs.first, list_As_Cs.second[0],
364 { {
"cal_dC",cal_dCV},
365 {
"writable_Cws",true}, {
"writable_dCws",true}, {
"writable_Vws",false}, {
"writable_dVws",false}});
366 std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> &Cs_temp = std::get<0>(Cs_dCs);
372 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>> &dCs_temp = std::get<1>(Cs_dCs);
380 if (this->info.unfold_hybrid_images)
384 for (
int d = 0; d < 3; ++d)
390 if (image_period != this->hybrid_images_period_
391 && RI::MPI_Wrapper::mpi_get_rank(this->mpi_comm) == 0)
393 std::cout <<
"RI_HYBRID_IMAGE_PERIOD " << image_period[0] <<
" " << image_period[1]
394 <<
" " << image_period[2] <<
" physical_mesh " << period[0] <<
" " << period[1]
395 <<
" " << period[2] << std::endl;
397 this->hybrid_images_period_ = image_period;
398 this->exx_lri.set_parallel(this->mpi_comm, atoms_pos, latvec, this->hybrid_images_period_);
399 this->exx_lri.set_Vs(Vs, this->info.V_threshold);
401 this->exx_lri.set_Cs(std::move(Cs), this->info.C_threshold);
405 std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, Ndim>
407 this->exx_lri.set_dCs(std::move(dCs_order), this->info.C_grad_threshold);
410 std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dCRs =
LRI_CV_Tools::cal_dMRs(ucell,dCs_order);
411 this->exx_lri.set_dCRs(std::move(dCRs), this->info.C_grad_R_threshold);
418 object.second.cv.clear_cache();
424 template <
typename Tdata>
434 std::vector<TA> atoms(ucell.
nat);
435 for(
int iat=0; iat<ucell.
nat; ++iat)
437 std::map<TA,TatomR> atoms_pos;
438 for(
int iat=0; iat<ucell.
nat; ++iat)
440 const std::array<TatomR,Ndim> latvec
444 const std::array<Tcell,Ndim> period = {this->p_kv->nmp[0], this->p_kv->nmp[1], this->p_kv->nmp[2]};
446 this->exx_lri.set_parallel(this->mpi_comm, atoms_pos, latvec, period);
449 const std::array<Tcell, Ndim> period_Vs
451 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
452 list_As_Vs = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Vs, 2,
false);
454 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>> dVs;
455 for(
const auto &settings_list : this->coulomb_settings)
457 if(!settings_list.second.first)
continue;
458 std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
459 Vs_temp = this->exx_objs[settings_list.first].cv.cal_Vs(ucell,
460 list_As_Vs.first, list_As_Vs.second[0],
461 {{
"writable_Vws",true}});
466 for (
const auto& IJRc: this->exx_objs[settings_list.first].cv.Vws)
468 const TA& I = IJRc.first;
469 const auto& JRc = IJRc.second;
470 for (
const auto& JRc_tensor: JRc)
472 const TA& J = JRc_tensor.first;
473 const auto Rc = JRc_tensor.second;
474 for (
const auto& Rc_tensor: Rc)
476 const auto& R = Rc_tensor.first;
481 std::cout <<
"Coulomb: number of atom-pairs inside atomic overlap is " << flag <<
". " << std::endl;
482 if (this->info.coul_moment ==
true)
484 double hf_Rcut = std::pow(0.75 * this->p_kv->get_nkstot_nospin() * ucell.
omega / (
ModuleBase::PI), 1.0 / 3.0);
494 moment_abfs =
nullptr;
499 for (
const auto& IJRc: this->exx_objs[settings_list.first].cv.Vws)
501 const auto& JRc = IJRc.second;
502 for (
const auto& JRc_tensor: JRc)
504 const auto Rc = JRc_tensor.second;
505 for (
const auto& Rc_tensor: Rc)
511 std::cout <<
"Coulomb: number of all atom-pairs is " << flag <<
". " << std::endl;
516 if(
PARAM.inp.cal_force ||
PARAM.inp.cal_stress)
518 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>>
519 dVs_temp = this->exx_objs[settings_list.first].cv.cal_dVs(ucell,
520 list_As_Vs.first, list_As_Vs.second[0],
521 {{
"writable_dVws",true}});
531 this->exx_lri.set_Vs(std::move(Vs_cut), this->info.V_threshold);
533 if(
PARAM.inp.cal_force ||
PARAM.inp.cal_stress)
535 std::map<TA,std::map<TAC,std::array<RI::Tensor<Tdata>,Ndim>>> dVs
536 = this->exx_objs[coulomb_method].cv.cal_dVs(ucell,
537 list_As_Vs.first, list_As_Vs.second[0],
538 {{
"writable_dVws",true}});
541 std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,Ndim> dVs_order
543 this->exx_lri.set_dVs(std::move(dVs_order), this->info.V_grad_threshold);
544 if(
PARAM.inp.cal_stress)
546 std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dVRs
548 this->exx_lri.set_dVRs(std::move(dVRs), this->info.V_grad_R_threshold);
553 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
554 list_As_Cs = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2,
false);
555 std::pair<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,
556 std::map<TA,std::map<TAC,std::array<RI::Tensor<Tdata>,3>>>>
557 Cs_dCs = this->exx_objs[coulomb_method].cv.cal_Cs_dCs(ucell,
558 list_As_Cs.first, list_As_Cs.second[0],
559 {{
"cal_dC",PARAM.inp.cal_force||PARAM.inp.cal_stress},
560 {
"writable_Cws",true},
561 {
"writable_dCws",true},
562 {
"writable_Vws",false},
563 {
"writable_dVws",false}});
564 Cs = std::get<0>(Cs_dCs);
570 this->exx_lri.set_Cs(Cs, this->info.C_threshold);
572 if(
PARAM.inp.cal_force ||
PARAM.inp.cal_stress)
574 std::map<TA,std::map<TAC,std::array<RI::Tensor<Tdata>,3>>>& dCs = std::get<1>(Cs_dCs);
576 std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,Ndim> dCs_order
578 this->exx_lri.set_dCs(std::move(dCs_order), this->info.C_grad_threshold);
579 if(
PARAM.inp.cal_stress)
581 std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dCRs
583 this->exx_lri.set_dCRs(std::move(dCRs), this->info.C_grad_R_threshold);
589template <
typename Tdata>
599 std::vector<TA> atoms(ucell.
nat);
600 for (
int iat = 0; iat < ucell.
nat; ++iat)
602 std::map<TA, TatomR> atoms_pos;
603 for (
int iat = 0; iat < ucell.
nat; ++iat)
605 const std::array<TatomR, Ndim> latvec = {
609 const std::array<Tcell, Ndim> period = {this->p_kv->nmp[0], this->p_kv->nmp[1], this->p_kv->nmp[2]};
611 this->exx_lri.set_parallel(this->mpi_comm, atoms_pos, latvec, period);
614 const std::array<Tcell, Ndim> period_Vs
616 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Vs
617 = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Vs, 2,
false);
619 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>> dVs;
620 for (
const auto& settings_list: this->coulomb_settings)
622 if (!settings_list.second.first)
624 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_temp
625 = this->exx_objs[settings_list.first].cv.cal_Vs(
628 list_As_Vs.second[0],
629 {{
"writable_Vws", true}});
634 for (
const auto& IJRc: this->exx_objs[settings_list.first].cv.Vws)
636 const TA& I = IJRc.first;
637 const auto& JRc = IJRc.second;
638 for (
const auto& JRc_tensor: JRc)
640 const TA& J = JRc_tensor.first;
641 const auto Rc = JRc_tensor.second;
642 for (
const auto& Rc_tensor: Rc)
644 const auto& R = Rc_tensor.first;
649 std::cout <<
"Coulomb: number of atom-pairs inside atomic overlap is " << flag <<
". " << std::endl;
650 if (this->info.coul_moment ==
true)
652 double hf_Rcut = std::pow(0.75 * this->p_kv->get_nkstot_nospin() * ucell.
omega / (
ModuleBase::PI), 1.0 / 3.0);
662 moment_abfs =
nullptr;
667 for (
const auto& IJRc: this->exx_objs[settings_list.first].cv.Vws)
669 const auto& JRc = IJRc.second;
670 for (
const auto& JRc_tensor: JRc)
672 const auto Rc = JRc_tensor.second;
673 for (
const auto& Rc_tensor: Rc)
679 std::cout <<
"Coulomb: number of all atom-pairs is " << flag <<
". " << std::endl;
684 this->exx_objs[settings_list.first].evq.init_ions(ucell, period_Vs);
685 const auto& coulomb_param = settings_list.second.second;
686 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_ewald;
687 for (
const auto& param_list: coulomb_param)
689 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_ewald_temp;
690 switch (param_list.first)
694 = this->exx_objs[settings_list.first].evq.get_singular_chi(ucell, param_list.second, 2.0);
695 Vs_ewald_temp = this->exx_objs[settings_list.first].evq.cal_Vs(ucell, chi, Vs_temp);
699 throw std::invalid_argument(std::string(__FILE__) +
" line " + std::to_string(__LINE__));
703 Vs_ewald = Vs_ewald.empty() ? Vs_ewald_temp :
LRI_CV_Tools::add(Vs_ewald, Vs_ewald_temp);
740template <
typename Tdata>
750 std::vector<TA> atoms(ucell.
nat);
751 for (
int iat = 0; iat < ucell.
nat; ++iat)
755 std::map<TA, TatomR> atoms_pos;
756 for (
int iat = 0; iat < ucell.
nat; ++iat)
760 const std::array<TatomR, Ndim> latvec = {
764 const std::array<Tcell, Ndim> period = {this->
p_kv->nmp[0], this->
p_kv->nmp[1], this->
p_kv->nmp[2]};
769 auto center2_obj_it = this->exx_objs.find(center2_method);
770 if (center2_obj_it == this->exx_objs.end())
772 throw std::invalid_argument(std::string(__FILE__) +
" line " + std::to_string(__LINE__));
775 const std::array<Tcell, Ndim> period_Vs
777 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Vs
778 = RI::Distribute_Equally::distribute_atoms_periods(this->
mpi_comm, atoms, period_Vs, 2,
false);
780 Vs_cut = center2_obj_it->second.cv.cal_Vs(
783 list_As_Vs.second[0],
784 {{
"writable_Vws", true}});
790 this->exx_lri.set_Vs(Vs_cut, this->info.V_threshold);
793 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Cs
794 = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2,
false);
795 std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
796 std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
797 Cs_dCs = center2_obj_it->second.cv.cal_Cs_dCs(
800 list_As_Cs.second[0],
802 {
"writable_Cws", true},
803 {
"writable_dCws", true},
804 {
"writable_Vws", false},
805 {
"writable_dVws", false}});
806 Cs = std::get<0>(Cs_dCs);
812 this->exx_lri.set_Cs(Cs, this->info.C_threshold);
817template <
typename Tdata>
827 std::vector<TA> atoms(ucell.
nat);
828 for (
int iat = 0; iat < ucell.
nat; ++iat)
832 std::map<TA, TatomR> atoms_pos;
833 for (
int iat = 0; iat < ucell.
nat; ++iat)
837 const std::array<TatomR, Ndim> latvec = {
841 const std::array<Tcell, Ndim> period = {this->
p_kv->nmp[0], this->
p_kv->nmp[1], this->
p_kv->nmp[2]};
845 const std::array<Tcell, Ndim> period_Vs
847 const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA, std::array<Tcell, Ndim>>>>> list_As_Vs
848 = RI::Distribute_Equally::distribute_atoms_periods(this->
mpi_comm, atoms, period_Vs, 2,
false);
850 for (
const auto& settings_list : this->coulomb_settings)
852 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_temp
853 = this->exx_objs[settings_list.first].cv.cal_Vs(
856 list_As_Vs.second[0],
857 {{
"writable_Vws", true}});
862 this->exx_objs[settings_list.first].evq.init_ions(ucell, period_Vs);
863 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_ewald;
864 for (
const auto& param_list : settings_list.second.second)
866 std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Vs_ewald_temp;
867 switch (param_list.first)
871 double chi = this->exx_objs[settings_list.first].evq.get_singular_chi(ucell, param_list.second, 2.0);
872 Vs_ewald_temp = this->exx_objs[settings_list.first].evq.cal_Vs(ucell, chi, Vs_temp);
877 throw std::invalid_argument(std::string(__FILE__) +
" line " + std::to_string(__LINE__));
880 Vs_ewald = Vs_ewald.empty() ? Vs_ewald_temp :
LRI_CV_Tools::add(Vs_ewald, Vs_ewald_temp);
897template<
typename Tdata>
906 const std::vector<std::tuple<std::set<TA>, std::set<TA>>> judge
912 { this->
exx_lri.set_symmetry(
false, {}); }
916 if (p_symrot &&
PARAM.inp.nspin == 4)
919 this->
exx_lri.set_symmetry(
false, {});
926 for(
int is=0; is<
PARAM.inp.nspin; ++is)
928 const std::string suffix = ((
PARAM.inp.cal_force ||
PARAM.inp.cal_stress) ? std::to_string(is) :
"");
930 this->
exx_lri.set_Ds(Ds[is], this->
info.dm_threshold, suffix);
931 this->
exx_lri.cal_Hs({
"",
"",suffix });
933 if (this->
info.unfold_hybrid_images)
940 this->
Hexxs[is] = RI::Communicate_Tensors_Map_Judge::comm_map2_first(
941 this->
mpi_comm, std::move(this->
exx_lri.Hs), std::get<0>(judge[is]), std::get<1>(judge[is]));
946 auto Hs_a2D = this->
exx_lri.post_2D.set_tensors_map2(this->
exx_lri.Hs);
951 this->
exx_lri.post_2D.saves[
"Ds_" + suffix],
952 this->exx_lri.post_2D.set_tensors_map2(Hs_a2D));
954 this->
Hexxs[is] = RI::Communicate_Tensors_Map_Judge::comm_map2_first(
955 this->
mpi_comm, std::move(Hs_a2D), std::get<0>(judge[is]), std::get<1>(judge[is]));
961 this->
exx_lri.set_symmetry(
false, {});
965template<
typename Tdata>
969 const std::vector<std::tuple<std::set<TA>, std::set<TA>>>& judge,
978 std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, 4> Hs_irr;
979 std::array<std::string, 4> suffix;
980 for (
int is = 0; is < 4; ++is)
982 suffix[is] = std::to_string(is);
983 this->
exx_lri.set_Ds(Ds[is], this->
info.dm_threshold, suffix[is]);
984 this->
exx_lri.cal_Hs({
"",
"",suffix[is] });
985 Hs_irr[is] = this->
exx_lri.post_2D.set_tensors_map2(this->
exx_lri.Hs);
989 std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, 4> Hs_full =
993 for (
int is = 0; is < 4; ++is)
996 this->
exx_lri.post_2D.saves[
"Ds_" + suffix[is]],
997 this->exx_lri.post_2D.set_tensors_map2(Hs_full[is]));
998 this->
Hexxs[is] = RI::Communicate_Tensors_Map_Judge::comm_map2_first(
999 this->
mpi_comm, std::move(Hs_full[is]), std::get<0>(judge[is]), std::get<1>(judge[is]));
1006template<
typename Tdata>
1010 constexpr Tdata frac = -1 * 2;
1014 RI::Map_Operator::for_each( Hexxs_io, multiply_frac );
1017template<
typename Tdata>
1021 const double SPIN_multiple = std::map<int, double>{ {1,2}, {2,1}, {4,1} }.at(
PARAM.inp.nspin);
1022 const double frac = -SPIN_multiple;
1023 return frac * Eexx_in;
1043template<
typename Tdata>
1050 const int& nspin =
PARAM.inp.nspin;
1051 for(
int is=0; is<nspin; ++is)
1053 this->
exx_lri.cal_force({
"",
"",std::to_string(is),
"",
""});
1054 for(std::size_t idim=0; idim<
Ndim; ++idim) {
1055 for(
const auto &force_item : this->
exx_lri.force[idim]) {
1056 this->
force_exx(force_item.first, idim) += std::real(force_item.second);
1062 const double SPIN_multiple = std::map<int,double>{{1,2}, {2,1}, {4,1}}.at(nspin);
1063 const double frac = -2 * SPIN_multiple;
1069template<
typename Tdata>
1076 for(
int is=0; is<
PARAM.inp.nspin; ++is)
1078 this->
exx_lri.cal_stress({
"",
"",std::to_string(is),
"",
""});
1079 for(std::size_t idim0=0; idim0<
Ndim; ++idim0) {
1080 for(std::size_t idim1=0; idim1<
Ndim; ++idim1) {
1085 const double SPIN_multiple = std::map<int,double>{{1,2}, {2,1}, {4,1}}.at(
PARAM.inp.nspin);
1086 const double frac = 2 * SPIN_multiple / omega * lat0;
std::vector< ModuleBase::Vector3< double > > tau
Cartesian coordinates of each atom in this type, in unit of lat0.
Definition atom_spec.h:52
static void print_orbs_size(const UnitCell &ucell, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &orbs, std::ostream &os)
Definition exx_abfs_ctor_orbs.cpp:475
static void filter_empty_orbs(std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &orbs)
Definition exx_abfs_ctor_orbs.cpp:545
static std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > abfs_same_atom(const UnitCell &ucell, const LCAO_Orbitals &orb, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &lcaos, const double kmesh_times_mot, const double times_threshold=0)
Definition exx_abfs_ctor_orbs.cpp:80
static std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > change_orbs(const LCAO_Orbitals &orb_in, const double kmesh_times)
Definition exx_abfs_ctor_orbs.cpp:10
static std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > construct_abfs(const LCAO_Orbitals &orbs, const std::vector< std::string > &files_abfs, const double kmesh_times=1)
Definition exx_abfs_io.cpp:12
ModuleBase::matrix stress_exx
Definition exx_lri.h:148
void post_process_Hexx(std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Hexxs_io) const
Definition exx_lri.hpp:1007
std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > lcaos
Definition exx_lri.h:166
int abfs_Lmax_
Definition exx_lri.h:160
CoulombSettings coulomb_settings
Definition exx_lri.h:172
std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > abfs
Definition exx_lri.h:167
void init(const MPI_Comm &mpi_comm_in, const UnitCell &ucell, const K_Vectors &kv_in, const LCAO_Orbitals &orb, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &abfs_in={})
Definition exx_lri.hpp:39
void cal_cut_coulomb_cs(std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Vs_cut_IJR, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Cs, const UnitCell &ucell, const bool write_cv=false)
Definition exx_lri.hpp:741
static constexpr std::size_t Ndim
Definition exx_lri.h:54
std::vector< std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > > Hexxs
Definition exx_lri.h:143
Exx_Info_RI info
Definition exx_lri.h:158
ModuleBase::matrix force_exx
Definition exx_lri.h:147
void cal_exx_elec(const std::vector< std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > > &Ds, const UnitCell &ucell, const Parallel_Orbitals &pv, const ModuleSymmetry::Symmetry_rotation *p_symrot=nullptr)
Definition exx_lri.hpp:898
void cal_exx_elec_soc(const std::vector< std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > > &Ds, const UnitCell &ucell, const std::vector< std::tuple< std::set< TA >, std::set< TA > > > &judge, const ModuleSymmetry::Symmetry_rotation *p_symrot)
Definition exx_lri.hpp:966
std::shared_ptr< ORB_gaunt_table > MGT
Definition exx_lri.h:163
double post_process_Eexx(const double &Eexx_in) const
Definition exx_lri.hpp:1018
std::pair< TA, TC > TAC
Definition exx_lri.h:56
std::map< Conv_Coulomb_Pot_K::Coulomb_Method, std::pair< bool, std::map< Conv_Coulomb_Pot_K::Coulomb_Type, std::vector< std::map< std::string, std::string > > > > > CoulombSettings
Definition exx_lri.h:60
int TA
Definition exx_lri.h:52
void refresh_coulomb(const UnitCell &ucell, const LCAO_Orbitals &orb, const CoulombSettings &settings, const bool use_gpu)
Refresh changed Coulomb kernels while retaining the initialized basis and Gaunt table.
Definition exx_lri.hpp:116
double Eexx
Definition exx_lri.h:144
std::map< Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj< Tdata > > exx_objs
Definition exx_lri.h:169
void cal_exx_ions(const UnitCell &ucell, const bool write_cv=false)
Definition exx_lri.hpp:247
MPI_Comm mpi_comm
Definition exx_lri.h:161
void cal_exx_force(const int &nat)
Definition exx_lri.hpp:1044
void init_spencer(const MPI_Comm &mpi_comm_in, const UnitCell &ucell, const K_Vectors &kv_in, const LCAO_Orbitals &orb, const std::vector< std::vector< std::vector< Numerical_Orbital_Lm > > > &abfs_in={})
Definition exx_lri.hpp:177
RI::Exx< TA, Tcell, Ndim, Tdata > exx_lri
Definition exx_lri.h:171
void cal_ewald_coulomb(std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Vs_full_IJR, std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > &Cs, const UnitCell &ucell, const bool write_cv=false)
Definition exx_lri.hpp:818
void cal_exx_stress(const double &omega, const double &lat0)
Definition exx_lri.hpp:1070
const K_Vectors * p_kv
Definition exx_lri.h:162
std::vector< double > orb_cutoff_
Definition exx_lri.h:164
Class for k-points management.
Definition klist.h:20
std::vector< double > cutoffs() const
Definition orb_read.cpp:41
Definition sph_bessel_recursive.h:52
static std::vector< Sph_Bessel_Recursive::D2 > sb_pool
Definition sph_bessel_recursive.h:94
static void start(void)
Start total time calculation.
Definition timer.cpp:44
static void end(const std::string &class_name_in, const std::string &name_in)
Definition timer.cpp:109
const std::map< Tap, std::set< TC > > & get_irred_sector() const
Definition symm_rotation_k.h:32
Definition symm_rotation.h:20
std::array< std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > >, 4 > restore_HR_nspin4(const Symmetry &symm, const Atom *atoms, const std::vector< int > &iat2it, const char mode, const std::array< std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > >, 4 > &HR_irreducible_soc) const
Definition symm_rotation_r.hpp:173
std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > > restore_HR(const Symmetry &symm, const Atom *atoms, const std::vector< int > &iat2it, const char mode, const std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > > &HR_irreduceble) const
Definition symm_rotation_r.hpp:79
Definition parallel_orbitals.h:16
Parallel_Blkcyclic & para_2d()
Definition parallel_orbitals.h:24
Definition rpa_lri_coeff_v1.h:11
Provide the basic information about unitcell.
Definition unitcell.h:16
Atom * atoms
Definition unitcell.h:165
std::vector< int > iat2ia
iat==>ia
Definition unitcell.h:157
ModuleSymmetry::Symmetry symm
Definition unitcell.h:177
double & omega
Definition unitcell.h:139
ModuleBase::Vector3< double > & a2
Definition unitcell.h:143
ModuleBase::Vector3< double > & a3
Definition unitcell.h:143
int nat
total number of atoms of all species in unitcell
Definition unitcell.h:155
ModuleBase::Vector3< double > & a1
Definition unitcell.h:143
std::vector< int > iat2it
iat==>it, distinguish a atom belong to which type
Definition unitcell.h:156
#define T
Definition exp.cpp:237
int TA
================ RI ==================
Definition bse_util.h:36
@ Fock
Definition coulomb_config.h:12
std::enable_if<!is_std_vector< T >::value, T >::type cal_orbs_ccp(const T &orbs, const CoulombParam &coulomb_param, const double rmesh_times)
Coulomb_Method
Definition coulomb_config.h:23
@ Ewald
Definition coulomb_config.h:25
@ Center2
Definition coulomb_config.h:24
std::enable_if<!is_std_vector< T >::value, T >::type cal_orbs_ccp_spencer(const T &orbs, const CoulombParam &coulomb_param, const double rmesh_times)
CoulombParam build_center2_cut_coulomb_param(const CoulombParam &coulomb_param, const UnitCell &ucell, const K_Vectors &kv, bool *synthesized_rcut)
Definition exx_lri_detail.cpp:25
int MY_RANK
global index of process
Definition global_variable.cpp:21
std::ofstream ofs_running
Definition global_variable.cpp:38
const double PI
Definition constants.h:19
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
void reduce_max(T &v)
Definition parallel_reduce.cpp:57
std::array< int, 3 > ImageCell
Definition hybrid_image_domain.h:12
void decode_hybrid_images(std::map< int, std::map< std::pair< int, ImageCell >, RI::Tensor< T > > > &blocks, const ImageCell &period)
Definition hybrid_image_domain.cpp:139
ImageCell hybrid_image_period(const ImageCell &c_extent, const ImageCell &v_extent)
Definition hybrid_image_domain.cpp:62
std::vector< std::tuple< std::set< TA >, std::set< TA > > > get_2D_judge(const UnitCell &ucell, const Parallel_Blkcyclic &pv)
ImageCell retained_image_extent(std::map< int, std::map< std::pair< int, ImageCell >, RI::Tensor< T > > > &blocks, const double threshold)
Definition hybrid_image_domain.cpp:27
std::array< Tcell, 3 > Vector3_to_array3(const ModuleBase::Vector3< Tcell > &v)
Definition ri_util.h:26
std::map< Conv_Coulomb_Pot_K::Coulomb_Method, std::pair< bool, std::map< Conv_Coulomb_Pot_K::Coulomb_Type, std::vector< std::map< std::string, std::string > > > > > update_coulomb_settings(const std::map< Conv_Coulomb_Pot_K::Coulomb_Type, std::vector< std::map< std::string, std::string > > > &coulomb_param, const UnitCell &ucell, const K_Vectors *p_kv)
Definition ri_util.cpp:53
Parameter PARAM
Definition parameter.cpp:3
std::pair< int, TC > TAC
Definition test_write_ri_cv.cpp:10