12#include <RI/global/Global_Func-2.h>
13#include <RI/ri/Cell_Nearest.h>
23template <
typename Tdata>
24void sparse_format::cal_HR_exx(
const UnitCell& ucell,
27 const int& current_spin,
28 const double& sparse_threshold,
30 const std::vector<std::map<
int,
31 std::map<std::pair<
int, std::array<int, 3>>,
32 RI::Tensor<Tdata>>>>& Hexxs) {
38 std::map<int, std::array<double, 3>> atoms_pos;
39 for (
int iat = 0; iat < ucell.
nat; ++iat) {
44 const std::array<std::array<double, 3>, 3> latvec
49 const std::array<int, 3> Rs_period = {nmp[0], nmp[1], nmp[2]};
51 RI::Cell_Nearest<int, int, 3, double, 3> cell_nearest;
52 cell_nearest.init(atoms_pos, latvec, Rs_period);
55 ? std::vector<int>{current_spin}
56 : std::vector<int>{0, 1, 2, 3};
58 for (
const int is: is_list)
69 for (
const auto& HexxA: Hexxs[is])
71 const int iat0 = HexxA.first;
72 for (
const auto& HexxB: HexxA.second)
74 const int iat1 = HexxB.first.first;
77 cell_nearest.get_cell_nearest_discrete(iat0,
83 const RI::Tensor<Tdata>& Hexx = HexxB.second;
85 for (
size_t iw0 = 0; iw0 < Hexx.shape[0]; ++iw0)
95 for (
size_t iw1 = 0; iw1 < Hexx.shape[1]; ++iw1)
105 if (std::abs(Hexx(iw0, iw1)) > sparse_threshold)
112 double& HR_sparse = HR_sparse_ptr[iwt1];
113 HR_sparse += RI::Global_Func::convert<double>(
114 frac * Hexx(iw0, iw1));
115 if (std::abs(HR_sparse) <= sparse_threshold)
117 HR_sparse_ptr.erase(iwt1);
125 std::complex<double>& HR_sparse
126 = HR_sparse_ptr[iwt1];
128 HR_sparse += RI::Global_Func::convert<
129 std::complex<double>>(frac * Hexx(iw0, iw1));
131 if (std::abs(HR_sparse) <= sparse_threshold)
133 HR_sparse_ptr.erase(iwt1);
138 throw std::invalid_argument(std::string(__FILE__) +
" line "
139 + std::to_string(__LINE__));
Definition abfs-vector3_order.h:16
std::vector< ModuleBase::Vector3< double > > tau
Definition atom_spec.h:36
Definition LCAO_HS_arrays.hpp:9
std::set< Abfs::Vector3_Order< int > > all_R_coor
Definition LCAO_HS_arrays.hpp:71
std::map< Abfs::Vector3_Order< int >, std::map< size_t, std::map< size_t, double > > > HR_sparse[2]
Definition LCAO_HS_arrays.hpp:29
std::map< Abfs::Vector3_Order< int >, std::map< size_t, std::map< size_t, std::complex< double > > > > HR_soc_sparse
Definition LCAO_HS_arrays.hpp:50
static void tick(const std::string &class_name_in, const std::string &name_in)
Use twice at a time: the first time, set start_flag to false; the second time, calculate the time dur...
Definition timer.cpp:57
int global2local_col(const int igc) const
get the local index of a global index (col)
Definition parallel_2d.h:51
int global2local_row(const int igr) const
get the local index of a global index (row)
Definition parallel_2d.h:45
Definition parallel_orbitals.h:9
const Input_para & inp
Definition parameter.h:26
int *& iat2it
Definition unitcell.h:47
Atom * atoms
Definition unitcell.h:18
int & nat
Definition unitcell.h:46
ModuleBase::Vector3< double > & a2
Definition unitcell.h:36
ModuleBase::Vector3< double > & a3
Definition unitcell.h:36
int *& iat2ia
Definition unitcell.h:48
ModuleBase::Vector3< double > & a1
Definition unitcell.h:36
Exx_Info exx_info
Definition test_xc.cpp:29
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
std::tuple< int, int > split_is_block(const int is_b)
Definition RI_2D_Comm.hpp:201
int get_iwt(const UnitCell &ucell, const int iat, const int iw_b, const int is_b)
Definition RI_2D_Comm.hpp:216
std::array< Tcell, 3 > Vector3_to_array3(const ModuleBase::Vector3< Tcell > &v)
Definition RI_Util.h:32
ModuleBase::Vector3< Tcell > array3_to_Vector3(const std::array< Tcell, 3 > &v)
Definition RI_Util.h:38
Parameter PARAM
Definition parameter.cpp:3
double hybrid_alpha
Definition exx_info.h:31
Exx_Info_Global info_global
Definition exx_info.h:38