VMPS++
Loading...
Searching...
No Matches
SUN.h
Go to the documentation of this file.
1#ifndef SUN_H_
2#define SUN_H_
3
4#include <array>
5#include <cstddef>
6
7#include <unsupported/Eigen/CXX11/Tensor>
8
9#include "ClebschGordan.h" //Library by Arne Alex for SU(N)-CGCs. See: https://homepages.physik.uni-muenchen.de/~vondelft/Papers/ClebschGordan/
10 //Seems to be not precise enough, maybe there is a better one.
11
12#include <gsl/gsl_sf_coupling.h> //temporary necessary because class SiteOperator ist implemented properly for Symmetries with CGCs..
13
14#include <boost/rational.hpp>
15
16namespace Sym{
17
28template<std::size_t N, typename Scalar>
29class SUN // : SymmetryBase<SUN<N,Scalar> >
30{
31 typedef Eigen::Index Index;
32 template<Index Rank> using TensorType = Eigen::Tensor<Scalar,Rank,Eigen::ColMajor,Index>;
33public:
34 typedef std::array<int,1> qType;
35
36 SUN() {};
37
38 static constexpr bool HAS_CGC = true;
39 static constexpr bool SPECIAL = false;
40 static constexpr std::size_t Nq=1;
41
42 static qType qvacuum() { return {1}; }
43
44 static std::string name() { std::stringstream ss; ss << "SU(" << N << ")"; return ss.str(); }
45
46 inline static qType flip( const qType& q ) { return q; }
47 inline static int degeneracy( const qType& q ) { return q[0]; }
48
49 static TensorType<3> reduce(qType ql, qType qr, qType Q);
50
51 static std::vector<qType> reduceSilent(qType ql, qType qr);
52
53 static std::vector<qType> reduceSilent(std::vector<qType> ql, qType qr);
54
55 static Eigen::Tensor<Scalar,2> calcCupTensor( qType q );
56
57 static Eigen::Tensor<Scalar,2> calcCapTensor( qType q );
58
59 static Scalar coeff_adjoint(const qType& q1, const qType& q2, const qType& q3);
60
61 static Scalar coeff_Apair(const qType& q1, const qType& q2, const qType& q3,
62 const qType& q4, const qType& q5, const qType& q6);
63
64 static Scalar coeff_buildR(const qType& q1, const qType& q2, const qType& q3,
65 const qType& q4, const qType& q5, const qType& q6,
66 const qType& q7, const qType& q8, const qType& q9);
67
68 template<std::size_t M>
69 static bool compare ( std::array<qType,M> q1, std::array<qType,M> q2 );
70
71 template<std::size_t M>
72 static bool validate( std::array<qType,M> qs );
73};
74
75template<std::size_t N, typename Scalar> bool operator== (const typename SUN<N,Scalar>::qType& lhs, const typename SUN<N,Scalar>::qType& rhs) {return lhs == rhs;}
76
77template<std::size_t N, typename Scalar>
78Eigen::Tensor<Scalar,3,Eigen::ColMajor,Eigen::Index> SUN<N,Scalar>::
79reduce(typename SUN<N,Scalar>::qType ql, typename SUN<N,Scalar>::qType qr, typename SUN<N,Scalar>::qType Q)
80{
81 clebsch::weight wl(N,ql[0]-1), wr(N,qr[0]-1), W(N,Q[0]-1);
82 clebsch::coefficients cgc(W,wl,wr);
83 Index dimwl = wl.dimension(),
84 dimwr = wr.dimension(),
85 dimW = W.dimension();
86 TensorType<3> T(dimwl,dimW,dimwr); T.setZero();
87 for (Index i = 0; i < dimW; ++i) {
88 for (Index j = 0; j < dimwl; ++j) {
89 for (Index k = 0; k < dimwr; ++k)
90 {
91 double x = Scalar(cgc(j, k, 0, i)); //The 0 is the innermultiplicity. For N>2 you need to adjust here something.
92 if (std::abs(x) > clebsch::EPS)
93 {
94 T(j,i,k) = x;
95 }
96 }
97 }
98 }
99 return T;
100}
101
102template<std::size_t N, typename Scalar>
103std::vector<typename SUN<N,Scalar>::qType> SUN<N,Scalar>::
104reduceSilent( qType ql, qType qr )
105{
106 std::vector<typename SUN<N,Scalar>::qType> vout;
107 int qmin = std::abs(ql[0]-qr[0]) +1;
108 int qmax = std::abs(ql[0]+qr[0]) -1;
109 for ( int i=qmin; i<=qmax; i+=2 ) { vout.push_back({i}); }
110 return vout;
111}
112
113template<std::size_t N, typename Scalar>
114std::vector<typename SUN<N,Scalar>::qType> SUN<N,Scalar>::
115reduceSilent( std::vector<qType> ql, qType qr )
116{
117 std::vector<typename SUN<N,Scalar>::qType> vout;
118 for (std::size_t q=0; q<ql.size(); q++)
119 {
120 int qmin = std::abs(ql[q][0]-qr[0]) +1;
121 int qmax = std::abs(ql[q][0]+qr[0]) -1;
122 for ( int i=qmin; i<=qmax; i+=2 ) { vout.push_back({i}); }
123 }
124 return vout;
125}
126
127template<std::size_t N, typename Scalar>
128template<std::size_t M>
130compare ( std::array<qType,M> q1, std::array<qType,M> q2 )
131{
132 for (std::size_t m=0; m<M; m++)
133 {
134 if (q1[m][0] < q2[m][0]) { return false; }
135 else if (q1[m][0] > q2[m][0]) {return true; }
136 }
137 return false;
138}
139
140template<std::size_t N, typename Scalar>
141template<std::size_t M>
143validate ( std::array<SUN<N,Scalar>::qType,M> qs )
144{
145 if constexpr( M > 1 )
146 {
147 std::vector<SUN<N,Scalar>::qType> decomp = SUN::reduceSilent(qs[0],qs[1]);
148 for (std::size_t i=2; i<M; i++)
149 {
150 decomp = SUN::reduceSilent(decomp,qs[i]);
151 }
152 for (std::size_t i=0; i<decomp.size(); i++)
153 {
154 if ( decomp[i] == SUN::qvacuum() ) { return true; }
155 }
156 return false;
157 }
158 else { return true; }
159}
160
161template<std::size_t N, typename Scalar>
162Eigen::Tensor<Scalar,2,Eigen::ColMajor,Eigen::Index> SUN<N,Scalar>::
164{
165 Index dim = q[0];
166 TensorType<2> Tout(dim,dim); Tout.setZero();
167 for (Index mInt=0; mInt<dim; mInt++)
168 {
169 Tout(mInt,dim-1-mInt) = std::pow(Scalar(-1),mInt)*pow(Scalar(-1),Scalar(dim-1));
170 }
171 return Tout;
172
173}
174
175template<std::size_t N, typename Scalar>
176Eigen::Tensor<Scalar,2,Eigen::ColMajor,Eigen::Index> SUN<N,Scalar>::
178{
179 Index dim = q[0];
180 std::cout << dim << std::endl;
181 TensorType<2> Tout(dim,dim); Tout.setZero();
182 for (Index mInt=0; mInt<dim; mInt++)
183 {
184 Tout(mInt,dim-1-mInt) = std::pow(Scalar(-1),mInt);
185 }
186 return Tout;
187}
188
189template<std::size_t N, typename Scalar>
191coeff_adjoint(const qType& q1, const qType& q2, const qType& q3)
192{
193 Scalar out = std::pow(static_cast<Scalar>(q1[0]),Scalar(0.5)) * std::pow(static_cast<Scalar>(q2[0]),Scalar(-0.5))*
194 std::pow(Scalar(-1.),Scalar(0.5)*static_cast<Scalar>(q3[0]+q1[0]-q2[0]-1));
195 return out;
196}
197
198template<std::size_t N, typename Scalar>
200coeff_Apair(const qType& q1, const qType& q2, const qType& q3,
201 const qType& q4, const qType& q5, const qType& q6)
202{
203 Scalar out = gsl_sf_coupling_6j(q1[0]-1,q2[0]-1,q3[0]-1,
204 q4[0]-1,q5[0]-1,q6[0]-1)*
205 std::pow(static_cast<Scalar>(q3[0]*q6[0]),Scalar(0.5))*
206 std::pow(Scalar(-1.),Scalar(0.5)*static_cast<Scalar>(q1[0]+q5[0]+q6[0]-3));
207 return out;
208}
209
210template<std::size_t N, typename Scalar>
212coeff_buildR(const qType& q1, const qType& q2, const qType& q3,
213 const qType& q4, const qType& q5, const qType& q6,
214 const qType& q7, const qType& q8, const qType& q9)
215{
216 Scalar out = gsl_sf_coupling_9j(q1[0]-1,q2[0]-1,q3[0]-1,
217 q4[0]-1,q5[0]-1,q6[0]-1,
218 q7[0]-1,q8[0]-1,q9[0]-1)*
219 std::pow(static_cast<Scalar>(q7[0]*q8[0]*q3[0]*q6[0]),Scalar(0.5));
220 return out;
221}
222
223} //end namespace Sym
224
225std::ostream& operator<< (std::ostream& os, const typename Sym::SUN<2,double>::qType &q)
226{
227 boost::rational<int> s = boost::rational<int>(q[0]-1,2);
228 if (s.numerator() == 0) {os << " " << 0 << " ";}
229 else if (s.denominator() == 1) {os << " " << s.numerator() << " ";}
230 else {os << s;}
231 return os;
232}
233
234#endif
size_t dim(const PivotMatrix0< Symmetry, Scalar, MpoScalar > &H)
double cgc(int j1x2, int j2x2, int Jx2, int m1x2, int m2x2, int Mx2)
std::ostream & operator<<(std::ostream &os, const typename Sym::SUN< 2, double >::qType &q)
Definition: SUN.h:225
Definition: SUN.h:30
static std::vector< qType > reduceSilent(qType ql, qType qr)
Definition: SUN.h:104
static qType qvacuum()
Definition: SUN.h:42
Eigen::Index Index
Definition: SUN.h:31
static constexpr bool SPECIAL
Definition: SUN.h:39
static Eigen::Tensor< Scalar, 2 > calcCapTensor(qType q)
Definition: SUN.h:163
static TensorType< 3 > reduce(qType ql, qType qr, qType Q)
Definition: SUN.h:79
static std::string name()
Definition: SUN.h:44
std::array< int, 1 > qType
Definition: SUN.h:34
static Eigen::Tensor< Scalar, 2 > calcCupTensor(qType q)
Definition: SUN.h:177
Eigen::Tensor< Scalar, Rank, Eigen::ColMajor, Index > TensorType
Definition: SUN.h:32
SUN()
Definition: SUN.h:36
static Scalar coeff_buildR(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: SUN.h:212
static constexpr bool HAS_CGC
Definition: SUN.h:38
static bool compare(std::array< qType, M > q1, std::array< qType, M > q2)
Definition: SUN.h:130
static constexpr std::size_t Nq
Definition: SUN.h:40
static bool validate(std::array< qType, M > qs)
static Scalar coeff_adjoint(const qType &q1, const qType &q2, const qType &q3)
Definition: SUN.h:191
static int degeneracy(const qType &q)
Definition: SUN.h:47
static qType flip(const qType &q)
Definition: SUN.h:46
static Scalar coeff_Apair(const qType &q1, const qType &q2, const qType &q3, const qType &q4, const qType &q5, const qType &q6)
Definition: SUN.h:200
bool operator==(const typename SUN< N, Scalar >::qType &lhs, const typename SUN< N, Scalar >::qType &rhs)
Definition: SUN.h:75