Xped
Loading...
Searching...
No Matches
ZN.hpp
Go to the documentation of this file.
1#ifndef XPED_ZN_H_
2#define XPED_ZN_H_
3
4#include <array>
5
7#include "Xped/Util/Mpi.hpp"
9
12
13namespace Xped::Sym {
14
15template <typename Kind, std::size_t N, typename Scalar_>
16struct ZN;
17
18template <typename Kind_, std::size_t N_, typename Scalar__>
19struct SymTraits<ZN<Kind_, N_, Scalar__>>
20{
21 constexpr static int Nq = 1;
23 typedef Scalar__ Scalar;
24};
25
33template <typename Kind, std::size_t N, typename Scalar_ = double>
34struct ZN : public SymBase<ZN<Kind, N, Scalar_>>
35{
36 typedef Scalar_ Scalar;
37 static constexpr size_t Nq = 1;
38
40
41 static constexpr std::array<bool, Nq> HAS_MULTIPLICITIES = {false};
42 static constexpr std::array<bool, Nq> NON_ABELIAN = {false};
43 static constexpr std::array<bool, Nq> ABELIAN = {true};
44 static constexpr std::array<bool, Nq> IS_TRIVIAL = {false};
45 static constexpr std::array<bool, Nq> IS_MODULAR = {true};
46 static constexpr std::array<bool, Nq> IS_FERMIONIC = {(Kind::name == KIND::FN)};
47 static constexpr std::array<bool, Nq> IS_BOSONIC = {(Kind::name == KIND::N)};
48 static constexpr std::array<bool, Nq> IS_SPIN = {(Kind::name == KIND::M)};
49 static constexpr std::array<int, Nq> MOD_N = {N};
50
51 static constexpr bool ANY_HAS_MULTIPLICITIES = HAS_MULTIPLICITIES[0];
52 static constexpr bool ANY_NON_ABELIAN = NON_ABELIAN[0];
53 static constexpr bool ANY_ABELIAN = ABELIAN[0];
54 static constexpr bool ANY_IS_TRIVIAL = IS_TRIVIAL[0];
55 static constexpr bool ANY_IS_MODULAR = IS_MODULAR[0];
56 static constexpr bool ANY_IS_FERMIONIC = IS_FERMIONIC[0];
57 static constexpr bool ANY_IS_BOSONIC = IS_BOSONIC[0];
58 static constexpr bool ANY_IS_SPIN = IS_SPIN[0];
59
60 static constexpr bool ALL_HAS_MULTIPLICITIES = HAS_MULTIPLICITIES[0];
61 static constexpr bool ALL_NON_ABELIAN = NON_ABELIAN[0];
62 static constexpr bool ALL_ABELIAN = ABELIAN[0];
63 static constexpr bool ALL_IS_TRIVIAL = IS_TRIVIAL[0];
64 static constexpr bool ALL_IS_MODULAR = IS_MODULAR[0];
65 static constexpr bool ALL_IS_FERMIONIC = IS_FERMIONIC[0];
66 static constexpr bool ALL_IS_BOSONIC = IS_BOSONIC[0];
67 static constexpr bool ALL_IS_SPIN = IS_SPIN[0];
68
69 static constexpr bool IS_CHARGE_SU2() { return false; }
70 static constexpr bool IS_SPIN_SU2() { return false; }
71
72 static constexpr bool IS_SPIN_U1()
73 {
74 if constexpr(IS_SPIN[0]) { return true; }
75 return false;
76 }
77
78 static constexpr bool NO_SPIN_SYM()
79 {
80 if constexpr(not IS_SPIN[0]) { return true; }
81 return false;
82 }
83 static constexpr bool NO_CHARGE_SYM()
84 {
85 if constexpr(not IS_FERMIONIC[0] and not IS_BOSONIC[0]) { return true; }
86 return false;
87 }
88
89 ZN(){};
90
91 inline static constexpr qType qvacuum() { return {0}; }
92 inline static constexpr auto lowest_qs()
93 {
94 if constexpr(N == 2) {
95 return std::array<qType, 1>{{qarray<1>(std::array<int, 1>{{1}})}};
96 } else {
97 return std::array<qType, 2>{{qarray<1>(std::array<int, 1>{{1}}), qarray<1>(std::array<int, 1>{{N - 1}})}};
98 }
99 }
100
101 inline static std::string name()
102 {
103 std::string prefix = IS_FERMIONIC[0] ? "ʑ" : "";
104 if(N == 2) { return prefix + "Zā‚‚"; }
105 if(N == 3) { return prefix + "Zā‚ƒ"; }
106 if(N == 4) { return prefix + "Zā‚„"; }
107 if(N == 5) { return prefix + "Zā‚…"; }
108 if(N == 36) { return prefix + "Zā‚ƒā‚†"; }
109 if(N == 64) { return prefix + "Zā‚†ā‚„"; }
110 return prefix + "Z(" + std::to_string(N) + ")";
111 }
112
113 inline static constexpr std::array<KIND, Nq> kind() { return {Kind::name}; }
114
115 inline static qType conj(const qType& q) { return {util::constFct::posmod<N>(-q[0])}; }
116 inline static int degeneracy(const qType&) { return 1; }
117
118 inline static qType random_q()
119 {
121 qType out = {qval};
122 return out;
123 }
124
128 static std::vector<qType> basis_combine(const qType& ql, const qType& qr);
129
130 static std::size_t multiplicity(const qType& q1, const qType& q2, const qType& q3) { return triangle(q1, q2, q3) ? 1ul : 0ul; }
131
133
139 inline static Scalar coeff_dot(const qType&) { return Scalar(1.); }
140
141 inline static Scalar coeff_twist(const qType& q)
142 {
143 if constexpr(not IS_FERMIONIC[0]) { return 1.; }
144 return (q[0] % 2 != 0) ? -1. : 1.;
145 }
146
147 static Scalar coeff_FS(const qType&) { return Scalar(1.); }
148
149 template <typename PlainLib>
150 static typename PlainLib::template TType<Scalar_, 2> one_j_tensor(const qType&, const mpi::XpedWorld& world = mpi::getUniverse())
151 {
152 typedef typename PlainLib::Indextype IndexType;
153 auto T = PlainLib::template construct<Scalar>(std::array<IndexType, 2>{1, 1}, world);
154 std::array<IndexType, 2> index = {0, 0};
155 PlainLib::template setVal<Scalar, 2>(T, index, Scalar(1.));
156 return T;
157 }
158
159 static Scalar coeff_rightOrtho(const qType&, const qType&) { return Scalar(1.); }
160
161 inline static Scalar coeff_3j(const qType& q1, const qType& q2, const qType& q3, int, int, int)
162 {
163 return triangle(q1, q2, conj(q3)) ? Scalar(1.) : Scalar(0.);
164 }
165
166 template <typename PlainLib>
167 static typename PlainLib::template TType<Scalar_, 3>
168 CGC(const qType& q1, const qType& q2, const qType& q3, const std::size_t, const mpi::XpedWorld& world = mpi::getUniverse());
169
170 static Scalar coeff_turn(const qType& ql, const qType& qr, const qType& qf) { return triangle(ql, qr, qf) ? Scalar(1.) : Scalar(0.); }
171
172 inline static Scalar coeff_6j(const qType& q1, const qType& q2, const qType& q3, const qType& q4, const qType& q5, const qType& q6);
173
174 inline static Scalar coeff_recouple(const qType& q1, const qType& q2, const qType& q3, const qType& Q, const qType& Q12, const qType& Q23)
175 {
176 return coeff_6j(q1, q2, Q12, q3, Q, Q23);
177 }
178
179 inline static Scalar
180 coeff_9j(const qType&, const qType&, const qType&, const qType&, const qType&, const qType&, const qType&, const qType&, const qType&)
181 {
182 return Scalar(1);
183 }
184
185 static Scalar coeff_swap(const qType& ql, const qType& qr, const qType& qf)
186 {
187 Scalar sign = +1.;
188 if constexpr(IS_FERMIONIC[0]) {
189 bool parity = (ql[0] % 2 != 0) and (qr[0] % 2 != 0);
190 sign = parity ? -1. : 1.;
191 SPDLOG_INFO("ql,pl={},{}; qr,pr={},{}; sign={}\n", ql[0], ql[0] % 2 != 0, qr[0], qr[0] % 2 != 0, sign);
192 }
193 return triangle(ql, qr, qf) ? sign * Scalar(1.) : Scalar(0.);
194 };
196
197 static bool triangle(const qType& q1, const qType& q2, const qType& q3);
198};
199
200template <typename Kind, std::size_t N, typename Scalar_>
201std::vector<typename ZN<Kind, N, Scalar_>::qType> ZN<Kind, N, Scalar_>::basis_combine(const qType& ql, const qType& qr)
202{
203 std::vector<qType> vout;
204 vout.push_back({util::constFct::posmod<N>({ql[0] + qr[0]})});
205 return vout;
206}
207
208template <typename Kind, std::size_t N, typename Scalar_>
209template <typename PlainLib>
210typename PlainLib::template TType<Scalar_, 3>
211ZN<Kind, N, Scalar_>::CGC(const qType& q1, const qType& q2, const qType& q3, const std::size_t, const mpi::XpedWorld& world)
212{
213 typedef typename PlainLib::Indextype IndexType;
214 auto T = PlainLib::template construct<Scalar>(std::array<IndexType, 3>{1, 1, 1}, world);
215 if(triangle(q1, q2, q3)) {
216 std::array<IndexType, 3> index = {0, 0, 0};
217 PlainLib::template setVal<Scalar, 3>(T, index, Scalar(1.));
218 } else {
219 std::array<IndexType, 3> index = {0, 0, 0};
220 PlainLib::template setVal<Scalar, 3>(T, index, Scalar(0.));
221 }
222 return T;
223}
224
225template <typename Kind, std::size_t N, typename Scalar_>
226Scalar_ ZN<Kind, N, Scalar_>::coeff_6j(const qType& q1, const qType& q2, const qType& q3, const qType& q4, const qType& q5, const qType& q6)
227{
228 if(triangle(q1, q2, q3) and triangle(q1, q6, q5) and triangle(q2, q4, q6) and triangle(q3, q4, q5)) { return Scalar(1.); }
229 return Scalar(0.);
230}
231
232template <typename Kind, std::size_t N, typename Scalar_>
233bool ZN<Kind, N, Scalar_>::triangle(const qType& q1, const qType& q2, const qType& q3)
234{
235 // check the triangle rule for ZN quantum numbers
236 if(util::constFct::posmod<N>(q1[0] + q2[0]) == q3[0]) { return true; }
237 return false;
238}
239
240} // namespace Xped::Sym
241
242#endif
Definition: CombSym.hpp:8
@ FN
Definition: functions.hpp:38
@ M
Definition: functions.hpp:39
@ T
Definition: functions.hpp:35
@ N
Definition: functions.hpp:37
XpedWorld & getUniverse()
Definition: Mpi.hpp:49
int threadSafeRandUniform< int, int >(int min, int max, bool FIXED_SEED)
Definition: Random.hpp:32
CTF::Tensor< Scalar > TType
Definition: PlainInterface_Cyclops_impl.cpp:13
Definition: SymBase.hpp:14
qarray< Nq > qType
Definition: ZN.hpp:22
Definition: SymBase.hpp:10
Definition: ZN.hpp:35
static constexpr bool IS_SPIN_U1()
Definition: ZN.hpp:72
static constexpr bool ALL_NON_ABELIAN
Definition: ZN.hpp:61
static constexpr auto lowest_qs()
Definition: ZN.hpp:92
static constexpr bool ALL_HAS_MULTIPLICITIES
Definition: ZN.hpp:60
static Scalar coeff_swap(const qType &ql, const qType &qr, const qType &qf)
Definition: ZN.hpp:185
static std::string name()
Definition: ZN.hpp:101
Scalar_ Scalar
Definition: ZN.hpp:36
static constexpr size_t Nq
Definition: ZN.hpp:37
static Scalar coeff_FS(const qType &)
Definition: ZN.hpp:147
static constexpr bool ANY_NON_ABELIAN
Definition: ZN.hpp:52
qarray< Nq > qType
Definition: ZN.hpp:39
static std::size_t multiplicity(const qType &q1, const qType &q2, const qType &q3)
Definition: ZN.hpp:130
static constexpr std::array< bool, Nq > ABELIAN
Definition: ZN.hpp:43
static constexpr std::array< KIND, Nq > kind()
Definition: ZN.hpp:113
static bool triangle(const qType &q1, const qType &q2, const qType &q3)
Definition: ZN.hpp:233
ZN()
Definition: ZN.hpp:89
static constexpr bool ANY_IS_BOSONIC
Definition: ZN.hpp:57
static qType conj(const qType &q)
Definition: ZN.hpp:115
static constexpr bool ANY_HAS_MULTIPLICITIES
Definition: ZN.hpp:51
static PlainLib::template TType< Scalar_, 2 > one_j_tensor(const qType &, const mpi::XpedWorld &world=mpi::getUniverse())
Definition: ZN.hpp:150
static constexpr std::array< bool, Nq > IS_SPIN
Definition: ZN.hpp:48
static qType random_q()
Definition: ZN.hpp:118
static constexpr bool ALL_IS_MODULAR
Definition: ZN.hpp:64
static Scalar coeff_rightOrtho(const qType &, const qType &)
Definition: ZN.hpp:159
static constexpr bool NO_CHARGE_SYM()
Definition: ZN.hpp:83
static Scalar coeff_dot(const qType &)
Definition: ZN.hpp:139
static constexpr std::array< bool, Nq > IS_TRIVIAL
Definition: ZN.hpp:44
static constexpr std::array< int, Nq > MOD_N
Definition: ZN.hpp:49
static constexpr std::array< bool, Nq > IS_FERMIONIC
Definition: ZN.hpp:46
static constexpr qType qvacuum()
Definition: ZN.hpp:91
static Scalar coeff_turn(const qType &ql, const qType &qr, const qType &qf)
Definition: ZN.hpp:170
static constexpr bool ANY_IS_FERMIONIC
Definition: ZN.hpp:56
static constexpr bool ANY_IS_TRIVIAL
Definition: ZN.hpp:54
static Scalar coeff_recouple(const qType &q1, const qType &q2, const qType &q3, const qType &Q, const qType &Q12, const qType &Q23)
Definition: ZN.hpp:174
static constexpr std::array< bool, Nq > IS_MODULAR
Definition: ZN.hpp:45
static constexpr bool ALL_IS_SPIN
Definition: ZN.hpp:67
static constexpr bool ANY_ABELIAN
Definition: ZN.hpp:53
static Scalar coeff_3j(const qType &q1, const qType &q2, const qType &q3, int, int, int)
Definition: ZN.hpp:161
static constexpr bool ALL_ABELIAN
Definition: ZN.hpp:62
static Scalar coeff_twist(const qType &q)
Definition: ZN.hpp:141
static constexpr bool ALL_IS_FERMIONIC
Definition: ZN.hpp:65
static constexpr bool NO_SPIN_SYM()
Definition: ZN.hpp:78
static Scalar coeff_9j(const qType &, const qType &, const qType &, const qType &, const qType &, const qType &, const qType &, const qType &, const qType &)
Definition: ZN.hpp:180
static constexpr bool ANY_IS_MODULAR
Definition: ZN.hpp:55
static constexpr bool IS_SPIN_SU2()
Definition: ZN.hpp:70
static std::vector< qType > basis_combine(const qType &ql, const qType &qr)
Definition: ZN.hpp:201
static PlainLib::template TType< Scalar_, 3 > CGC(const qType &q1, const qType &q2, const qType &q3, const std::size_t, const mpi::XpedWorld &world=mpi::getUniverse())
Definition: ZN.hpp:211
static constexpr bool ALL_IS_BOSONIC
Definition: ZN.hpp:66
static int degeneracy(const qType &)
Definition: ZN.hpp:116
static constexpr bool IS_CHARGE_SU2()
Definition: ZN.hpp:69
static constexpr std::array< bool, Nq > NON_ABELIAN
Definition: ZN.hpp:42
static constexpr std::array< bool, Nq > IS_BOSONIC
Definition: ZN.hpp:47
static constexpr bool ANY_IS_SPIN
Definition: ZN.hpp:58
static Scalar coeff_6j(const qType &q1, const qType &q2, const qType &q3, const qType &q4, const qType &q5, const qType &q6)
Definition: ZN.hpp:226
static constexpr std::array< bool, Nq > HAS_MULTIPLICITIES
Definition: ZN.hpp:41
static constexpr bool ALL_IS_TRIVIAL
Definition: ZN.hpp:63
Definition: Mpi.hpp:34
Definition: qarray.hpp:30