12#include <RI/global/Global_Func-2.h>
13#include <RI/ri/Cell_Nearest.h>
23template <
typename Tdata>
24void sparse_format::cal_HR_exx(
28 const int& current_spin,
29 const double& sparse_threshold,
31 const std::vector<std::map<
int, std::map<std::pair<
int, std::array<int, 3>>, RI::Tensor<Tdata>>>>& Hexxs)
38 std::map<int, std::array<double, 3>> atoms_pos;
39 for (
int iat = 0; iat < ucell.
nat; ++iat)
43 const std::array<std::array<double, 3>, 3> latvec
48 const std::array<int, 3> Rs_period = {nmp[0], nmp[1], nmp[2]};
50 RI::Cell_Nearest<int, int, 3, double, 3> cell_nearest;
51 cell_nearest.init(atoms_pos, latvec, Rs_period);
53 const std::vector<int> is_list
54 = (
PARAM.
inp.
nspin != 4) ? std::vector<int>{current_spin} : std::vector<int>{0, 1, 2, 3};
56 for (
const int is: is_list)
67 for (
const auto& HexxA: Hexxs[is])
69 const int iat0 = HexxA.first;
70 for (
const auto& HexxB: HexxA.second)
72 const int iat1 = HexxB.first.first;
75 cell_nearest.get_cell_nearest_discrete(iat0, iat1, HexxB.first.second));
79 const RI::Tensor<Tdata>& Hexx = HexxB.second;
81 for (
size_t iw0 = 0; iw0 < Hexx.shape[0]; ++iw0)
91 for (
size_t iw1 = 0; iw1 < Hexx.shape[1]; ++iw1)
101 if (std::abs(Hexx(iw0, iw1)) > sparse_threshold)
105 auto& HR_sparse_ptr = HS_Arrays.
HR_sparse[current_spin][R][iwt0];
106 double& HR_sparse = HR_sparse_ptr[iwt1];
107 HR_sparse += RI::Global_Func::convert<double>(frac * Hexx(iw0, iw1));
108 if (std::abs(HR_sparse) <= sparse_threshold)
110 HR_sparse_ptr.erase(iwt1);
117 std::complex<double>& HR_sparse = HR_sparse_ptr[iwt1];
119 HR_sparse += RI::Global_Func::convert<std::complex<double>>(frac * Hexx(iw0, iw1));
121 if (std::abs(HR_sparse) <= sparse_threshold)
123 HR_sparse_ptr.erase(iwt1);
128 throw std::invalid_argument(std::string(__FILE__) +
" line "
129 + 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:66
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:49
Atom * atoms
Definition unitcell.h:19
int & nat
Definition unitcell.h:48
ModuleBase::Vector3< double > & a2
Definition unitcell.h:38
ModuleBase::Vector3< double > & a3
Definition unitcell.h:38
int *& iat2ia
Definition unitcell.h:50
ModuleBase::Vector3< double > & a1
Definition unitcell.h:38
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