I am trying to attach leads with a honeycomb basis to a honeycomb lattice, and can’t seem to understand why my code doesn’t work, I don’t really understand the logic of attaching the lead (and how the r variable is defined):
The attach logic is probably a bit confusing at first. The way to understand it is that it adds a self energy to some sites in your Hamiltonian, creating a “contact” on those sites. The core syntax is then simply attach(h::AbstractHamiltonian, Σ::SelfEnergy; sites...), or the curried version h |> attach(Σ; sites...). Then, instead of you actually building the self energy, you have a series of additional attach methods (see docs), like the h |> attach(glead::GreenFunction; sites...) above, that compute the self-energy for you. The net result is an OpenHamiltonian, that when converted to a GreenFunction with the appropiate GreenSolver (here GS.Schur), allows you to compute different observables.
Note that since the central lattice is just a piece of the lead in this case, any observable you compute with gcentral (round sites) you could also get with glead (square sites, extending to infinity)
Hi @Milt, yes you can. Since the glead and cell are not lattice-matched, you need to use the attach(::GreenSlice, ::Model; siteselection...) syntax, i.e. you need to define how the two systems are coupled. You also need to make sure siteselection selects a finite number of sites (otherwise attach will throw a [currently obscure] error), and you need to translate the unit cell of glead that you want to couple (given in GreenSlice) so that it is located where you want.
Following your example you would then need something like this:
using Quantica
using GLMakie
Rot = r -> SA[0 -1; 1 0] * r
glead = LP.square(a0 = 2*cos(π/6), dim = 2) |> onsite(4) - hopping(1) |> supercell((1,0), region = r -> -2 <= r[2] <= 2) |> translate((6,0)) |> greenfunction(GS.Schur(boundary = 0));
cell = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell(region = RP.rectangle((14,14))) |> transform(Rot)
green = cell |> attach(glead[cells = 1], -hopping(1, range = 2), region = r -> r[1] > 6.5 && -1.5 <= r[2] <= 1.5) |> greenfunction
qplot(green)
The plot (using current Quantica master) would give you this
That said, I suspect you wanted to have the same lattice spacing in the lead, right? It’s good to remember that the default lattice spacing of all lattice preset is one. In the honeycomb that is the next-nearest-neighbor distance, so the nearest neighbor distance is 1/sqrt(3). Hence, you might have intended to do
using Quantica
using GLMakie
Rot = r -> SA[0 -1; 1 0] * r
glead = LP.square(a0 = 1, dim = 2) |> onsite(4) - hopping(1) |> supercell((1,0), region = r -> -1 <= r[2] <= 1) |> translate((6.5,0)) |> greenfunction(GS.Schur(boundary = 0));
cell = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell(region = RP.rectangle((14,14))) |> transform(Rot)
green = cell |> attach(glead[cells = 1], -hopping(1), region = r -> r[1] > 6.5 && -1.5 <= r[2] <= 1.5) |> greenfunction
qplot(green)
It would seem that the cell surface and the lead are lattice-matched, but the two lattices have different number of sublattices, so currently one must use the more general attach method. You got me thinking, however, that one could perhaps generalize the simplified attach method a bit to make it work also in this case. I’ll give it a try when I have time.