Xped
Loading...
Searching...
No Matches
SU2.hpp
Go to the documentation of this file.
1#ifndef SU2_H_
2#define SU2_H_
3
5#include <array>
6#include <cstddef>
7#include <vector>
9
14#include "Xped/Util/Mpi.hpp"
15
16namespace Xped::Sym {
17
18template <typename Kind, typename Scalar_>
19struct SU2;
20
21template <typename Kind_, typename Scalar__>
22struct SymTraits<SU2<Kind_, Scalar__>>
23{
24 constexpr static int Nq = 1;
26 typedef Scalar__ Scalar;
27};
28
41template <typename Kind, typename Scalar_ = double>
42struct SU2 : public SymBase<SU2<Kind, Scalar_>>
43{
44 typedef Scalar_ Scalar;
46
47 static constexpr std::size_t Nq = 1;
48
49 static constexpr std::array<bool, Nq> HAS_MULTIPLICITIES = {false};
50 static constexpr std::array<bool, Nq> NON_ABELIAN = {true};
51 static constexpr std::array<bool, Nq> ABELIAN = {false};
52 static constexpr std::array<bool, Nq> IS_TRIVIAL = {false};
53 static constexpr std::array<bool, Nq> IS_MODULAR = {false};
54 static constexpr std::array<bool, Nq> IS_FERMIONIC = {(Kind::name == KIND::FT)};
55 static constexpr std::array<bool, Nq> IS_BOSONIC = {(Kind::name == KIND::T)};
56 static constexpr std::array<bool, Nq> IS_SPIN = {(Kind::name == KIND::S)};
57 static constexpr std::array<int, Nq> MOD_N = {1};
58
59 static constexpr bool ANY_HAS_MULTIPLICITIES = HAS_MULTIPLICITIES[0];
60 static constexpr bool ANY_NON_ABELIAN = NON_ABELIAN[0];
61 static constexpr bool ANY_ABELIAN = ABELIAN[0];
62 static constexpr bool ANY_IS_TRIVIAL = IS_TRIVIAL[0];
63 static constexpr bool ANY_IS_MODULAR = IS_MODULAR[0];
64 static constexpr bool ANY_IS_FERMIONIC = IS_FERMIONIC[0];
65 static constexpr bool ANY_IS_BOSONIC = IS_BOSONIC[0];
66 static constexpr bool ANY_IS_SPIN = IS_SPIN[0];
67
68 static constexpr bool ALL_HAS_MULTIPLICITIES = HAS_MULTIPLICITIES[0];
69 static constexpr bool ALL_NON_ABELIAN = NON_ABELIAN[0];
70 static constexpr bool ALL_ABELIAN = ABELIAN[0];
71 static constexpr bool ALL_IS_TRIVIAL = IS_TRIVIAL[0];
72 static constexpr bool ALL_IS_MODULAR = IS_MODULAR[0];
73 static constexpr bool ALL_IS_FERMIONIC = IS_FERMIONIC[0];
74 static constexpr bool ALL_IS_BOSONIC = IS_BOSONIC[0];
75 static constexpr bool ALL_IS_SPIN = IS_SPIN[0];
76
77 static constexpr bool IS_CHARGE_SU2()
78 {
79 if constexpr(IS_FERMIONIC[0] or IS_BOSONIC[0]) { return true; }
80 return false;
81 }
82 static constexpr bool IS_SPIN_SU2()
83 {
84 if constexpr(IS_SPIN[0]) { return true; }
85 return false;
86 }
87
88 static constexpr bool IS_SPIN_U1() { return false; }
89
90 static constexpr bool NO_SPIN_SYM()
91 {
92 if constexpr(not IS_SPIN[0]) { return true; }
93 return false;
94 }
95 static constexpr bool NO_CHARGE_SYM()
96 {
97 if constexpr(not IS_FERMIONIC[0] and not IS_BOSONIC[0]) { return true; }
98 return false;
99 }
100
102
103 SU2(){};
104
105 inline static std::string name() { return IS_FERMIONIC[0] ? "Æ‘SUâ‚‚" : "SUâ‚‚"; }
106 inline static constexpr std::array<KIND, Nq> kind() { return {Kind::name}; }
107
108 inline static constexpr qType qvacuum() { return {1}; }
109 inline static constexpr std::array<qType, 1> lowest_qs() { return std::array<qType, 1>{{qarray<1>(std::array<int, 1>{{2}})}}; }
110
111 inline static qType conj(const qType& q) { return q; }
112 inline static int degeneracy(const qType& q) { return q[0]; }
113
114 static qType random_q();
115
119 static std::vector<qType> basis_combine(const qType& ql, const qType& qr);
120
121 static std::size_t multiplicity(const qType& q1, const qType& q2, const qType& q3) { return triangle(q1, q2, q3) ? 1ul : 0ul; }
123
126 static Scalar coeff_dot(const qType& q1);
127
128 inline static Scalar coeff_twist(const qType& q)
129 {
130 if constexpr(not IS_FERMIONIC[0]) { return 1.; }
131 return ((q[0] - 1) % 2 != 0) ? -1. : 1.;
132 }
133
134 static Scalar coeff_FS(const qType& q1);
135
136 template <typename PlainLib>
137 static typename PlainLib::template TType<Scalar_, 2> one_j_tensor(const qType& q1, const mpi::XpedWorld& world = mpi::getUniverse());
138
139 static Scalar coeff_rightOrtho(const qType& q1, const qType& q2) { return static_cast<Scalar>(q1[0]) / static_cast<Scalar>(q2[0]); }
140
141 static Scalar coeff_3j(const qType& q1, const qType& q2, const qType& q3, int q1_z, int q2_z, int q3_z);
142
143 static Scalar coeff_turn(const qType& ql, const qType& qr, const qType& qf)
144 {
145 return triangle(ql, qr, qf) ? coeff_swap(ql, qr, qf) * std::sqrt(static_cast<Scalar>(qf[0]) / static_cast<Scalar>(ql[0])) : Scalar(0.);
146 }
147
148 template <typename PlainLib>
149 static typename PlainLib::template TType<Scalar_, 3>
150 CGC(const qType& q1, const qType& q2, const qType& q3, const std::size_t, const mpi::XpedWorld& world = mpi::getUniverse());
151
152 static Scalar coeff_6j(const qType& q1, const qType& q2, const qType& q3, const qType& q4, const qType& q5, const qType& q6);
153
154 static Scalar coeff_9j(const qType& q1,
155 const qType& q2,
156 const qType& q3,
157 const qType& q4,
158 const qType& q5,
159 const qType& q6,
160 const qType& q7,
161 const qType& q8,
162 const qType& q9);
163
164 static Scalar coeff_recouple(const qType& q1, const qType& q2, const qType& q3, const qType& Q, const qType& Q12, const qType& Q23)
165 {
166 return std::sqrt(Q12[0] * Q23[0]) * phase<Scalar>((q1[0] + q2[0] + q3[0] + Q[0]) / 2.) * coeff_6j(q1, q2, Q12, q3, Q, Q23);
167 }
168
169 static Scalar coeff_swap(const qType& ql, const qType& qr, const qType& qf)
170 {
171 Scalar sign = +1.;
172 if constexpr(IS_FERMIONIC[0]) {
173 bool parity = ((ql[0] - 1) % 2 != 0) and ((qr[0] - 1) % 2 != 0);
174 sign = parity ? -1. : 1.;
175 }
176 return triangle(ql, qr, qf) ? sign * phase<Scalar>((ql[0] + qr[0] - qf[0] - 1) / 2) : Scalar(0.);
177 }
179
180 static bool triangle(const qType& q1, const qType& q2, const qType& q3);
181};
182
183} // namespace Xped::Sym
184
185#ifndef XPED_COMPILED_LIB
186# include "Symmetry/SU2.cpp"
187#endif
188
189#endif
Definition: CombSym.hpp:8
@ T
Definition: functions.hpp:35
@ FT
Definition: functions.hpp:36
@ S
Definition: functions.hpp:33
XpedWorld & getUniverse()
Definition: Mpi.hpp:49
CTF::Tensor< Scalar > TType
Definition: PlainInterface_Cyclops_impl.cpp:13
Definition: SU2.hpp:43
static constexpr bool ALL_IS_BOSONIC
Definition: SU2.hpp:74
static constexpr std::size_t Nq
Definition: SU2.hpp:47
static Scalar coeff_rightOrtho(const qType &q1, const qType &q2)
Definition: SU2.hpp:139
static Scalar coeff_3j(const qType &q1, const qType &q2, const qType &q3, int q1_z, int q2_z, int q3_z)
Definition: SU2.cpp:64
static Scalar coeff_9j(const qType &q1, const qType &q2, const qType &q3, const qType &q4, const qType &q5, const qType &q6, const qType &q7, const qType &q8, const qType &q9)
Definition: SU2.cpp:99
static constexpr std::array< bool, Nq > IS_BOSONIC
Definition: SU2.hpp:55
static constexpr bool ALL_IS_SPIN
Definition: SU2.hpp:75
static constexpr bool ANY_IS_SPIN
Definition: SU2.hpp:66
static constexpr std::array< bool, Nq > HAS_MULTIPLICITIES
Definition: SU2.hpp:49
static constexpr bool ANY_NON_ABELIAN
Definition: SU2.hpp:60
static qType random_q()
Definition: SU2.cpp:10
static constexpr std::array< bool, Nq > IS_TRIVIAL
Definition: SU2.hpp:52
static constexpr bool ALL_ABELIAN
Definition: SU2.hpp:70
static constexpr bool ALL_IS_TRIVIAL
Definition: SU2.hpp:71
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: SU2.cpp:73
static constexpr bool ALL_HAS_MULTIPLICITIES
Definition: SU2.hpp:68
static Scalar coeff_recouple(const qType &q1, const qType &q2, const qType &q3, const qType &Q, const qType &Q12, const qType &Q23)
Definition: SU2.hpp:164
static constexpr bool ANY_IS_BOSONIC
Definition: SU2.hpp:65
static PlainLib::template TType< Scalar_, 2 > one_j_tensor(const qType &q1, const mpi::XpedWorld &world=mpi::getUniverse())
Definition: SU2.cpp:43
static constexpr bool ANY_IS_TRIVIAL
Definition: SU2.hpp:62
static constexpr bool IS_SPIN_U1()
Definition: SU2.hpp:88
qarray< Nq > qType
Definition: SU2.hpp:101
static Scalar coeff_swap(const qType &ql, const qType &qr, const qType &qf)
Definition: SU2.hpp:169
static constexpr bool ALL_NON_ABELIAN
Definition: SU2.hpp:69
static constexpr std::array< bool, Nq > NON_ABELIAN
Definition: SU2.hpp:50
static constexpr bool ANY_IS_FERMIONIC
Definition: SU2.hpp:64
static Scalar coeff_turn(const qType &ql, const qType &qr, const qType &qf)
Definition: SU2.hpp:143
static constexpr std::array< bool, Nq > IS_MODULAR
Definition: SU2.hpp:53
static constexpr std::array< bool, Nq > ABELIAN
Definition: SU2.hpp:51
SU2()
Definition: SU2.hpp:103
static constexpr std::array< qType, 1 > lowest_qs()
Definition: SU2.hpp:109
static Scalar coeff_6j(const qType &q1, const qType &q2, const qType &q3, const qType &q4, const qType &q5, const qType &q6)
Definition: SU2.cpp:92
static Scalar coeff_FS(const qType &q1)
Definition: SU2.cpp:36
static int degeneracy(const qType &q)
Definition: SU2.hpp:112
static constexpr bool IS_SPIN_SU2()
Definition: SU2.hpp:82
static std::string name()
Definition: SU2.hpp:105
static constexpr bool ANY_IS_MODULAR
Definition: SU2.hpp:63
static constexpr std::array< bool, Nq > IS_FERMIONIC
Definition: SU2.hpp:54
Scalar_ Scalar
Definition: SU2.hpp:44
static constexpr bool ALL_IS_FERMIONIC
Definition: SU2.hpp:73
static constexpr bool ANY_ABELIAN
Definition: SU2.hpp:61
static std::size_t multiplicity(const qType &q1, const qType &q2, const qType &q3)
Definition: SU2.hpp:121
static constexpr std::array< KIND, Nq > kind()
Definition: SU2.hpp:106
static constexpr bool NO_SPIN_SYM()
Definition: SU2.hpp:90
static constexpr std::array< int, Nq > MOD_N
Definition: SU2.hpp:57
static Scalar coeff_twist(const qType &q)
Definition: SU2.hpp:128
static constexpr std::array< bool, Nq > IS_SPIN
Definition: SU2.hpp:56
static constexpr bool ALL_IS_MODULAR
Definition: SU2.hpp:72
static constexpr qType qvacuum()
Definition: SU2.hpp:108
static constexpr bool NO_CHARGE_SYM()
Definition: SU2.hpp:95
static constexpr bool ANY_HAS_MULTIPLICITIES
Definition: SU2.hpp:59
static std::vector< qType > basis_combine(const qType &ql, const qType &qr)
Definition: SU2.cpp:18
static qType conj(const qType &q)
Definition: SU2.hpp:111
static constexpr bool IS_CHARGE_SU2()
Definition: SU2.hpp:77
SymBase< SU2< Kind, Scalar > > Base
Definition: SU2.hpp:45
static Scalar coeff_dot(const qType &q1)
Definition: SU2.cpp:30
static bool triangle(const qType &q1, const qType &q2, const qType &q3)
Definition: SU2.cpp:114
Definition: SymBase.hpp:14
qarray< Nq > qType
Definition: SU2.hpp:25
Scalar__ Scalar
Definition: SU2.hpp:26
Definition: SymBase.hpp:10
Definition: Mpi.hpp:34
Definition: qarray.hpp:30