-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHubbard2D.hpp
78 lines (62 loc) · 1.9 KB
/
Hubbard2D.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Hubbard2D.hpp
//
// Created by ryle on 1/15/17.
// Copyright © 2017 R L. All rights reserved.
//
#ifndef Hubbard2D_hpp
#define Hubbard2D_hpp
#include <stdio.h>
#include <bitset>
#include <complex>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <Eigen/SparseCore>
#include <Eigen/Core>
//**************************************c
#define BASISSIZE 32 //(4*4)*2
//**************************************c
typedef std::bitset<BASISSIZE> tbitset;
typedef tbitset lattice_t;
typedef std::vector<lattice_t> basis_t;
typedef std::complex<double> Complex;
typedef Eigen::SparseMatrix<double,Eigen::RowMajor,long> SpMat;
///basis mapping
typedef std::unordered_map<lattice_t,unsigned long> dict_t;
typedef Eigen::MatrixXd rotation_t;
EIGEN_STATIC_ASSERT(BASISSIZE%2==0, BASISSIZE_NEEDS_TO_BE_EVEN);
class HubbardModel2D{
protected:
int Lx,Ly,nUp,nDown,numParam;
double t,U;
basis_t basis;
//Hamiltonian
SpMat H;
///make a map of basis bitset to index
dict_t indexMap;
/// Hoping/Neighbor Matrix; should include -t,-t' etc
// TODO:allow for t' values that aren't 1
Eigen::MatrixXd HH;
//stores neighbors, currently unused beyond HH generation
std::vector<std::vector<int> > neighbors;
public:
HubbardModel2D(int nUp_in,int nDown_in,double t_in, double U_in):
nUp(nUp_in),nDown(nDown_in),t(t_in),U(U_in){
init();};
//setup matrices
void init();
///construct a basis given Lx,Ly, nUp, nDown
void makeBasis();
///build matrix given init bonds
void buildHubbard2D();
//getter functions
///getter for the internal basis
const basis_t *getBasis() {return &basis;}
///getter for last made Hamiltonian
SpMat *getH() {return &H;}
///given a basis element return index
unsigned long getState(const lattice_t &psi){return indexMap[psi];}
};
#endif /* Hubbard2D_hpp */