Kwant-Plot discretize potential with different colours
Dear Kwant community, I am a physics student and I am approaching to Kwant to solve simple problems of scattering. For example, I created a 2D discrete potential. The potential has two different values: "V0" and "0". When I plot the system, using the command "kwant.plot(syst)", I obtain the plot with only light-blue colour. There is a command to plot the discrete potential with two (or more) different colours (in my case one colour for "V0", and another one for "0")? Yours Sincerely Lorenzo Bagnasacco
Dear Lorenzo,
Of course there is. It is straightforward, thanks to Kwant. To do so you
need two functions to be defined.
1- you have to define the onsite as a function.
2- you have to define a family_color function which has to depend on the
onsite function.
3-Active family_color in kwant.plot().
To make this simple to you, kindly see the following examples (p-n-junction)
best, Adel
import kwant
import numpy as np
from math import sqrt
import matplotlib.pyplot as plt
from types import SimpleNamespace
from ipywidgets import interact
from mpl_toolkits import mplot3d
import warnings
warnings.filterwarnings('ignore')
def onsite_1(site):
x,y = site.pos
if x>0:
return 5
else:
return 0
### --------- Onsite-------
def family_color_1(site):
x,y = site.pos
return onsite_1(site)
def onsite_2(site):
x,y = site.pos
if abs(x)<4:
return 5
elif x>4:
return 2.5
else:
return 0
### --------- Onsite-------
def family_color_2(site):
x,y = site.pos
return onsite_2(site)
lat = kwant.lattice.honeycomb(a=1, norbs=1, name=["a", "b"])
a, b =lat.sublattices
def rect(pos):
x, y = pos
return abs(x) < 10 and abs(y) < 5
sys1=kwant.Builder()
sys1[lat.shape(rect, (1, 1))] = onsite_1
sys1[lat.neighbors(1)] = -1
sys2=kwant.Builder()
sys2[lat.shape(rect, (1, 1))] = onsite_2
sys2[lat.neighbors(1)] = -1
kwant.plot(sys1, site_color=family_color_1, site_size=None, cmap='jet',
colorbar=True,)
plt.show()
kwant.plot(sys2, site_color=family_color_2, site_size=None, cmap='jet',
colorbar=True,)
plt.show()
Le mar. 17 mai 2022 à 11:22, Lorenzo BAGNASACCO
Dear Kwant community,
I am a physics student and I am approaching to Kwant to solve simple problems of scattering. For example, I created a 2D discrete potential. The potential has two different values: "V0" and "0". When I plot the system, using the command "kwant.plot(syst)", I obtain the plot with only light-blue colour. There is a command to plot the discrete potential with two (or more) different colours (in my case one colour for "V0", and another one for "0")?
Yours Sincerely
Lorenzo Bagnasacco
participants (2)
-
Adel Belayadi
-
Lorenzo BAGNASACCO