# Attaching leads to honeycomb lattice

Hi,

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):

hgraph = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell(3,3)
glead = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell((0, 1), region = r → abs(r[1]) <= √3/3)
|> greenfunction(GS.Schur(boundary = 0));

g = hgraph |>
attach(glead, region = r → r[1] == 1) |>
greenfunction

The parent lattice and lead look as follows:

@pablosanjose

Something like this?

``````julia> using GLMakie, Quantica

julia> glead = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell((1,-1), region = r -> -3.5 <= r[2] <= 3.5) |> greenfunction(GS.Schur(boundary = 0));

julia> qplot(glead, selector = siteselector(; cells = 1:10), sitecolor = :blue)

julia> gcentral = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell(region = RP.rectangle((11,10))) |> attach(glead, region = r -> r[1] > 5.1 && -3.5 <= r[2] <= 3.5) |> greenfunction;

julia> qplot(gcentral, children =(; selector = siteselector(cells = 1:3), sitecolor = :blue))
``````

Note that these plots use current master, which you can get with `] add Quantica#master`

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.

Another geometry, perhaps closer to what you had in mind:

``````julia> glead = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell(3,1) |> supercell((0,-1))|> greenfunction(GS.Schur(boundary = 0));

julia> gcentral = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell(3,3) |> supercell |> attach(glead, region = r -> SA[-√3/2,1/2]' * r < 0) |> greenfunction;

julia> qplot(gcentral)
``````

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)

2 Likes

Is it possible to attach a square lead onto a honeycombe lattice?

I am attempting to attach leads horizontally in the following way:

``````glead = LP.square(a0 = 2*cos(π/6), dim = 2) |> onsite(4) - hopping(1) |> supercell((1,0), region = r -> -2 <= r[2] <= 2) |> greenfunction(GS.Schur(boundary = 0));

cell = LP.honeycomb() |> onsite(4) - hopping(1) |> supercell(region = RP.rectangle((14,14))) |> transform(Rot)

green = cell |>
attach(glead, region = r -> r[1] > 7 && -1.5 <= r[2] <= 1.5, reverse = false) |>
greenfunction

``````

Many thanks

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.