/
hubbard.py
152 lines (122 loc) · 5.75 KB
/
hubbard.py
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
"""Bosonic and fermionic Hubbard models."""
# Copyright 2019-2020 TeNPy Developers, GNU GPLv3
import numpy as np
from .model import CouplingMPOModel, NearestNeighborModel
from ..tools.params import asConfig
from ..networks.site import BosonSite, SpinHalfFermionSite
__all__ = ['BoseHubbardModel', 'BoseHubbardChain', 'FermiHubbardModel', 'FermiHubbardChain']
class BoseHubbardModel(CouplingMPOModel):
r"""Spinless Bose-Hubbard model.
The Hamiltonian is:
.. math ::
H = - t \sum_{\langle i, j \rangle, i < j} (b_i^{\dagger} b_j + b_j^{\dagger} b_i)
+ V \sum_{\langle i, j \rangle, i < j} n_i n_j
+ \frac{U}{2} \sum_i n_i (n_i - 1) - \mu \sum_i n_i
Here, :math:`\langle i,j \rangle, i< j` denotes nearest neighbor pairs.
All parameters are collected in a single dictionary `model_params`, which
is turned into a :class:`~tenpy.tools.params.Config` object.
Parameters
----------
model_params : :class:`~tenpy.tools.params.Config`
Parameters for the model. See :cfg:config:`BoseHubbardModel` below.
Options
-------
.. cfg:config :: BoseHubbardModel
:include: CouplingMPOModel
n_max : int
Maximum number of bosons per site.
filling : float
Average filling.
conserve: {'best' | 'N' | 'parity' | None}
What should be conserved. See :class:`~tenpy.networks.Site.BosonSite`.
t, U, V, mu: float | array
Couplings as defined in the Hamiltonian above. Note the signs!
"""
def init_sites(self, model_params):
n_max = model_params.get('n_max', 3)
filling = model_params.get('filling', 0.5)
conserve = model_params.get('conserve', 'N')
if conserve == 'best':
conserve = 'N'
if self.verbose >= 1.:
print(self.name + ": set conserve to", conserve)
site = BosonSite(Nmax=n_max, conserve=conserve, filling=filling)
return site
def init_terms(self, model_params):
# 0) Read and set parameters.
t = model_params.get('t', 1.)
U = model_params.get('U', 0.)
V = model_params.get('V', 0.)
mu = model_params.get('mu', 0)
for u in range(len(self.lat.unit_cell)):
self.add_onsite(-mu - U / 2., u, 'N')
self.add_onsite(U / 2., u, 'NN')
for u1, u2, dx in self.lat.pairs['nearest_neighbors']:
self.add_coupling(-t, u1, 'Bd', u2, 'B', dx, plus_hc=True)
self.add_coupling(V, u1, 'N', u2, 'N', dx)
class BoseHubbardChain(BoseHubbardModel, NearestNeighborModel):
"""The :class:`BoseHubbardModel` on a Chain, suitable for TEBD.
See the :class:`BoseHubbardModel` for the documentation of parameters.
"""
def __init__(self, model_params):
model_params = asConfig(model_params, self.__class__.__name__)
model_params.setdefault('lattice', "Chain")
CouplingMPOModel.__init__(self, model_params)
class FermiHubbardModel(CouplingMPOModel):
r"""Spin-1/2 Fermi-Hubbard model.
The Hamiltonian reads:
.. math ::
H = - \sum_{\langle i, j \rangle, i < j, \sigma} t (c^{\dagger}_{\sigma, i} c_{\sigma j} + h.c.)
+ \sum_i U n_{\uparrow, i} n_{\downarrow, i}
- \sum_i \mu ( n_{\uparrow, i} + n_{\downarrow, i} )
+ \sum_{\langle i, j \rangle, i< j, \sigma} V
(n_{\uparrow,i} + n_{\downarrow,i})(n_{\uparrow,j} + n_{\downarrow,j})
Here, :math:`\langle i,j \rangle, i< j` denotes nearest neighbor pairs.
All parameters are collected in a single dictionary `model_params`, which
is turned into a :class:`~tenpy.tools.params.Config` object.
.. warning ::
Using the Jordan-Wigner string (``JW``) is crucial to get correct results!
See :doc:`/intro/JordanWigner` for details.
Parameters
----------
model_params : :class:`~tenpy.tools.params.Config`
Parameters for the model. See :cfg:config:`FermiHubbardModel` below.
Options
-------
.. cfg:config :: FermiHubbardModel
:include: CouplingMPOModel
cons_N : {'N' | 'parity' | None}
Whether particle number is conserved,
see :class:`~tenpy.networks.site.SpinHalfFermionSite` for details.
cons_Sz : {'Sz' | 'parity' | None}
Whether spin is conserved,
see :class:`~tenpy.networks.site.SpinHalfFermionSite` for details.
t, U, mu : float | array
Config as defined for the Hamiltonian above. Note the signs!
"""
def init_sites(self, model_params):
cons_N = model_params.get('cons_N', 'N')
cons_Sz = model_params.get('cons_Sz', 'Sz')
site = SpinHalfFermionSite(cons_N=cons_N, cons_Sz=cons_Sz)
return site
def init_terms(self, model_params):
# 0) Read out/set default parameters.
t = model_params.get('t', 1.)
U = model_params.get('U', 0)
V = model_params.get('V', 0)
mu = model_params.get('mu', 0.)
for u in range(len(self.lat.unit_cell)):
self.add_onsite(-mu, u, 'Ntot')
self.add_onsite(U, u, 'NuNd')
for u1, u2, dx in self.lat.pairs['nearest_neighbors']:
self.add_coupling(-t, u1, 'Cdu', u2, 'Cu', dx, plus_hc=True)
self.add_coupling(-t, u1, 'Cdd', u2, 'Cd', dx, plus_hc=True)
self.add_coupling(V, u1, 'Ntot', u2, 'Ntot', dx)
class FermiHubbardChain(FermiHubbardModel, NearestNeighborModel):
"""The :class:`FermiHubbardModel` on a Chain, suitable for TEBD.
See the :class:`FermiHubbardModel` for the documentation of parameters.
"""
def __init__(self, model_params):
model_params = asConfig(model_params, self.__class__.__name__)
model_params.setdefault('lattice', "Chain")
CouplingMPOModel.__init__(self, model_params)