Joseph Weston wrote:

- A more general solution is to do what Anton proposed. I include a sample script below.

sym.add_site_family(lat.sublattices[0], other_vectors=[(-1, 2)]) sym.add_site_family(lat.sublattices[1], other_vectors=[(-1, 2)])

Thanks for this. I had tried do do the following:

        sym.add_site_family(lat, other_vectors=[(-1, 2)])

instead of calling `add_site_family` for each sub-lattice, and it did not work. I therefore thought that my understanding was flawed, but it seems that for a polyatomic lattice one has to manually add each sub-lattice. Maybe a word in the documentation would be useful to prevent this potential pitfall

Thanks for brining up this issue, this is certainly one aspect of Kwant that could (and will) be improved in the future.

Even though add_site_family is part of the public API, it is something of a second-class citizen. It was not meant to be used commonly. Only after publishing Kwant 1.0 we realized that add_site_family can be actually useful for choosing the orientation of lead unit cells.

In fact, “add_site_family” should be have been named “add_lattice”, as it does not work for general site families but only for instances of kwant.lattice.Monatomic. It could also accept kwant.lattice.Polyatomic instances as you suggest.

Fixing all this in a backwards-compatible way would be messy and confusing. I’ve made a note about this issue for the next major version of Kwant. For now, I recommend using what has been suggested above, i.e.:

for sl in lat.sublattices:
   sym.add_site_family(sl, other_vectors=[(-1, 2)])

Christoph

Attachment: signature.asc
Description: PGP signature

Reply via email to