VMPS++
Loading...
Searching...
No Matches
SpinlessFermionBase.h
Go to the documentation of this file.
1#ifndef SPINLESSFERMIONBASE
2#define SPINLESSFERMIONBASE
3
5#include <algorithm>
6#include <iterator>
7
8#include <boost/dynamic_bitset.hpp>
9#include <Eigen/Core>
11
13#include "sites/SpinlessFermionSite.h"
14#include <boost/dynamic_bitset.hpp>
15#include <Eigen/Core>
16#include <unsupported/Eigen/MatrixFunctions>
17
20#include "DmrgExternal.h" // for posmod
21
29template<typename Symmetry_>
31{
32 typedef Eigen::Index Index;
33 typedef double Scalar;
34
35public:
36
37 typedef Symmetry_ Symmetry;
39 typedef typename Symmetry::qType qType;
40
42
46 SpinlessFermionBase (size_t L_input);
47
49 inline size_t dim() const {return N_states;}
50
52 inline size_t orbitals() const {return N_orbitals;}
53
55 OperatorType c (std::size_t orbital=0) const;
56 OperatorType cdag (std::size_t orbital=0) const;
57 OperatorType n (std::size_t orbital=0) const;
58 OperatorType nph (std::size_t orbital=0) const;
59 OperatorType sign (std::size_t orb1=0, std::size_t orb2=0) const;
60 OperatorType Id (std::size_t orbital=0) const;
61 //OperatorType Zero() const;
63
65 ArrayXd ZeroField() const { return ArrayXd::Zero(N_orbitals); }
66
68 ArrayXXd ZeroHopping() const { return ArrayXXd::Zero(N_orbitals,N_orbitals); }
69
70// typename Symmetry::qType getQ (int Delta=0) const;
71
74
75private:
76
77 OperatorType make_operator(const OperatorType &Op_1s, size_t orbital=0, bool FERMIONIC = false, string label="") const;
78
79 size_t N_orbitals;
80 size_t N_states;
81
86// qarray<Symmetry::Nq> qNums (size_t index) const;
87
88// vector<boost::dynamic_bitset<unsigned char> > basis;
89
90 Qbasis<Symmetry> TensorBasis; //Final basis for N_orbital sites
91
92 //double parity (const boost::dynamic_bitset<unsigned char> &state, int orbital) const;
93
94 //operators defined on zero orbitals
96};
97
98template<typename Symmetry_>
100SpinlessFermionBase (size_t L_input)
101:SpinlessFermionSite<Symmetry>(), N_orbitals(L_input)
102{
103 //create basis for zero orbitals
104 typename Symmetry::qType Q=Symmetry::qvacuum();
105 Eigen::Index inner_dim = 1;
106 Qbasis<Symmetry_> vacuum;
107 vacuum.push_back(Q, inner_dim);
108
109 // create operators for zero orbitals
110 Zero_vac = OperatorType(Symmetry::qvacuum(), vacuum);
112 Id_vac = OperatorType(Symmetry::qvacuum(), vacuum);
114
115 // create basis for N_orbitals fermionic sites
116 if (N_orbitals == 1) {TensorBasis = this->basis_1s();}
117 else if (N_orbitals == 0) {TensorBasis = vacuum;}
118 else
119 {
120 TensorBasis = this->basis_1s().combine(this->basis_1s());
121 for (std::size_t o=2; o<N_orbitals; o++)
122 {
123 TensorBasis = TensorBasis.combine(this->basis_1s());
124 }
125 }
126
127 N_states = TensorBasis.size();
128}
129
130template<typename Symmetry_>
133make_operator (const OperatorType &Op_1s, size_t orbital, bool FERMIONIC, string label) const
134{
135 OperatorType out;
136 if (N_orbitals == 1) {out = Op_1s; out.label() = label; return out;}
137 else if (N_orbitals == 0) {return Zero_vac;}
138 else
139 {
140 OperatorType stringOp;
141 if (FERMIONIC) {stringOp = this->F_1s();}
142 else {stringOp = this->Id_1s();}
143 bool TOGGLE=false;
144 if (orbital == 0) {out = OperatorType::outerprod(Op_1s,this->Id_1s(),Op_1s.Q()); TOGGLE=true;}
145 else
146 {
147 if (orbital == 1) {out = OperatorType::outerprod(stringOp,Op_1s,Op_1s.Q()); TOGGLE=true;}
148 else {out = OperatorType::outerprod(stringOp,stringOp,Symmetry_::qvacuum());}
149 }
150 for(std::size_t o=2; o<N_orbitals; o++)
151 {
152 if (orbital == o) {out = OperatorType::outerprod(out,Op_1s,Op_1s.Q()); TOGGLE=true; }
153 else if (TOGGLE==false) {out = OperatorType::outerprod(out,stringOp,Symmetry_::qvacuum());}
154 else if (TOGGLE==true) {out = OperatorType::outerprod(out,this->Id_1s(),Op_1s.Q());}
155 }
156 out.label() = label;
157 return out;
158 }
159}
160
161template<typename Symmetry_>
164c (std::size_t orbital) const
165{
166 return make_operator(this->c_1s(),orbital,PROP::FERMIONIC, "c");
167}
168
169template<typename Symmetry_>
172cdag (std::size_t orbital) const
173{
174 return make_operator(this->cdag_1s(),orbital,PROP::FERMIONIC, "c");
175}
176
177template<typename Symmetry_>
180n (std::size_t orbital) const
181{
182 return make_operator(this->n_1s(), orbital, PROP::NON_FERMIONIC, "n");
183}
184
185template<typename Symmetry_>
188nph (std::size_t orbital) const
189{
190 return make_operator(this->nph_1s(), orbital, PROP::NON_FERMIONIC, "n");
191}
192
193template <typename Symmetry_>
196sign (std::size_t orb1, std::size_t orb2) const
197{
198 OperatorType Oout;
199 if (N_orbitals == 1) {Oout = this->F_1s(); Oout.label()="sign"; return Oout;}
200 else if (N_orbitals == 0) {return Zero_vac;}
201 else
202 {
203 Oout = Id();
204 for (int i=orb1; i<N_orbitals; ++i)
205 {
206 Oout = Oout * n(i);
207 }
208 for (int i=0; i<orb2; ++i)
209 {
210 Oout = Oout * n(i);
211 }
212 Oout.label() = "sign";
213 return Oout;
214 }
215}
216
217template <typename Symmetry_>
220Id (std::size_t orbital) const
221{
222 return make_operator(this->Id_1s(), orbital, PROP::NON_FERMIONIC, "Id");
223}
224
225//template<typename Symmetry_>
226//SiteOperator<Symmetry,double> SpinlessFermionBase<Symmetry_>::
227//Zero() const
228//{
229// SparseMatrixXd mat = MatrixXd::Zero(N_states,N_states).sparseView();
230// OperatorType Oout(mat,Symmetry::qvacuum());
231// return Oout;
232//}
233
234//template<typename Symmetry_>
235//double SpinlessFermionBase<Symmetry_>::
236//parity (const boost::dynamic_bitset<unsigned char> &b, int i) const
237//{
238// double out = 1.;
239// for (int j=0; j<i; ++j)
240// {
241// if (b[j]) {out *= -1.;} // switch sign for every particle found between 0 & i
242// }
243// return out;
244//}
245
246//template<typename Symmetry_>
247//qarray<Symmetry::Nq> SpinlessFermionBase<Symmetry_>::
248//qNums (size_t index) const
249//{
250// int N = 0;
251//
252// for (size_t i=0; i<N_orbitals; i++)
253// {
254// if (basis[index][i]) {N+=1;}
255// }
256//
257// if constexpr (Symmetry::IS_TRIVIAL) { return qarray<0>{}; }
258// else if constexpr (Symmetry::Nq == 1)
259// {
260// if constexpr (Symmetry::kind()[0] == Sym::KIND::N) {return qarray<1>{N};}
261// else if constexpr (Symmetry::kind()[0] == Sym::KIND::Z2) {return qarray<1>{posmod<2>(N)};}
262// else {assert(false and "Ill defined KIND of the used Symmetry.");}
263// }
264//}
265
266//template<typename Symmetry_>
267//vector<qarray<Symmetry::Nq> > SpinlessFermionBase<Symmetry_>::
268//get_basis() const
269//{
270// vector<qarray<Symmetry::Nq> > vout;
271//
272// for (size_t i=0; i<N_states; ++i)
273// {
274// vout.push_back(qNums(i));
275// }
276//
277// return vout;
278//}
279
280//template<typename Symmetry_>
281//typename Symmetry::qType SpinlessFermionBase<Symmetry_>::
282//getQ (int Delta) const
283//{
284// if constexpr (Symmetry::IS_TRIVIAL) {return {};}
285// else if constexpr (Symmetry::Nq == 1)
286// {
287// if constexpr (Symmetry::kind()[0] == Sym::KIND::N) //return particle number as good quantum number.
288// {
289// return {Delta};
290// }
291// else if constexpr (Symmetry::kind()[0] == Sym::KIND::Z2) //return parity as good quantum number.
292// {
293// return {posmod<2>(Delta)};
294// }
295// else {assert(false and "Ill defined KIND of the used Symmetry.");}
296// }
297// static_assert("You inserted a Symmetry which can not be handled by SpinlessFermionBase.");
298//}
299
300#endif
Definition: Qbasis.h:39
void push_back(const std::tuple< qType, Eigen::Index, std::vector< std::string > > &state)
Definition: Qbasis.h:214
std::string & label()
void setIdentity()
OperatorType n(std::size_t orbital=0) const
ArrayXXd ZeroHopping() const
ArrayXd ZeroField() const
SiteOperatorQ< Symmetry, Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > > OperatorType
OperatorType sign(std::size_t orb1=0, std::size_t orb2=0) const
Qbasis< Symmetry > TensorBasis
OperatorType nph(std::size_t orbital=0) const
OperatorType Id(std::size_t orbital=0) const
OperatorType make_operator(const OperatorType &Op_1s, size_t orbital=0, bool FERMIONIC=false, string label="") const
OperatorType cdag(std::size_t orbital=0) const
Qbasis< Symmetry > get_basis() const
OperatorType c(std::size_t orbital=0) const
Qbasis< Symmetry > basis_1s() const
const bool FERMIONIC
Definition: DmrgTypedefs.h:496
const bool NON_FERMIONIC
Definition: DmrgTypedefs.h:497