7#include <RI/global/Tensor.h>
12 template<
typename Tdata>
14 const int nspin,
const int nbasis,
15 std::vector<std::map<
int, std::map<
TAC, RI::Tensor<Tdata>>>>& Hexxs)
19 for (
int is = 0;is < nspin;++is)
25 for (
int iat1 = 0; iat1 < ucell.
nat; ++iat1) {
26 for (
int iat2 = 0;iat2 < ucell.
nat;++iat2) {
27 for (
int iR = 0;iR < nR;++iR)
30 TC dR({ R[0], R[1], R[2] });
31 Hexxs[is][iat1][{iat2, dR}] = RI::Tensor<Tdata>(
41#pragma omp for schedule(dynamic)
43 for (
int iR = 0;iR < nR;++iR)
50 const int& i = ijv.first.first * npol;
51 const int& j = ijv.first.second * npol;
52 Hexxs.at(is).at(ucell.
iwt2iat[i]).at(
57 )(ucell.
iwt2iw[i] / npol, ucell.
iwt2iw[j] / npol) = ijv.second;
63 template<
typename Tdata>
65 std::vector<std::map<
int, std::map<
TAC, RI::Tensor<Tdata>>>>& Hexxs)
69 std::ifstream ifs(file_name, std::ios::binary);
72 cereal::BinaryInputArchive iar(ifs);
77 template<
typename Tdata>
78 std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, Tdata>>>
80 const std::map<
int, std::map<
TAC, RI::Tensor<Tdata>>>& Hexxs,
84 std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, Tdata>>> target;
85 for (
auto& a1_a2R_data : Hexxs)
87 int iat1 = a1_a2R_data.first;
88 for (
auto& a2R_data : a1_a2R_data.second)
90 int iat2 = a2R_data.first.first;
96 const TC& R = a2R_data.first.second;
97 auto& matrix = a2R_data.second;
99 for (
int i = 0;i < nw1;++i) {
100 for (
int j = 0;j < nw2;++j) {
101 target[dR][start1 + i][start2 + j] =
102 ((std::abs(matrix(i, j)) > sparse_threshold) ? matrix(i, j) :
static_cast<Tdata
>(0));
110 template<
typename Tdata>
112 const std::vector<std::map<
int, std::map<
TAC, RI::Tensor<Tdata>>>>& Hexxs)
115 std::set<Abfs::Vector3_Order<int>> all_R_coor;
116 double sparse_threshold = 1e-10;
117 for (
int is = 0;is < Hexxs.size();++is)
119 for (
const auto& HexxA : Hexxs[is])
121 const int iat0 = HexxA.first;
122 for (
const auto& HexxB : HexxA.second)
124 const int iat1 = HexxB.first.first;
126 all_R_coor.insert(R);
134 file_name +
"_" + std::to_string(is) +
".csr",
136 "Hexxs_" + std::to_string(is),
Definition abfs-vector3_order.h:16
int nw
Definition atom_spec.h:23
int stapos_wf
Definition atom_spec.h:33
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
Sparse matrix class designed mainly for csr format input and output.
Definition sparse_matrix.h:24
const std::map< std::pair< int, int >, T > & getElements() const
Definition sparse_matrix.h:90
Class to read CSR file.
Definition csr_reader.h:35
std::vector< int > getRCoordinate(int index) const
Definition csr_reader.cpp:80
int getMatrixDimension() const
Definition csr_reader.cpp:123
SparseMatrix< T > getMatrix(int Rx, int Ry, int Rz)
Definition csr_reader.cpp:102
int getNumberOfR() const
Definition csr_reader.cpp:116
Definition parallel_orbitals.h:9
int *& iat2it
Definition unitcell.h:47
Atom * atoms
Definition unitcell.h:18
const int & get_npol() const
Definition unitcell.h:76
int *& iwt2iw
Definition unitcell.h:50
int & nat
Definition unitcell.h:46
int *& iat2ia
Definition unitcell.h:48
int *& iwt2iat
Definition unitcell.h:49
void WARNING_QUIT(const std::string &, const std::string &)
Combine the functions of WARNING and QUIT.
Definition test_delley.cpp:14
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
This class has two functions: restart psi from the previous calculation, and write psi to the disk.
Definition cal_dos.h:9
std::pair< int, TC > TAC
Definition restart_exx_csr.h:11
void write_Hexxs_csr(const std::string &file_name, const UnitCell &ucell, const std::map< int, std::map< TAC, RI::Tensor< Tdata > > > &Hexxs)
write Hexxs in CSR format
void read_Hexxs_cereal(const std::string &file_name, std::vector< std::map< int, std::map< TAC, RI::Tensor< Tdata > > > > &Hexxs)
read Hexxs in cereal format
Definition restart_exx_csr.hpp:64
void read_Hexxs_csr(const std::string &file_name, const UnitCell &ucell, const int nspin, const int nbasis, std::vector< std::map< int, std::map< TAC, RI::Tensor< Tdata > > > > &Hexxs)
read Hexxs in CSR format
Definition restart_exx_csr.hpp:13
std::map< Abfs::Vector3_Order< int >, std::map< size_t, std::map< size_t, Tdata > > > calculate_RI_Tensor_sparse(const double &sparse_threshold, const std::vector< std::map< int, std::map< TAC, RI::Tensor< Tdata > > > > &Hexxs, const UnitCell &ucell)
void save_sparse(const std::map< Abfs::Vector3_Order< int >, std::map< size_t, std::map< size_t, Tdata > > > &smat, const std::set< Abfs::Vector3_Order< int > > &all_R_coor, const double &sparse_thr, const bool &binary, const std::string &filename, const Parallel_Orbitals &pv, const std::string &label, const int &istep=-1, const bool &reduce=true)
Definition write_HS_sparse.cpp:704
std::array< int, 3 > TC
Definition restart_exx_csr.h:10
ModuleBase::Vector3< Tcell > array3_to_Vector3(const std::array< Tcell, 3 > &v)
Definition RI_Util.h:38