
Hi Joe, thank you for your help (and also for getting back to a python and not a kwant one). The next error where it hangs 'Matrices are not aligned' are again inherently python, but I think the reason for the error is rooted in my layout of the 1D lattice. If I want a 1D lattice with a bi-atomic unit cell, is the following a correct way of defining the lattice? I am wondering, because I originally wanted to define my lattice vectors as [2,0] in order to not land on my second site when constructing the lattice, but it didn't let me (commensurate error). SSH = kwant.lattice.general([[1, 0]], # lattice vectors [[0,0], [1,0]]) # Coordinates of the sites) and sequentially when i want to define the short/long hoppings as (((0,0),a,b) and (((-1,0),a,b)? When the hoppings were defined in the graphene tutorial they also included the hopping like ((0,0),a,b) - does this refer to a hopping inside the unit cell itself between the two sublattices, I would have initially gone like (((1,0),a,b)? If you could shed some light on whats going on here with the sublattices or where I can read about it, that would be great. Thank you, Steffen ----------------------- complete code import numpy as np import kwant t = 1 SSH = kwant.lattice.general([[1, 0]], # lattice vectors [[0,0], [1,0]]) # Coordinates of the sites) a,b = SSH.sublattices SSH_lead = kwant.Builder(kwant.TranslationalSymmetry([-1, 0])) SSH_lead[a.shape((lambda pos: abs(pos[0]) == 0), (0, 0))] = 1 SSH_lead[b.shape((lambda pos: abs(pos[0]) == 1), (0, 0))] = 1 LongBond = [((0, 0), a, b),] ShortBond = [((-1, 0), a, b),] SSH_lead[[kwant.builder.HoppingKind(*hopping) for hopping in LongBond]] = 2 SSH_lead[[kwant.builder.HoppingKind(*hopping) for hopping in ShortBond]] = 1 kwant.plot(SSH_lead) kwant.plotter.bands(SSH_lead.finalized()) On 07/10/2017 06:36 AM, Joseph Weston wrote:
Hi Steffen.
Your code fails in the following lines:
LongBond = (((1, 0), a, b)) SSH_lead[[kwant.builder.HoppingKind(*hopping) for hopping in LongBond]] = 2
because the 'LongBond' variable is not instantiated correctly. In Python you have to leave a trailing comma when creating a single-element tuple:
LongBond = (((1, 0), a, b),) to make things easier to read you can also just create a list:
LongBond = [((1, 0), a, b)]
In the future you can try inserting calls to 'print' into your code to check certain conditions and inspect what is going on.
Happy Kwanting,
Joe