Commit dc280613 authored by Christoph Groth's avatar Christoph Groth
Browse files

use expression "term index" instead of "term number"

parent d1644397
...@@ -1913,21 +1913,21 @@ class _VectorizedFinalizedBuilderMixin(_FinalizedBuilderMixin): ...@@ -1913,21 +1913,21 @@ class _VectorizedFinalizedBuilderMixin(_FinalizedBuilderMixin):
h = h.conjugate().transpose() h = h.conjugate().transpose()
return h return h
def hamiltonian_term(self, term_number, selector=slice(None), def hamiltonian_term(self, index, selector=slice(None),
args=(), params=None): args=(), params=None):
if args and params: if args and params:
raise TypeError("'args' and 'params' are mutually exclusive.") raise TypeError("'args' and 'params' are mutually exclusive.")
if term_number < 0: if index < 0:
raise ValueError("term numbers must be non-negative") raise ValueError("term indices must be non-negative")
term = self.terms[term_number] term = self.terms[index]
val = self._term_values[term_number] val = self._term_values[index]
if not callable(val): if not callable(val):
return val[selector] return val[selector]
# Construct site arrays to pass to the vectorized value function. # 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 (to_which, from_which), (to_off, from_off) = subgraph
is_onsite = to_off is from_off is_onsite = to_off is from_off
to_off = to_off[selector] to_off = to_off[selector]
...@@ -1952,8 +1952,8 @@ class _VectorizedFinalizedBuilderMixin(_FinalizedBuilderMixin): ...@@ -1952,8 +1952,8 @@ class _VectorizedFinalizedBuilderMixin(_FinalizedBuilderMixin):
# There was a problem extracting parameter names from the value # There was a problem extracting parameter names from the value
# function (probably an illegal signature) and we are using # function (probably an illegal signature) and we are using
# keyword parameters. # keyword parameters.
if self._term_errors[term_number] is not None: if self._term_errors[index] is not None:
raise self._term_errors[term_number] raise self._term_errors[index]
try: try:
args = [params[p] for p in term.parameters] args = [params[p] for p in term.parameters]
except KeyError: except KeyError:
...@@ -2253,9 +2253,9 @@ def _make_onsite_terms(builder, sites, site_arrays, term_offset): ...@@ -2253,9 +2253,9 @@ def _make_onsite_terms(builder, sites, site_arrays, term_offset):
# tuple for each onsite term. # tuple for each onsite term.
# #
# _onsite_term_by_site_id # _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. # a part of.
# lists the number of the # lists the index of the
# Hamiltonian term associated with each site/hopping. For # Hamiltonian term associated with each site/hopping. For
# Hermitian conjugate hoppings "-term - 1" is stored instead. # 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 ...@@ -2359,8 +2359,8 @@ def _make_hopping_terms(builder, graph, sites, site_arrays, cell_size, term_offs
# differences. # differences.
# #
# _hopping_term_by_edge_id # _hopping_term_by_edge_id
# Maps hopping edge IDs to the number of the term that the hopping # Maps hopping edge IDs to the index of the term that the hopping
# is a part of. For Hermitian conjugate hoppings "-term_number -1" # is a part of. For Hermitian conjugate hoppings "-term_index -1"
# is stored instead. # is stored instead.
# #
# NOTE: 'graph' contains site indices >= cell_size, however 'sites' # NOTE: 'graph' contains site indices >= cell_size, however 'sites'
......
...@@ -586,14 +586,14 @@ class VectorizedSystem(System, metaclass=abc.ABCMeta): ...@@ -586,14 +586,14 @@ class VectorizedSystem(System, metaclass=abc.ABCMeta):
is assumed to return the real-space position of a site given its index. is assumed to return the real-space position of a site given its index.
""" """
@abc.abstractmethod @abc.abstractmethod
def hamiltonian_term(self, term_number, selector=slice(None), def hamiltonian_term(self, index, selector=slice(None),
args=(), params=None): args=(), params=None):
"""Return the Hamiltonians for hamiltonian term number k. """Return the Hamiltonians for hamiltonian term number k.
Parameters Parameters
---------- ----------
term_number : int index : int
The number of the term to evaluate. The index of the term to evaluate.
selector : slice or sequence of int, default: slice(None) selector : slice or sequence of int, default: slice(None)
The elements of the term to evaluate. The elements of the term to evaluate.
args : tuple args : tuple
...@@ -687,7 +687,7 @@ class FiniteSystemMixin(metaclass=abc.ABCMeta): ...@@ -687,7 +687,7 @@ class FiniteSystemMixin(metaclass=abc.ABCMeta):
Additional parameters required for calculating the Hamiltionians. Additional parameters required for calculating the Hamiltionians.
Deprecated in favor of 'params' (and mutually exclusive with it). Deprecated in favor of 'params' (and mutually exclusive with it).
leads : sequence of integers or None leads : sequence of integers or None
Numbers of the leads to be precalculated. If ``None``, all are Indices of the leads to be precalculated. If ``None``, all are
precalculated. precalculated.
what : 'modes', 'selfenergy', 'all' what : 'modes', 'selfenergy', 'all'
The quantitity to precompute. 'all' will compute both The quantitity to precompute. 'all' will compute both
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment