5#include <RI/global/Global_Func-2.h>
6#include <RI/physics/symmetry/Symmetry_Rotation.h>
15 for (
int i = 0; i < block.
nr; ++i) {
16 for (
int j = 0; j < block.
nc; ++j) {
17 t(i, j) = block(i, j);
30 for (
size_t is = 0; is < this->
rotmat_Slm_.size(); ++is)
33 for (
size_t il = 0; il < this->
rotmat_Slm_[is].size(); ++il) {
44 inline double conj_elem(
const double v) {
return v; }
45 inline std::complex<float>
conj_elem(
const std::complex<float>& v) {
return std::conj(v); }
46 inline std::complex<double>
conj_elem(
const std::complex<double>& v) {
return std::conj(v); }
48 template<
typename Tdata>
52 for (
int i = 0;i < t.shape[0];++i)
54 for (
int j = 0;j < t.shape[1];++j) {
60 template<
typename Tdata>
64 for (
int a = 0;a < t.shape[0];++a)
67 for (
int i = 0;i < t.shape[1];++i)
69 for (
int j = 0;j < t.shape[2];++j) {
78 template<
typename Tdata>
80 const Symmetry& symm,
const Atom* atoms,
const std::vector<int>& iat2it,
const char mode,
81 const std::map<
int, std::map<std::pair<int, TC>,
RI::Tensor<Tdata>>>& HR_irreducible)
const
87 for (
auto& tmp1 : HR_irreducible)
89 const int& irap1 = tmp1.first;
90 for (
auto& tmp2 : tmp1.second)
92 const int& irap2 = tmp2.first.first;
93 const Tap& irap = { irap1, irap2 };
94 const TC& irR = tmp2.first.second;
95 const TapR& irapR = { irap, irR };
96 if (this->
irs_.sector_stars_.find(irapR) != this->irs_.sector_stars_.end())
98 for (
const std::pair<
const int, std::pair<std::pair<int, int>, std::array<int, 3>>>& isym_apR : this->
irs_.sector_stars_.at(irapR))
100 const int& isym = isym_apR.first;
101 const TapR& apR = isym_apR.second;
102 const int& ap1 = apR.first.first;
103 const int& ap2 = apR.first.second;
104 const TC& R = apR.second;
105 HR_full[ap1][{ap2, R}] =
rotate_atompair_serial(tmp2.second, isym, atoms[iat2it[irap1]], atoms[iat2it[irap2]], mode);
108 else { std::cout <<
"Warning: not found: irreducible atom pair =(" << irap1 <<
"," << irap2 <<
"), irR=(" << irR[0] <<
"," << irR[1] <<
"," << irR[2] <<
")\n";}
172 template<
typename Tdata>
174 const Symmetry& symm,
const Atom* atoms,
const std::vector<int>& iat2it,
const char mode,
175 const std::array<std::map<
int, std::map<std::pair<int, TC>,
RI::Tensor<Tdata>>>, 4>& HR_irreducible_soc)
const
179 assert(mode ==
'H' || mode ==
'D');
180 std::array<std::map<int, std::map<std::pair<int, TC>,
RI::Tensor<Tdata>>>, 4> HR_full;
184 std::map<int, std::set<std::pair<int, TC>>> ir_keys;
185 for (
int is = 0;is < 4;++is)
187 for (
auto& tmp1 : HR_irreducible_soc[is])
189 for (
auto& tmp2 : tmp1.second) { ir_keys[tmp1.first].insert(tmp2.first); }
193 for (std::pair<
const int, std::set<std::pair<
int, std::array<int, 3>>>>& k1 : ir_keys)
195 const int& irap1 = k1.first;
196 for (
const std::pair<
int, std::array<int, 3>>& a2R : k1.second)
198 const int& irap2 = a2R.first;
199 const TC& irR = a2R.second;
200 const TapR irapR = { { irap1, irap2 }, irR };
201 if (this->
irs_.sector_stars_.find(irapR) == this->irs_.sector_stars_.end())
203 std::cout <<
"Warning: not found: irreducible atom pair =(" << irap1 <<
"," << irap2 <<
"), irR=(" << irR[0] <<
"," << irR[1] <<
"," << irR[2] <<
")\n";
206 const Atom& a1 = atoms[iat2it[irap1]];
207 const Atom& a2 = atoms[iat2it[irap2]];
209 std::array<RI::Tensor<Tdata>, 4> Hir;
210 for (
int is = 0;is < 4;++is)
212 const auto& chan = HR_irreducible_soc[is];
213 auto it1 = chan.find(irap1);
214 if (it1 != chan.end())
216 auto it2 = it1->second.find({ irap2, irR });
217 if (it2 != it1->second.end()) { Hir[is] = it2->second; }
219 if (Hir[is].empty()) { Hir[is] =
RI::Tensor<Tdata>({
static_cast<size_t>(a1.
nw),
static_cast<size_t>(a2.
nw) }); }
221 for (
const std::pair<
const int, std::pair<std::pair<int, int>, std::array<int, 3>>>& isym_apR : this->
irs_.sector_stars_.at(irapR))
223 const int& isym = isym_apR.first;
224 const TapR& apR = isym_apR.second;
225 const int& ap1 = apR.first.first;
226 const int& ap2 = apR.first.second;
227 const TC& R = apR.second;
229 std::array<RI::Tensor<Tdata>, 4> G;
233 std::array<RI::Tensor<Tdata>, 4> Hout_ch;
234 for (
int a = 0;a < 2;++a) {
235 for (
int b = 0;b < 2;++b)
238 for (
int c = 0;c < 2;++c) {
239 for (
int d = 0;d < 2;++d)
241 const std::complex<double> coeff = (mode ==
'H')
242 ? std::conj(U[c * 2 + a]) * U[d * 2 + b]
243 : U[c * 2 + a] * std::conj(U[d * 2 + b]);
244 Hout += RI::Global_Func::convert<Tdata>(coeff) * G[c * 2 + d];
247 Hout_ch[a * 2 + b] = Hout;
252 if (isym >= this->
nsym_)
258 static const int src[4] = { 3, 2, 1, 0 };
259 static const bool neg[4] = {
false,
true,
true,
false };
260 std::array<RI::Tensor<Tdata>, 4> Y = Hout_ch;
261 for (
int is = 0;is < 4;++is)
265 for (
size_t i = 0;i < t.shape[0];++i) {
266 for (
size_t j = 0;j < t.shape[1];++j)
269 t(i, j) = neg[is] ? -v : v;
275 for (
int is = 0;is < 4;++is) { HR_full[is][ap1][{ap2, R}] = Hout_ch[is]; }
283 template<
typename Tdata>
287 for (
int i = 0;i < block.shape[0];++i) {
288 for (
int j = 0;j < block.shape[1];++j) {
289 obj_tensor(starti + i, startj + j) = RI::Global_Func::convert<Tdata>(block(i, j));
294 template<
typename Tdata>
308 template<
typename Tdata>
310 const Atom& a1,
const Atom& a2,
const char mode,
const bool output)
const
313 assert(mode ==
'H' || mode ==
'D');
315 assert(A.shape[0] == a1.
nw);
316 assert(A.shape[1] == a2.
nw);
322 (mode ==
'H') ? RI::Sym::T1_HR_T2(TAT.ptr(), A.ptr(), T1, T2) : RI::Sym::T1_DR_T2(TAT.ptr(), A.ptr(), T1, T2);
332 template<
typename Tdata>
334 const int& nw1,
const int& nw2,
const int isym,
335 const Atom& a1,
const Atom& a2,
const char mode)
const
338 assert(mode ==
'H' || mode ==
'D');
340 assert(nw1 == a1.
nw);
341 assert(nw2 == a2.
nw);
346 (mode ==
'H') ? RI::Sym::T1_HR_T2(TAT, A, T1, T2) : RI::Sym::T1_DR_T2(TAT, A, T1, T2);
350 template<
typename Tdata>
372 template<
typename Tdata>
374 const int isym,
const Atom& a1,
const Atom& a2,
const int& type1,
bool output)
const
378 assert(C.shape.size() == 3);
379 const int& slice_size = C.shape[1] * C.shape[2];
381 for (
int iabf = 0;iabf < C.shape[0];++iabf) {
383 a1.
nw, a2.
nw, isym, a1, a2,
'H');
387 RI::Sym::T1_HR(Cout.ptr(), Cout.ptr(), Tabfs, slice_size);
391 template<
typename Tdata>
394 for (
auto& HR_ia1 : HR)
396 int iat1 = HR_ia1.first;
397 for (
auto& HR_ia12R : HR_ia1.second)
399 int iat2 = HR_ia12R.first.first;
400 TC R = HR_ia12R.first.second;
402 std::cout <<
"atom pair (" << iat1 <<
", " << iat2 <<
"), R=(" << R[0] <<
"," << R[1] <<
"," << R[2] <<
"), ";
Atom class for storing atom information.
Definition atom_spec.h:14
int nw
number of local orbitals (l,n,m) of this type
Definition atom_spec.h:36
std::string label
atomic symbol
Definition atom_spec.h:51
std::vector< int > iw2l
use iw to find L
Definition atom_spec.h:33
Definition complexmatrix.h:11
int nr
Definition complexmatrix.h:15
int nc
Definition complexmatrix.h:16
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
int rotmat_Slm_version_
Definition symm_rotation_k.h:172
Irred_Sector irs_
irreducible sector
Definition symm_rotation_k.h:190
int nsym_
Definition symm_rotation_k.h:152
std::vector< std::vector< ModuleBase::ComplexMatrix > > rotmat_Slm_
the rotation matrix under the basis of S_l^m. size: [nsym][lmax][nm*nm]
Definition symm_rotation_k.h:167
std::vector< SpinRotation::Su2 > spin_U_
Definition symm_rotation_k.h:187
std::vector< std::vector< RI::Tensor< std::complex< double > > > > rotmat_Slm_tensor_
Definition symm_rotation.h:97
const RI::Tensor< std::complex< double > > & get_rotmat_Slm_tensor(const int isym, const int l) const
Definition symm_rotation_r.hpp:25
bool reduce_Cs_
Definition symm_rotation.h:101
int rotmat_Slm_tensor_version_
Definition symm_rotation.h:98
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::vector< std::vector< int > > abfs_l_nchi_
number of abfs for each angular momentum
Definition symm_rotation.h:103
RI::Tensor< Tdata > rotate_atompair_serial(const RI::Tensor< Tdata > &A, const int isym, const Atom &a1, const Atom &a2, const char mode, bool output=false) const
Definition symm_rotation_r.hpp:309
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
RI::Tensor< Tdata > set_rotation_matrix(const Atom &a, const int &isym) const
Definition symm_rotation_r.hpp:295
RI::Tensor< Tdata > set_rotation_matrix_abf(const int &type, const int &isym) const
Definition symm_rotation_r.hpp:351
void print_HR(const std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > > &HR, const std::string name, const double &threshold=0.0)
Definition symm_rotation_r.hpp:392
RI::Tensor< Tdata > rotate_singleC_serial(const RI::Tensor< Tdata > &C, const int isym, const Atom &a1, const Atom &a2, const int &type1, bool output=false) const
rotate a 3-dim C tensor in RI technique
Definition symm_rotation_r.hpp:373
Symmetry analysis class.
Definition symmetry.h:24
Definition rpa_lri_coeff_v1.h:11
#define N
Definition exp.cpp:24
#define T
Definition exp.cpp:237
std::ofstream ofs_running
Definition global_variable.cpp:38
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
std::array< std::complex< double >, 4 > Su2
A 2x2 complex matrix stored row-major: {m00, m01, m10, m11}.
Definition symm_rot_spin.h:37
std::pair< int, int > Tap
Definition irred_sec.h:14
std::array< int, 3 > TC
Definition irred_sec.h:15
RI::Tensor< std::complex< double > > rotmat_Slm_to_tensor(const ModuleBase::ComplexMatrix &block)
Definition symm_rotation_r.hpp:12
std::pair< Tap, TC > TapR
Definition irred_sec.h:16
void set_block(const int starti, const int startj, const RI::Tensor< std::complex< double > > &block, RI::Tensor< Tdata > &obj_tensor)
Definition symm_rotation_r.hpp:284
void print_tensor(const RI::Tensor< Tdata > &t, const std::string &name, const double &threshold=0.0)
Definition symm_rotation_r.hpp:49
float conj_elem(const float v)
Definition symm_rotation_r.hpp:43
void print_tensor3(const RI::Tensor< Tdata > &t, const std::string &name, const double &threshold=0.0)
Definition symm_rotation_r.hpp:61
#define threshold
Definition sph_bessel_rec_test.cpp:4