HubbardGPU
Hubbard diagonalisation on the GPU (and CPU)
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Friends
Macros
nonp-ham.cpp
Go to the documentation of this file.
1
/* Copyright (C) 2014 Ward Poelmans
2
3
This file is part of Hubbard-GPU.
4
5
Hubbard-GPU is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
Hubbard-GPU is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with Hubbard-GPU. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
#include "
nonp-ham.h
"
19
28
NonPeriodicHamiltonian::NonPeriodicHamiltonian
(
int
L,
int
Nu,
int
Nd,
double
J,
double
U):
29
Hamiltonian
(L,Nu,Nd,J,U)
30
{
31
32
}
33
34
NonPeriodicHamiltonian::~NonPeriodicHamiltonian
()
35
{
36
}
37
46
int
NonPeriodicHamiltonian::hopping
(
myint
a,
myint
b,
int
jumpsign)
const
47
{
48
int
result = 0;
49
// find all the holes in the ket
50
myint
cur = ~b;
51
52
while
(cur)
53
{
54
// isolate the rightmost 1 bit
55
myint
hop = cur & (~cur + 1);
56
cur ^= hop;
57
58
myint
tryjump;
59
// you cannot jump if rightmost site
60
if
(! (hop & 0x1))
61
{
62
tryjump = hop >> 1;
63
64
if
(tryjump & b)
65
{
66
myint
bra_test = b ^ (tryjump + hop);
67
68
if
(bra_test == a)
69
result -= 1;
70
}
71
}
72
73
// you cannot jump if leftmost site
74
if
(! (hop &
Hb
))
75
{
76
tryjump = hop << 1;
77
78
if
(tryjump & b)
79
{
80
myint
bra_test = b ^ (tryjump + hop);
81
82
if
(bra_test == a)
83
result -= 1;
84
}
85
}
86
}
87
88
return
result;
89
}
90
91
/* vim: set ts=8 sw=4 tw=0 expandtab :*/
nonp-ham.cpp
Generated on Fri Mar 7 2014 14:52:13 for HubbardGPU by
1.8.3.1