-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnonp-ham.cpp
91 lines (74 loc) · 2.39 KB
/
nonp-ham.cpp
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
79
80
81
82
83
84
85
86
87
88
89
90
91
/* Copyright (C) 2014 Ward Poelmans
This file is part of Hubbard-GPU.
Hubbard-GPU is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hubbard-GPU is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Hubbard-GPU. If not, see <http://www.gnu.org/licenses/>.
*/
#include "nonp-ham.h"
/**
* Constructor of the NonPeriodicHamiltonian class
* @param L Number of lattice sites
* @param Nu Number of Up Electrons
* @param Nd Number of Down Electrons
* @param J The hopping strengh
* @param U The onsite interaction strength
*/
NonPeriodicHamiltonian::NonPeriodicHamiltonian(int L, int Nu, int Nd, double J, double U):
Hamiltonian(L,Nu,Nd,J,U)
{
}
NonPeriodicHamiltonian::~NonPeriodicHamiltonian()
{
}
/**
* Calculates the hopping for the non periodic boundary conditions
* @param a the bra to use
* @param b the ket to use
* @param jumpsign ignored, has no meaning here, set to zero by default
* @returns matrix element of the hopping term between the ket and the bra. You still
* have to multiply this with the hopping strength J
*/
int NonPeriodicHamiltonian::hopping(myint a, myint b, int jumpsign) const
{
int result = 0;
// find all the holes in the ket
myint cur = ~b;
while(cur)
{
// isolate the rightmost 1 bit
myint hop = cur & (~cur + 1);
cur ^= hop;
myint tryjump;
// you cannot jump if rightmost site
if(! (hop & 0x1))
{
tryjump = hop >> 1;
if(tryjump & b)
{
myint bra_test = b ^ (tryjump + hop);
if(bra_test == a)
result -= 1;
}
}
// you cannot jump if leftmost site
if(! (hop & Hb))
{
tryjump = hop << 1;
if(tryjump & b)
{
myint bra_test = b ^ (tryjump + hop);
if(bra_test == a)
result -= 1;
}
}
}
return result;
}
/* vim: set ts=8 sw=4 tw=0 expandtab :*/