Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • kwant kwant
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 140
    • Issues 140
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 20
    • Merge requests 20
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • kwant
  • kwantkwant
  • Issues
  • #65
Closed
Open
Created Oct 31, 2016 by Joseph Weston@jbwestonOwner

Arrays indexable by site/hopping

Often users will calculate quantities defined over sites/hoppings.

Presently, they have to map high-level Site objects to the corresponding index using the sites list in the system.

This is unnecessarily cumbersome given how often this issue comes up. What we would like to have instead is an array-like object that can be indexed using sites:

ld = kwant.ldos(syst, ...)
ld[lat(0, 0)]

Similarly, objects that are defined on hoppings (e.g. kwant.operator.Current) could be indexed with pairs of sites:

current = J(psi)
current[lat(0, 0), lat(0, 1)]

Also the wavefunction returned by kwant could be indexed by site and return a sub-array over the orbitals on that site (this is related to #9)

I could imagine the following hierarchy:

class Indexable:

    def __init__(self, syst, data):
        pass

    def _index(self, obj):
        pass

    def __getitem__(self, obj):
        return data[self._index(obj)]


class SiteIndexable(Indexable):
    # acts on arrays defined over all sites, indexable by site
    # (_index returns an integer)
    ...

class HoppingIndexable(Indexable):
    # acts on arrays defined over all hoppings (hoppings ordered
    # in the same way as when we iterate over the graph), indexable by hopping
    # (_index returns an integer)
    ...

class OrbitalIndexable(Indexable):
    # acts on arrays defined over all orbitals, indexable by site
    # (_index returns a slice over  -- this can be obtained almost trivially
    # from `syst.site_ranges` (see `_get_orbs` in `kwant/operator.pyx`))
    ...
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking