5#include <RI/global/Global_Func-2.h>
6#include <RI/physics/symmetry/Symmetry_Rotation.h>
9 template<
typename Tdata>
13 for (
int i = 0;i < t.shape[0];++i)
15 for (
int j = 0;j < t.shape[1];++j) {
21 template<
typename Tdata>
25 for (
int a = 0;a < t.shape[0];++a)
28 for (
int i = 0;i < t.shape[1];++i)
30 for (
int j = 0;j < t.shape[2];++j) {
39 template<
typename Tdata>
42 const std::map<
int, std::map<std::pair<int, TC>, RI::Tensor<Tdata>>>& HR_irreducible)
const
46 std::map<int, std::map<std::pair<int, TC>, RI::Tensor<Tdata>>> HR_full;
48 for (
auto& tmp1 : HR_irreducible)
50 const int& irap1 = tmp1.first;
51 for (
auto& tmp2 : tmp1.second)
53 const int& irap2 = tmp2.first.first;
54 const Tap& irap = { irap1, irap2 };
55 const TC& irR = tmp2.first.second;
56 const TapR& irapR = { irap, irR };
61 const int& isym = isym_apR.first;
62 const TapR& apR = isym_apR.second;
63 const int& ap1 = apR.first.first;
64 const int& ap2 = apR.first.second;
65 const TC& R = apR.second;
69 else { std::cout <<
"Warning: not found: irreducible atom pair =(" << irap1 <<
"," << irap2 <<
"), irR=(" << irR[0] <<
"," << irR[1] <<
"," << irR[2] <<
")\n";}
115 template<
typename Tdata>
116 inline void set_block(
const int starti,
const int startj,
const RI::Tensor<std::complex<double>>& block,
117 RI::Tensor<Tdata>& obj_tensor)
119 for (
int i = 0;i < block.shape[0];++i) {
120 for (
int j = 0;j < block.shape[1];++j) {
121 obj_tensor(starti + i, startj + j) = RI::Global_Func::convert<Tdata>(block(i, j));
126 template<
typename Tdata>
129 RI::Tensor<Tdata>
T({
static_cast<size_t>(a.
nw),
static_cast<size_t>(a.
nw) });
140 template<
typename Tdata>
142 const Atom& a1,
const Atom& a2,
const char mode,
const bool output)
const
145 assert(mode ==
'H' || mode ==
'D');
147 assert(A.shape[0] == a1.
nw);
148 assert(A.shape[1] == a2.
nw);
150 const RI::Tensor<Tdata>& T1 = this->set_rotation_matrix<Tdata>(a1, isym);
151 const RI::Tensor<Tdata>& T2 = sametype ? T1 : this->set_rotation_matrix<Tdata>(a2, isym);
153 RI::Tensor<Tdata>TAT(A.shape);
154 (mode ==
'H') ? RI::Sym::T1_HR_T2(TAT.ptr(), A.ptr(), T1, T2) : RI::Sym::T1_DR_T2(TAT.ptr(), A.ptr(), T1, T2);
164 template<
typename Tdata>
166 const int& nw1,
const int& nw2,
const int isym,
167 const Atom& a1,
const Atom& a2,
const char mode)
const
170 assert(mode ==
'H' || mode ==
'D');
172 assert(nw1 == a1.
nw);
173 assert(nw2 == a2.
nw);
175 const RI::Tensor<Tdata>& T1 = this->set_rotation_matrix<Tdata>(a1, isym);
176 const RI::Tensor<Tdata>& T2 = sametype ? T1 : this->set_rotation_matrix<Tdata>(a2, isym);
178 (mode ==
'H') ? RI::Sym::T1_HR_T2(TAT, A, T1, T2) : RI::Sym::T1_DR_T2(TAT, A, T1, T2);
182 template<
typename Tdata>
188 RI::Tensor<Tdata>
T({
static_cast<size_t>(nabfs),
static_cast<size_t>(nabfs) });
204 template<
typename Tdata>
206 const int isym,
const Atom& a1,
const Atom& a2,
const int& type1,
bool output)
const
209 RI::Tensor<Tdata> Cout(C.shape);
210 assert(C.shape.size() == 3);
211 const int& slice_size = C.shape[1] * C.shape[2];
213 for (
int iabf = 0;iabf < C.shape[0];++iabf) {
215 a1.
nw, a2.
nw, isym, a1, a2,
'H');
218 const RI::Tensor<Tdata>& Tabfs = this->set_rotation_matrix_abf<Tdata>(type1, isym);
219 RI::Sym::T1_HR(Cout.ptr(), Cout.ptr(), Tabfs, slice_size);
223 template<
typename Tdata>
226 for (
auto& HR_ia1 : HR)
228 int iat1 = HR_ia1.first;
229 for (
auto& HR_ia12R : HR_ia1.second)
231 int iat2 = HR_ia12R.first.first;
232 TC R = HR_ia12R.first.second;
233 const RI::Tensor<Tdata>& HR_tensor = HR_ia12R.second;
234 std::cout <<
"atom pair (" << iat1 <<
", " << iat2 <<
"), R=(" << R[0] <<
"," << R[1] <<
"," << R[2] <<
"), ";
240 template<
typename Tdata>
242 const std::map<
int, std::map<std::pair<int, TC>, RI::Tensor<Tdata>>>& HR_full)
247 std::map<int, std::map<std::pair<int, TC>, RI::Tensor<Tdata>>> HR_irreducible;
250 const Tap& irap = irap_Rs.first;
251 for (
auto& irR : irap_Rs.second)
253 const std::pair<int, TC> a2_irR = { irap.second, irR };
254 HR_irreducible[irap.first][a2_irR] = (HR_full.at(irap.first).count(a2_irR) != 0) ?
255 HR_full.at(irap.first).at(a2_irR)
256 : RI::Tensor<Tdata>(HR_full.at(irap.first).begin()->second.shape);
260 std::map<int, std::map<std::pair<int, TC>, RI::Tensor<Tdata>>> HR_rotated =
restore_HR(symm, atoms, st, mode, HR_irreducible);
262 for (
auto& HR_ia1 : HR_rotated)
264 int iat1 = HR_ia1.first;
265 for (
auto& HR_ia12R : HR_ia1.second)
267 int iat2 = HR_ia12R.first.first;
268 TC R = HR_ia12R.first.second;
269 const RI::Tensor<Tdata>& HR_rot = HR_ia12R.second;
270 if (HR_full.at(iat1).count({ iat2, R }) == 0)
272 std::cout <<
"R_rot not found in atom pair (" << iat1 <<
", " << iat2 <<
"): R=(" << R[0] <<
"," << R[1] <<
"," << R[2] <<
"):\n";
275 const RI::Tensor<Tdata>& HR_ref = HR_full.at(iat1).at({ iat2, R });
276 assert(HR_rot.shape[0] == HR_ref.shape[0]);
277 assert(HR_rot.shape[1] == HR_ref.shape[1]);
279 std::cout <<
"atom pair (" << iat1 <<
", " << iat2 <<
"), R=(" << R[0] <<
"," << R[1] <<
"," << R[2] <<
"):\n";
280 print_tensor(HR_rot, std::string(
"R_rot").insert(0, 1, mode));
281 print_tensor(HR_ref, std::string(
"R_ref").insert(0, 1, mode));
286 template<
typename Tdata>
288 const std::map<
int, std::map<std::pair<int, TC>, RI::Tensor<Tdata>>>& Cs_full)
const
292 const TapR& apR = sector_pair.first;
293 const int& isym = sector_pair.second.first;
294 const TapR& irapR = sector_pair.second.second;
296 if (apR.first != irapR.first)
298 std::cout <<
"irapR=(" << irapR.first.first <<
"," << irapR.first.second <<
"), (" << irapR.second[0] <<
"," << irapR.second[1] <<
"," << irapR.second[2] <<
"):\n";
299 std::cout <<
"apR=(" << apR.first.first <<
"," << apR.first.second <<
"), (" << apR.second[0] <<
"," << apR.second[1] <<
"," << apR.second[2] <<
"):\n";
300 const RI::Tensor<Tdata>& Cs_ir = Cs_full.at(irapR.first.first).at({ irapR.first.second,irapR.second });
301 const RI::Tensor<Tdata>& Cs_ref = Cs_full.at(apR.first.first).at({ apR.first.second,apR.second });
303 atoms[st.
iat2it[irapR.first.first]], atoms[st.
iat2it[irapR.first.second]], irapR.first.first);
int nw
Definition atom_spec.h:23
std::string label
Definition atom_spec.h:35
std::vector< int > iw2l
Definition atom_spec.h:20
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
std::map< Tap, std::set< TC > > irreducible_sector_
whether in 2D plain or not for each symmetry operation
Definition irreducible_sector.h:123
std::map< TapR, std::map< int, TapR > > sector_stars_
Definition irreducible_sector.h:132
std::map< TapR, std::pair< int, TapR >, apR_less_func > full_map_to_irreducible_sector_
Definition irreducible_sector.h:128
bool reduce_Cs_
Definition symmetry_rotation.h:160
void test_Cs_rotation(const Symmetry &symm, const Atom *atoms, const Statistics &st, const std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > > &Cs_full) const
Definition symmetry_rotation_R.hpp:287
std::vector< std::vector< RI::Tensor< std::complex< double > > > > rotmat_Slm_
the rotation matrix under the basis of S_l^m. size: [nsym][lmax][nm*nm]
Definition symmetry_rotation.h:166
std::vector< std::vector< int > > abfs_l_nchi_
number of abfs for each angular momentum
Definition symmetry_rotation.h:163
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 symmetry_rotation_R.hpp:141
std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > > restore_HR(const Symmetry &symm, const Atom *atoms, const Statistics &st, const char mode, const std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > > &HR_irreduceble) const
Definition symmetry_rotation_R.hpp:40
void test_HR_rotation(const Symmetry &symm, const Atom *atoms, const Statistics &st, const char mode, const std::map< int, std::map< std::pair< int, TC >, RI::Tensor< Tdata > > > &HR_full)
Definition symmetry_rotation_R.hpp:241
RI::Tensor< Tdata > set_rotation_matrix(const Atom &a, const int &isym) const
Definition symmetry_rotation_R.hpp:127
RI::Tensor< Tdata > set_rotation_matrix_abf(const int &type, const int &isym) const
Definition symmetry_rotation_R.hpp:183
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 symmetry_rotation_R.hpp:224
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 symmetry_rotation_R.hpp:205
Irreducible_Sector irs_
irreducible sector
Definition symmetry_rotation.h:175
#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
Definition symm_other.cpp:4
std::pair< Tap, TC > TapR
Definition irreducible_sector.h:15
void set_block(const int starti, const int startj, const RI::Tensor< std::complex< double > > &block, RI::Tensor< Tdata > &obj_tensor)
Definition symmetry_rotation_R.hpp:116
std::array< int, 3 > TC
Definition irreducible_sector.h:14
void print_tensor(const RI::Tensor< Tdata > &t, const std::string &name, const double &threshold=0.0)
Definition symmetry_rotation_R.hpp:10
std::pair< int, int > Tap
Definition irreducible_sector.h:13
void print_tensor3(const RI::Tensor< Tdata > &t, const std::string &name, const double &threshold=0.0)
Definition symmetry_rotation_R.hpp:22
#define threshold
Definition sph_bessel_recursive_test.cpp:4
usefull data and index maps
Definition unitcell_data.h:47
int * iat2it
Definition unitcell_data.h:50