Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pablo Piskunow
kwant
Commits
dc280613
Commit
dc280613
authored
Feb 13, 2020
by
Christoph Groth
Browse files
use expression "term index" instead of "term number"
parent
d1644397
Changes
2
Hide whitespace changes
Inline
Side-by-side
kwant/builder.py
View file @
dc280613
...
...
@@ -1913,21 +1913,21 @@ class _VectorizedFinalizedBuilderMixin(_FinalizedBuilderMixin):
h
=
h
.
conjugate
().
transpose
()
return
h
def
hamiltonian_term
(
self
,
term_number
,
selector
=
slice
(
None
),
def
hamiltonian_term
(
self
,
index
,
selector
=
slice
(
None
),
args
=
(),
params
=
None
):
if
args
and
params
:
raise
TypeError
(
"'args' and 'params' are mutually exclusive."
)
if
term_number
<
0
:
raise
ValueError
(
"term
number
s must be non-negative"
)
if
index
<
0
:
raise
ValueError
(
"term
indice
s must be non-negative"
)
term
=
self
.
terms
[
term_number
]
val
=
self
.
_term_values
[
term_number
]
term
=
self
.
terms
[
index
]
val
=
self
.
_term_values
[
index
]
if
not
callable
(
val
):
return
val
[
selector
]
# Construct site arrays to pass to the vectorized value function.
subgraph
=
self
.
subgraphs
[
self
.
terms
[
term_number
].
subgraph
]
subgraph
=
self
.
subgraphs
[
self
.
terms
[
index
].
subgraph
]
(
to_which
,
from_which
),
(
to_off
,
from_off
)
=
subgraph
is_onsite
=
to_off
is
from_off
to_off
=
to_off
[
selector
]
...
...
@@ -1952,8 +1952,8 @@ class _VectorizedFinalizedBuilderMixin(_FinalizedBuilderMixin):
# There was a problem extracting parameter names from the value
# function (probably an illegal signature) and we are using
# keyword parameters.
if
self
.
_term_errors
[
term_number
]
is
not
None
:
raise
self
.
_term_errors
[
term_number
]
if
self
.
_term_errors
[
index
]
is
not
None
:
raise
self
.
_term_errors
[
index
]
try
:
args
=
[
params
[
p
]
for
p
in
term
.
parameters
]
except
KeyError
:
...
...
@@ -2253,9 +2253,9 @@ def _make_onsite_terms(builder, sites, site_arrays, term_offset):
# tuple for each onsite term.
#
# _onsite_term_by_site_id
# Maps the site ID to the
number
of the term that the site is
# Maps the site ID to the
index
of the term that the site is
# a part of.
# lists the
number
of the
# lists the
index
of the
# Hamiltonian term associated with each site/hopping. For
# Hermitian conjugate hoppings "-term - 1" is stored instead.
...
...
@@ -2359,8 +2359,8 @@ def _make_hopping_terms(builder, graph, sites, site_arrays, cell_size, term_offs
# differences.
#
# _hopping_term_by_edge_id
# Maps hopping edge IDs to the
number
of the term that the hopping
# is a part of. For Hermitian conjugate hoppings "-term_
number
-1"
# Maps hopping edge IDs to the
index
of the term that the hopping
# is a part of. For Hermitian conjugate hoppings "-term_
index
-1"
# is stored instead.
#
# NOTE: 'graph' contains site indices >= cell_size, however 'sites'
...
...
kwant/system.py
View file @
dc280613
...
...
@@ -586,14 +586,14 @@ class VectorizedSystem(System, metaclass=abc.ABCMeta):
is assumed to return the real-space position of a site given its index.
"""
@
abc
.
abstractmethod
def
hamiltonian_term
(
self
,
term_number
,
selector
=
slice
(
None
),
def
hamiltonian_term
(
self
,
index
,
selector
=
slice
(
None
),
args
=
(),
params
=
None
):
"""Return the Hamiltonians for hamiltonian term number k.
Parameters
----------
term_number
: int
The
number
of the term to evaluate.
index
: int
The
index
of the term to evaluate.
selector : slice or sequence of int, default: slice(None)
The elements of the term to evaluate.
args : tuple
...
...
@@ -687,7 +687,7 @@ class FiniteSystemMixin(metaclass=abc.ABCMeta):
Additional parameters required for calculating the Hamiltionians.
Deprecated in favor of 'params' (and mutually exclusive with it).
leads : sequence of integers or None
Number
s of the leads to be precalculated. If ``None``, all are
Indice
s of the leads to be precalculated. If ``None``, all are
precalculated.
what : 'modes', 'selfenergy', 'all'
The quantitity to precompute. 'all' will compute both
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment