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