Hi, I'm experiencing an issue on my cubic construction. It doesn't matter what I try it persists. I think it is a bug, but I'm not sure. I have the following code, and I'm getting that the top site of z at a "x,y" corner is always a different lattice, the botton lattice. If I eliminate "lat_ti" which is green, then this site becomes blue, "lat_tu", but never becomes "lat_sc" as stated. Even if I put this site above the sample, that is, unnconected, this issue mantains. This also was happening before stating colors for the lattices. Link for the plot: https://drive.google.com/file/d/13Z5XnGaeyJGYJgyM_NGm0onp5MoQs_O/view?usp=s... def make_system(a=1, W=21, L=15, H=4, Hs=6, barrier=1.5, mu=0.4, Delta=0.1, t=1.0): lat_sc = kwant.lattice.cubic(a,name='Supercondutor', norbs=2) lat_tu = kwant.lattice.cubic(a,name='Tunelamento', norbs=2) lat_ti = kwant.lattice.cubic(a,name='TopIns') syst = kwant.Builder() #### Scattering region. #### syst[(lat_ti(x, y, z) for x in range(W) for y in range(L) for z in range(H1))] = 0 syst[(lat_ti(x, y, z) for x in range(int(W/3),int(2*W/3)) for y in range(L) for z in range(H1,H))] = 0 syst[(lat_sc(x, y, z) for x in range(int(W/3)) for y in range(L) for z in range(H+1,H+Hs))] = onsite_sc syst[(lat_sc(x, y, z) for x in range(int(2*W/3),W) for y in range(L) for z in range(H+1,H+Hs))] = onsite_sc syst[(lat_sc(W1, 0, H+Hs+2))] = 0 #bug ? # The tunnel barrier syst[(lat_tu(x, y, z) for x in range(int(W/3)) for y in range(L) for z in range(H1, H+1))] = onsite_tu syst[(lat_tu(x, y, z) for x in range(int(2*W/3),W) for y in range(L) for z in range(H1,H+1))] = onsite_tu def family_color(site): if site.family == lat_sc: return 'red' if site.family == lat_ti: return 'green' if site.family == lat_tu: return 'blue' return syst, family_color
Hi, can you please send the complete script to reproduce this issue? Without trying it out I can say that matplotlib’s 3d plotting is a hack and the sorting from back to the front does not always work. So it could well be that your code is performing as it should and that there’s only a problem with the plotting. Christoph
Hi, thanks for the answer. I also think that It might be something from matplotlib, but I'm not sure. The following code completely reproduces the bug, and the #sys shows how it deslocates. Taking of some f the lattices also doesn't fix, it can be checked. import kwant import tinyarray import numpy as np from matplotlib import pyplot #Pauli Matrices sigma_0 = tinyarray.array([[1, 0], [0, 1]]) sigma_x = tinyarray.array([[0, 1], [1, 0]]) sigma_y = tinyarray.array([[0, 1j], [1j, 0]]) sigma_z = tinyarray.array([[1, 0], [0, 1]]) barrier=1.5 phi = 0.005 U0 = 0.3 salt = 13 mu=0.4 Delta=0.1 t=1.0 #Onsite + Disorder from kwant.digest import uniform def onsite_sc(site): return (4 * t  mu) * np.tensordot(sigma_z,sigma_0, axes=0) + Delta * np.tensordot(sigma_x,sigma_0, axes=0) def onsite_tu(site): return (4 * t + barrier  mu) * np.tensordot(sigma_z,sigma_0, axes=0) def make_system(a=1, W=21, L=15, H=4, Hs=6, barrier=1.5, phi = 0.005, U0 = 0.3, salt = 13, mu=0.4, Delta=0.1, t=1.0): lat_ti = kwant.lattice.cubic(a,name='TopIns') lat_sc = kwant.lattice.cubic(a,name='Supercondutor', norbs=2) lat_tu = kwant.lattice.cubic(a,name='Tunelamento', norbs=2) syst = kwant.Builder() syst[(lat_ti(x, y, z) for x in range(W) for y in range(L) for z in range(H1))] = 0 syst[(lat_ti(x, y, z) for x in range(int(W/3),int(2*W/3)) for y in range(L) for z in range(H1,H))] = 0 syst[(lat_sc(x, y, z) for x in range(int(W/3)) for y in range(L) for z in range(H+1,H+Hs))] = onsite_sc syst[(lat_sc(x, y, z) for x in range(int(2*W/3),W) for y in range(L) for z in range(H+1,H+Hs))] = onsite_sc #syst[(lat_sc(W1, 0, H+Hs+10))] = 0 #bug ? # The tunnel barrier syst[(lat_tu(x, y, z) for x in range(int(W/3)) for y in range(L) for z in range(H1, H+1))] = onsite_tu syst[(lat_tu(x, y, z) for x in range(int(2*W/3),W) for y in range(L) for z in range(H1,H+1))] = onsite_tu def family_color(site): if site.family == lat_sc: return 'yellow' if site.family == lat_ti: return 'green' if site.family == lat_tu: return 'blue' return syst, family_color def main(): syst = make_system()[0] # Check that the system looks as intended. kwant.plot(syst, site_color=make_system()[1]) if __name__ == '__main__': main()
guilhermewells@gmail.com wrote:
The following code completely reproduces the bug, and the #sys shows how it deslocates. Taking of some f the lattices also doesn't fix, it can be checked.
Now I understand what you meant: in the figure you linked to previously, the color of the single “stray” site does not match the color of the “humps” with which it shares the same site family. Before you sent the example I wrongly believed that your issue might be about the sorting order of sites with regards to which there used to be some problems. However, I would be surprised if the color issue you observe was caused by matplotlib. It should be able to plot a circle in the color it is told to do. So that’s indeed a strange problem! However, I cannot reproduce it. In your script, I uncommented the line marked with “bug?” and obtain the attached plot. The separate site has the same color (here: yellow) as the two humps that are made with lat_sc, as it should be. This is with Python 3.9, Kwant 1.4.3, and matplotlib 3.3.4, running on Debian stable. What is your environment? Christoph
Dear Christoph and Gillherm,
I think that is indeed a bug.
I simplified the code to minimum, and could not find any error or
explanation.
My matplotlib is 3.4.3
kwant 1.4.3 installed on windows.
Regards,
Adel
################################################################
import kwant
from matplotlib import pyplot
lat1 = kwant.lattice.cubic(a=1,name='first')
lat2 = kwant.lattice.cubic(a=1,name='second')
syst = kwant.Builder()
syst[(lat1(x, y, z) for x in range(5) for y in range(5) for z in [15])] = 0
syst[(lat2(x, y, z) for x in range(5) for y in range(5) for z in [5])] = 0
def Color(site):
if site.family == lat1: return 'red'
else: return 'green'
kwant.plot(syst, site_color=Color)
On Mon, Apr 17, 2023 at 7:52 PM Christoph Groth
guilhermewells@gmail.com wrote:
The following code completely reproduces the bug, and the #sys shows how it deslocates. Taking of some f the lattices also doesn't fix, it can be checked.
Now I understand what you meant: in the figure you linked to previously, the color of the single “stray” site does not match the color of the “humps” with which it shares the same site family.
Before you sent the example I wrongly believed that your issue might be about the sorting order of sites with regards to which there used to be some problems. However, I would be surprised if the color issue you observe was caused by matplotlib. It should be able to plot a circle in the color it is told to do.
So that’s indeed a strange problem!
However, I cannot reproduce it. In your script, I uncommented the line marked with “bug?” and obtain the attached plot. The separate site has the same color (here: yellow) as the two humps that are made with lat_sc, as it should be.
This is with Python 3.9, Kwant 1.4.3, and matplotlib 3.3.4, running on Debian stable. What is your environment?
Christoph
 Abbout Adel
Hi Adel, Thanks for contributing to this. When I run your script, I obtain the attached plot: There is one layer of green and one layer of red sites. This is how it is supposed to work, right? Do you obtain a different result? Christoph
Christoph Groth wrote :
However, I cannot reproduce it. In your script, I uncommented the line marked with “bug?” and obtain the attached plot. The separate site has the same color (here: yellow) as the two humps that are made with lat_sc, as it should be.
I forgot to attach the plot. Here it is:
participants (3)

Abbout Adel

Christoph Groth

guilhermewells＠gmail.com