ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
lr_util_hcontainer.h
Go to the documentation of this file.
1#ifndef ABACUS_SOURCE_LCAO_MODULE_LR_UTILS_LR_UTIL_HCONTAINER_H
2#define ABACUS_SOURCE_LCAO_MODULE_LR_UTILS_LR_UTIL_HCONTAINER_H
3
7#include <ATen/core/tensor.h>
8#include <iosfwd>
10#ifdef __EXX
13#endif
14namespace LR_Util
15{
16 template <typename T>
17 using Real = typename GetTypeReal<T>::type;
18 template<typename TR>
19 void print_HR(const hamilt::HContainer<TR>& HR, const std::string& label, const double& threshold = 1e-10)
20 {
21 std::cout << label << "\n";
22 for (int iap = 0; iap < HR.size_atom_pairs(); ++iap)
23 {
24 auto ap = HR.get_atom_pair(iap);
25 const int ia = ap.get_atom_i();
26 const int ja = ap.get_atom_j();
27 for (int iR = 0;iR < ap.get_R_size();++iR)
28 {
29 std::cout << "atom pair (" << ia << ", " << ja << "), "
30 << "R=(" << ap.get_R_index(iR)[0] << ", " << ap.get_R_index(iR)[1] << ", " << ap.get_R_index(iR)[2] << "): \n";
31 auto& mat = ap.get_HR_values(iR);
32 std::cout << "rowsize=" << ap.get_row_size() << ", colsize=" << ap.get_col_size() << "\n";
33 for (int i = 0;i < ap.get_row_size();++i)
34 {
35 for (int j = 0;j < ap.get_col_size();++j)
36 {
37 auto& v = mat.get_value(i, j);
38 std::cout << (std::abs(v) > threshold ? v : 0) << " ";
39 }
40 std::cout << "\n";
41 }
42 }
43 }
44 }
45
46 template <typename TK, typename TR>
47 void print_DMR(const module_dm::DensityMatrix<TK, TR>& DMR, const std::string& label, const double& threshold = 1e-10)
48 {
49 std::cout << label << "\n";
50 int is = 0;
51 for (auto& dr : DMR.get_dmr_vec())
52 print_HR(*dr, "DMR[ispin=s" + std::to_string(is++) + "]", threshold);
53 }
54
57 template<typename TR_from, typename TR_to>
59 hamilt::HContainer<TR_to>& HR_real, const bool get_imag)
60 {
61 for (int iap = 0; iap < HR.size_atom_pairs(); ++iap)
62 {
63 hamilt::AtomPair<TR_from>* ap = &const_cast<hamilt::HContainer<TR_from>&>(HR).get_atom_pair(iap);
64 const int ia = ap->get_atom_i();
65 const int ja = ap->get_atom_j();
66 hamilt::AtomPair<TR_to>* ap_real = HR_real.find_pair(ia, ja);
67 // under MPI-parallel (2D block-cyclic) HContainer, an atom pair not owned by this
68 // rank is absent from find_pair() and returns nullptr here; skip it
69 if (!ap_real)
70 {
71 continue;
72 }
73 for (int iR = 0;iR < ap->get_R_size();++iR)
74 {
75 // R index may be different between the two HContainers, find by R value instead of R-index
77 TR_from* ptr = ap->get_HR_values(iR).get_pointer();
78 TR_to* ptr_real = ap_real->get_HR_values(dR.x, dR.y, dR.z).get_pointer();
79 for (int i = 0; i < ap->get_size(); ++i)
80 {
81 ptr_real[i] = (get_imag ? std::imag(ptr[i]) : std::real(ptr[i]));
82 }
83 }
84 }
85 }
86
87 template<typename T>
90 const char& type = 'R')
91 {
92 assert(DMR.get_dmr_vec().size() == DMR_real.get_dmr_vec().size());
93 const bool get_imag = (type == 'I' || type == 'i');
94 for (size_t is = 0; is < DMR.get_dmr_vec().size(); ++is)
95 {
96 hamilt::HContainer<T>* dr = DMR.get_dmr_vec()[is]; //get_dmr_ptr() has bug when is=0
97 hamilt::HContainer<Real<T>>* dr_real = DMR_real.get_dmr_vec()[is];
98 assert(dr != nullptr);
99 assert(dr_real != nullptr);
100 copy_hcontainer_real_imag_part(*dr, *dr_real, get_imag);
101 }
102 }
103
106 template<typename T>
109 const int& is,
110 const char& type = 'R')
111 {
112 assert(static_cast<size_t>(is) < DMR.get_dmr_vec().size());
113 assert(DMR_real.get_dmr_vec().size() == 1);
114 const bool get_imag = (type == 'I' || type == 'i');
115 auto dr = DMR.get_dmr_vec()[is]; //get_dmr_ptr() has bug when is=0
116 auto dr_real = DMR_real.get_dmr_vec()[0];
117 assert(dr != nullptr);
118 assert(dr_real != nullptr);
119 copy_hcontainer_real_imag_part(*dr, *dr_real, get_imag);
120 }
121
123 hamilt::HContainer<std::complex<double>>& HR,
124 const char& type)
125 {
126 bool get_imag = (type == 'I' || type == 'i');
127 for (int iap = 0; iap < HR.size_atom_pairs(); ++iap)
128 {
129 hamilt::AtomPair<std::complex<double>>* ap = &HR.get_atom_pair(iap);
130 const int ia = ap->get_atom_i();
131 const int ja = ap->get_atom_j();
132 hamilt::AtomPair<double>* ap_real = HR_real.find_pair(ia, ja);
133 assert(ap_real != nullptr);
134 for (int iR = 0;iR < ap->get_R_size();++iR)
135 {
136 // R index may be different between the two HContainers, find by R value instead of R-index
138 std::complex<double>* ptr = ap->get_HR_values(iR).get_pointer();
139 double* ptr_real = ap_real->get_HR_values(dR.x, dR.y, dR.z).get_pointer();
140 for (int i = 0; i < ap->get_size(); ++i)
141 {
142 get_imag ? ptr[i].imag(ptr_real[i]) : ptr[i].real(ptr_real[i]);
143 }
144 }
145 }
146 }
147
148 template <typename T, typename TR>
150 const UnitCell& ucell,
151 const Grid_Driver& gd,
152 const std::vector<double>& orb_cutoff)
153 {
154 const Parallel_Orbitals& pmat = *hR.get_paraV();
155 for (int iat1 = 0; iat1 < ucell.nat; iat1++)
156 {
157 ModuleBase::Vector3<double> tau1 = ucell.get_tau(iat1);
158 int T1, I1;
159 ucell.iat2iait(iat1, &I1, &T1);
160 AdjacentAtomInfo adjs;
161 gd.Find_atom(ucell, tau1, T1, I1, &adjs);
162 for (int ad = 0; ad < adjs.adj_num + 1; ++ad)
163 {
164 const int T2 = adjs.ntype[ad];
165 const int I2 = adjs.natom[ad];
166 int iat2 = ucell.itia2iat(T2, I2);
167 if (pmat.is_invalid_atom_pair(iat1, iat2)) { continue; }
168 const ModuleBase::Vector3<int>& R_index = adjs.box[ad];
169 if (ucell.cal_dtau(iat1, iat2, R_index).norm() * ucell.lat0 >= orb_cutoff[T1] + orb_cutoff[T2]) { continue; }
170 hamilt::AtomPair<TR> tmp(iat1, iat2, R_index.x, R_index.y, R_index.z, &pmat);
171 hR.insert_pair(tmp);
172 }
173 }
174 hR.allocate(nullptr, true);
175 // hR.set_paraV(&pmat);
176 if (std::is_same<T, double>::value) { hR.fix_gamma(); }
177 }
178 template <typename T, typename TR>
180 const Parallel_Orbitals& pmat,
181 const UnitCell& ucell,
182 const Grid_Driver& gd,
183 const std::vector<double>& orb_cutoff)
184 {
185 hamilt::HContainer<TR> hR_tmp(&pmat);
186 initialize_HR<T, TR>(hR_tmp, ucell, gd, orb_cutoff);
187 dm.init_dmr(hR_tmp);
188 }
189
191 template<typename TR1, typename TR2>
193 {
194 TR1 sum = 0;
195 // Match by atom/R values: containers may store pairs and images in different orders.
196 for (int iap = 0; iap < h1.size_atom_pairs(); ++iap)
197 {
198 const hamilt::AtomPair<TR1>& ap1 = h1.get_atom_pair(iap);
199 const int iat1 = ap1.get_atom_i();
200 const int iat2 = ap1.get_atom_j();
201 const hamilt::AtomPair<TR2>* ap2 = h2.find_pair(iat1, iat2);
202 assert(ap2);
203 for (int iR = 0; iR < ap1.get_R_size(); ++iR)
204 {
205 const ModuleBase::Vector3<int>& R = ap1.get_R_index(iR);
206 const hamilt::BaseMatrix<TR1>& mat1 = ap1.get_HR_values(R.x, R.y, R.z);
207 const hamilt::BaseMatrix<TR2>& mat2 = ap2->get_HR_values(R.x, R.y, R.z);
208 const int size = mat1.get_col_size() * mat1.get_row_size();
209 const TR1* values1 = mat1.get_pointer();
210 const TR2* values2 = mat2.get_pointer();
211 TR1 block_sum = 0;
212 for (int index = 0; index < size; ++index)
213 {
214 block_sum += values1[index] * values2[index];
215 }
216 sum += block_sum;
217 }
218 }
219 // Parallel_Reduce::reduce_all(sum); // not needed, since it will be reduced outside
220 return sum;
221 }
222
223
224 // cal_dmr converts column-major DMK into row-major DMR without changing AO indices.
225 // It already uses the ground-state DMR convention, including exp(+ik.R) for multi-k.
226 // A physical transpose must therefore be applied to DMK, never by swapping atom pairs.
227 template<typename TK>
229 {
230 // 1. transpose dm(k)
231 for (std::vector<TK>& dk : dm.get_dmk_vec())
232 {
233#ifdef __MPI
234 // dm(k) is 2D-block-cyclic distributed, so the transpose needs the PBLAS routine
235 // `mattrans` (pdtran_/pztranc_) rather than a plain serial swap.
236 LR_Util::mattrans(dk.data(), pv.para_2d().nrglb(), pv.para_2d());
237#else
238 // In a serial build the entire square AO matrix is local, in column-major order.
239 const int n = pv.para_2d().nrglb();
240 std::vector<TK> transposed(dk.size());
241 for (int j = 0; j < n; ++j)
242 {
243 for (int i = 0; i < n; ++i)
244 {
245 transposed[j * n + i] = LR_Util::get_conj(dk[i * n + j]);
246 }
247 }
248 dk.swap(transposed);
249#endif
250 }
251
252 // 2. FT
253 dm.cal_dmr(-1);
254 }
255 template<typename TK>
256 void transpose_DMR(module_dm::DensityMatrix<TK, std::complex<double>>& dm, const Parallel_Orbitals& pv)
257 {
258 throw std::runtime_error("transpose_DMR is not implemented for complex DMR, due to the lack of minus-sign FT.");
259 // 1. dm(k) dagger
260 for (auto& dk : dm.get_dmk_vec())
261 {
262#ifdef __MPI
263 LR_Util::mattrans(dk.data(), pv.para_2d().nrglb(), pv.para_2d());
264#else
265 throw std::runtime_error("transpose_DMR requires MPI (PBLAS mattrans) for the 2D-block-cyclic dm(k) transpose.");
266#endif
267 }
268
269 // 2. FT with the minus sign in the exponent (TO DO)
270 dm.cal_dmr(-1);
271 }
272
273 template<typename TK, typename TR>
274 module_dm::DensityMatrix<TK, TR> build_dm_from_dmk(const std::vector<ct::Tensor>& dmk,
275 const Parallel_Orbitals& pmat,
276 const int& nk,
277 const std::vector<ModuleBase::Vector3<double>>& kvec_d,
278 const UnitCell& ucell,
279 const Grid_Driver& gd,
280 const std::vector<double>& orb_cutoff,
281 const bool symmetrize = false,
282 const bool cal_dmr = true,
283 const bool transpose = false)
284 {
285 module_dm::DensityMatrix<TK, TR> dm(&pmat, 1, kvec_d, nk);
286 initialize_DMR(dm, pmat, ucell, gd, orb_cutoff);
287
288 if (symmetrize)
289 for (int ik = 0; ik < nk; ++ik)
290#ifdef __MPI
291 LR_Util::matsym(dmk[ik].data<TK>(), pmat.para_2d().nrglb(), pmat.para_2d());
292#else
293 LR_Util::matsym(dmk[ik].data<TK>(), pmat.para_2d().nrglb());
294#endif
295
296 for (int ik = 0; ik < nk; ++ik)
297 dm.set_dmk_ptr(ik, dmk[ik].data<TK>());
298
299 if (cal_dmr)
300 {
301 dm.cal_dmr(-1);
302 }
303 return dm;
304 }
305
311 template <typename TK, typename TR>
312 module_dm::DensityMatrix<TK, TR> build_dm_from_dmk_spin(const std::vector<std::vector<ct::Tensor>>& dmk,
313 const Parallel_Orbitals& pmat,
314 const int& nk,
315 const std::vector<ModuleBase::Vector3<double>>& kvec_d,
316 const UnitCell& ucell,
317 const Grid_Driver& gd,
318 const std::vector<double>& orb_cutoff,
319 const bool symmetrize = false,
320 const bool cal_dmr = true)
321 {
322 const int nspin_dm = static_cast<int>(dmk.size());
323 module_dm::DensityMatrix<TK, TR> dm(&pmat, nspin_dm, kvec_d, nk);
324 initialize_DMR(dm, pmat, ucell, gd, orb_cutoff);
325 for (int is = 0; is < nspin_dm; ++is)
326 {
327 const std::size_t kpoint_count = nk;
328 assert(dmk[is].size() >= kpoint_count);
329 if (symmetrize)
330 {
331 for (int ik = 0; ik < nk; ++ik)
332 {
333#ifdef __MPI
334 LR_Util::matsym(dmk[is][ik].data<TK>(), pmat.para_2d().nrglb(), pmat.para_2d());
335#else
336 LR_Util::matsym(dmk[is][ik].data<TK>(), pmat.para_2d().nrglb());
337#endif
338 }
339 }
340 for (int ik = 0; ik < nk; ++ik)
341 {
342 dm.set_dmk_ptr(is * nk + ik, dmk[is][ik].data<TK>());
343 }
344 }
345 if (cal_dmr)
346 {
347 dm.cal_dmr(-1);
348 }
349 return dm;
350 }
351
352 // Thin adapters to the common sparse writer. Structural R keys are synchronized
353 // independently of thresholded values; each DMR spin channel gets its own file.
354 template<typename TR>
355 void save_HR(const hamilt::HContainer<TR>& hR, const std::string& filename,
356 const Parallel_Orbitals& pv, const std::string& out_dir,
357 double sparse_thr, std::ostream& running_log);
358
359 template<typename TK, typename TR>
360 void save_DMR(const module_dm::DensityMatrix<TK, TR>& dm, const std::string& filename,
361 const Parallel_Orbitals& pv, const std::string& out_dir,
362 double sparse_thr, std::ostream& running_log);
363
364#ifdef __EXX
365 // convert DensityMatrix to maps of RI::Tensors
366 // return 0.5*D[0]
367 template <typename TK, typename TR>
368 auto get_exx_Ds_spin1(const module_dm::DensityMatrix<TK, TR>& dm,
369 const UnitCell& ucell, const K_Vectors& kv, const Parallel_Orbitals& pmat)
370 -> std::map<int, std::map<std::pair<int, std::array<int, 3>>, RI::Tensor<TK>>>
371 {
372 const int& nk = dm.get_DMK_nks(); // nks/nspin
373 std::vector<const std::vector<TK>*> DMk_trans_pointer(nk);
374 for (int ik = 0; ik < nk; ++ik)
375 {
376 DMk_trans_pointer[ik] = &dm.get_dmk_vec()[ik];
377 }
379 ucell, kv, DMk_trans_pointer, pmat.para_2d(), /*nspin=*/1)[0];
380 }
381 // return SPIN_multiple*D[0] as implemented in split_m2D_ktoR
382 // SPIN_multiple = map({ {1,0.5}, {2,1}, {4,1} }).at(nspin)
383 template <typename TK, typename TR>
384 auto get_exx_Ds_gs(const module_dm::DensityMatrix<TK, TR>& dm,
385 const UnitCell& ucell, const K_Vectors& kv, const Parallel_Orbitals& pmat)
386 -> std::vector<std::map<int, std::map<std::pair<int, std::array<int, 3>>, RI::Tensor<TK>>>>
387 {
388 const int& nspin = dm.get_dmr_vec().size();
389 const int nks = dm.get_DMK_nks();
390 std::vector<const std::vector<TK>*> DMk_trans_pointer(nks);
391 for (int iks = 0;iks < dm.get_DMK_nks();++iks)
392 DMk_trans_pointer[iks] = &dm.get_dmk_vec()[iks];
394 ucell, kv, DMk_trans_pointer, pmat.para_2d(), nspin);
395 }
396#endif
397}
398
399#endif // ABACUS_SOURCE_LCAO_MODULE_LR_UTILS_LR_UTIL_HCONTAINER_H
Struct of array for packing the Adjacent atom information.
Definition sltk_grid_driver.h:21
int adj_num
number of adjacent atoms
Definition sltk_grid_driver.h:30
std::vector< ModuleBase::Vector3< int > > box
box indices of adjacent atoms
Definition sltk_grid_driver.h:34
std::vector< int > ntype
types of adjacent atoms
Definition sltk_grid_driver.h:31
std::vector< int > natom
indices of adjacent atoms
Definition sltk_grid_driver.h:32
Grid_Driver class for neighbor search interface.
Definition sltk_grid_driver.h:63
void Find_atom(const UnitCell &ucell, const int ntype, const int nnumber, AdjacentAtomInfo *adjs=nullptr) const
Find adjacent atoms for a given atom.
Definition sltk_grid_driver.cpp:24
Class for k-points management.
Definition klist.h:20
3 elements vector
Definition vector3.h:21
T x
Definition vector3.h:23
T norm(void) const
Get the norm of a Vector3.
Definition vector3.h:213
T y
Definition vector3.h:24
T z
Definition vector3.h:25
int nrglb() const
Definition parallel_blkcyc.cpp:75
Definition parallel_orbitals.h:16
bool is_invalid_atom_pair(int iat1, int iat2) const
Definition parallel_orbitals.cpp:131
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
const ModuleBase::Vector3< double > & get_tau(const int &iat) const
Get tau for atom iat.
Definition unitcell.h:104
double & lat0
Definition unitcell.h:135
ModuleBase::IntArray itia2iat
(it, ia)==>iat, the index in nat (add 2009-3-2 by mohan)
Definition unitcell.h:160
int nat
total number of atoms of all species in unitcell
Definition unitcell.h:155
const ModuleBase::Vector3< double > cal_dtau(const int &iat1, const int &iat2, const ModuleBase::Vector3< int > &R) const
Calculate vector between two atoms with R cell.
Definition unitcell.h:110
bool iat2iait(const Tiat iat, Tiait *ia, Tiait *it) const
Indexing tools for ia and it.
Definition unitcell.h:79
Definition atom_pair.h:45
BaseMatrix< T > & get_HR_values(int rx_in, int ry_in, int rz_in)
get target BaseMatrix of target cell for const AtomPair, it will return a const BaseMatrix<T> object,...
Definition atom_pair.cpp:451
int get_size() const
get size = col_size * row_size
Definition atom_pair.h:167
ModuleBase::Vector3< int > get_R_index(const int &index) const
Definition atom_pair.cpp:908
size_t get_R_size() const
Definition atom_pair.h:391
int get_atom_j() const
Definition atom_pair.cpp:370
int get_atom_i() const
get atom_i and atom_j for this AtomPair
Definition atom_pair.cpp:363
Definition base_matrix.h:20
T * get_pointer() const
get pointer of value from a submatrix
Definition base_matrix.h:86
int get_col_size() const
get col_size for this matrix
Definition base_matrix.h:102
int get_row_size() const
get row_size for this matrix
Definition base_matrix.h:106
Definition hcontainer.h:147
void fix_gamma()
restrict R indexes of all atom-pair to 0, 0, 0 add BaseMatrix<T> with non-zero R index to this->atom_...
Definition hcontainer.cpp:715
void insert_pair(const AtomPair< T > &atom_ij)
a AtomPair object can be inserted into HContainer, two steps: 1, find AtomPair with atom index atom_i...
Definition hcontainer.cpp:880
size_t size_atom_pairs() const
calculate number of AtomPairs for current R index
Definition hcontainer.cpp:832
void allocate(T *data_array=nullptr, bool if_zero=false)
allocate memory for all <IJR> matrix if data_array is not nullptr, use memory after data_array for ea...
Definition hcontainer.cpp:324
AtomPair< T > & get_atom_pair(int i, int j) const
return a reference of AtomPair with index of atom I and J in atom_pairs
Definition hcontainer.cpp:528
const Parallel_Orbitals * get_paraV() const
get parallel orbital pointer to check parallel information
Definition hcontainer.h:210
AtomPair< T > * find_pair(int i, int j) const
find AtomPair with atom index atom_i and atom_j This interface can be used to find AtomPair,...
Definition hcontainer.cpp:378
DensityMatrix Class <TK,TR> = <double,double> for Gamma-only calculation <TK,TR> = <std::complex<doub...
Definition density_matrix.h:172
const std::vector< hamilt::HContainer< TR > * > & get_dmr_vec() const
get pointer vector of DMR
Definition density_matrix.h:301
void init_dmr(const Grid_Driver *GridD_in, const UnitCell *ucell)
initialize density matrix DMR from UnitCell
Definition dmr_init.cpp:19
void cal_dmr(const int ik_in)
calculate density matrix DMR from dm(k) using blas::axpy
const std::vector< std::vector< TK > > & get_dmk_vec() const
get pointer vector of DMK
Definition density_matrix.h:329
void set_dmk_ptr(const int ik, TK *DMK_in)
set dmk using a input TK* pointer please make sure the size of TK* is correct
Definition dm_setter.cpp:20
#define T
Definition exp.cpp:237
#define __MPI
Definition exciton_plotter.cpp:368
void save_DMR(const module_dm::DensityMatrix< TK, TR > &dm, const std::string &filename, const Parallel_Orbitals &pv, const std::string &out_dir, const double sparse_thr, std::ostream &running_log)
Definition lr_sparse.cpp:26
module_dm::DensityMatrix< TK, TR > build_dm_from_dmk_spin(const std::vector< std::vector< ct::Tensor > > &dmk, const Parallel_Orbitals &pmat, const int &nk, const std::vector< ModuleBase::Vector3< double > > &kvec_d, const UnitCell &ucell, const Grid_Driver &gd, const std::vector< double > &orb_cutoff, const bool symmetrize=false, const bool cal_dmr=true)
Spin-resolved counterpart of build_dm_from_dmk: one dmk list per spin channel.
Definition lr_util_hcontainer.h:312
void save_HR(const hamilt::HContainer< TR > &hR, const std::string &filename, const Parallel_Orbitals &pv, const std::string &out_dir, const double sparse_thr, std::ostream &running_log)
Definition lr_sparse.cpp:9
void matsym(const T *in, const int n, T *out)
Definition lr_util.hpp:79
void set_HR_real_imag_part(const hamilt::HContainer< double > &HR_real, hamilt::HContainer< std::complex< double > > &HR, const char &type)
Definition lr_util_hcontainer.h:122
void get_DMR_real_imag_part(const module_dm::DensityMatrix< T, T > &DMR, module_dm::DensityMatrix< T, Real< T > > &DMR_real, const char &type='R')
Definition lr_util_hcontainer.h:88
double get_conj(const double &x)
Definition lr_util.hpp:70
typename GetTypeReal< T >::type Real
Definition lr_util_hcontainer.h:17
void print_HR(const hamilt::HContainer< TR > &HR, const std::string &label, const double &threshold=1e-10)
Definition lr_util_hcontainer.h:19
void copy_hcontainer_real_imag_part(const hamilt::HContainer< TR_from > &HR, hamilt::HContainer< TR_to > &HR_real, const bool get_imag)
Definition lr_util_hcontainer.h:58
void initialize_DMR(module_dm::DensityMatrix< T, TR > &dm, const Parallel_Orbitals &pmat, const UnitCell &ucell, const Grid_Driver &gd, const std::vector< double > &orb_cutoff)
Definition lr_util_hcontainer.h:179
void transpose_DMR(module_dm::DensityMatrix< TK, double > &dm, const Parallel_Orbitals &pv)
Definition lr_util_hcontainer.h:228
void print_DMR(const module_dm::DensityMatrix< TK, TR > &DMR, const std::string &label, const double &threshold=1e-10)
Definition lr_util_hcontainer.h:47
void initialize_HR(hamilt::HContainer< TR > &hR, const UnitCell &ucell, const Grid_Driver &gd, const std::vector< double > &orb_cutoff)
Definition lr_util_hcontainer.h:149
void mattrans(const T *in, const int n, const Parallel_Blkcyclic &pmat, T *out)
TR1 dot_R_matrix(const hamilt::HContainer< TR1 > &h1, const hamilt::HContainer< TR2 > &h2)
$\sum_{uvR} H1_{uv}(R) H2_{uv}(R)$
Definition lr_util_hcontainer.h:192
module_dm::DensityMatrix< TK, TR > build_dm_from_dmk(const std::vector< ct::Tensor > &dmk, const Parallel_Orbitals &pmat, const int &nk, const std::vector< ModuleBase::Vector3< double > > &kvec_d, const UnitCell &ucell, const Grid_Driver &gd, const std::vector< double > &orb_cutoff, const bool symmetrize=false, const bool cal_dmr=true, const bool transpose=false)
Definition lr_util_hcontainer.h:274
std::vector< std::map< TA, std::map< TAC, RI::Tensor< Tdata > > > > split_m2D_ktoR(const UnitCell &ucell, const K_Vectors &kv, const std::vector< const Tmatrix * > &mks_2D, const Parallel_Blkcyclic &pv, const int nspin, const bool spgsym=false)
const int nks
Definition dos_test_data.h:12
#define threshold
Definition sph_bessel_rec_test.cpp:4
T type
Definition macros.h:8