How can I use kwant.plotter.map when using an orbital description
I am going through the tutorials and I wanted to combine two of the lessons. 2.4. Beyond transport: Band structure and closed systems 2.6. Superconductors: orbital vs. lattice degrees of freedom In 2.4, they plot the wavefunction using kwant.plotter.map In 2.6, the system uses tinyarrays Can I combine these and plot the wavefunction using map? Here is my code import kwant import numpy as np import matplotlib.pyplot as plt import tinyarray as ta s_0 = ta.array([[1, 0], [0, 1]]) s_x = ta.array([[0, 1], [1, 0]]) s_y = ta.array([[0, -1j], [1j, 0]]) s_z = ta.array([[1, 0], [0, -1]]) def make_system(a=1, L=21, W=21, t=1.0, mu=-3.618, Delta=0.1, leads=True): lat = kwant.lattice.square(a) syst = kwant.Builder() syst[(lat(x,y) for x in range(L) for y in range(W))] = -mu * s_z + Delta * s_x syst[lat.neighbors()] = -t * s_z if (leads): lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) lead[(lat(0, j) for j in range(W))] = -mu * s_z lead[lat.neighbors()] = -t * s_z syst.attach_lead(lead) syst.attach_lead(lead.reversed()) return syst def plot_conductance(syst, energies): data = [] for energy in energies: smatrix = kwant.smatrix(syst, energy) # Conductance is N - R_ee + R_he data.append(smatrix.submatrix(0, 0).shape[0] - smatrix.transmission(0, 0) + smatrix.transmission(1, 0)) plt.figure() plt.plot(energies, data) plt.xlabel("energy [t]") plt.ylabel("conductance [e^2/h]") plt.show() def plot_wave_function(sys): # Calculate the wave functions in the system. ham_mat = sys.hamiltonian_submatrix(sparse=True) evecs = sla.eigsh(ham_mat, k=20, which='SM')[1] # Plot the probability density of the 10th eigenmode. kwant.plotter.map(sys, np.abs(evecs[:, 9])**2, colorbar=False, oversampling=1) syst = make_system() kwant.plot(syst) syst = syst.finalized() plot_conductance(syst, energies=[-0.25 + 0.005 * i for i in range(100)]) plot_wave_function(syst) Currently, I get the error "The number of sites doesn't match the number of provided values." Thanks, Eric
Dear Eric, First, import the necessary library: import scipy.sparse.linalg as sla Then, you should notice that the dimension of your wavevector is twice the number of sites (because you have two spins). All what you need is to plot the wave function for each spin separately by replacing your wave fucntion by: evecs[::2, 9])**2 or by evecs[1::2, 9])**2 (each one represents a different spin.) I hope that this helps. Adel On Thu, Dec 15, 2016 at 7:41 AM, Eric Mascot <emasco2@uic.edu> wrote:
I am going through the tutorials and I wanted to combine two of the lessons. 2.4. Beyond transport: Band structure and closed systems 2.6. Superconductors: orbital vs. lattice degrees of freedom
In 2.4, they plot the wavefunction using kwant.plotter.map In 2.6, the system uses tinyarrays Can I combine these and plot the wavefunction using map?
Here is my code
import kwant import numpy as np import matplotlib.pyplot as plt import tinyarray as ta
s_0 = ta.array([[1, 0], [0, 1]]) s_x = ta.array([[0, 1], [1, 0]]) s_y = ta.array([[0, -1j], [1j, 0]]) s_z = ta.array([[1, 0], [0, -1]])
def make_system(a=1, L=21, W=21, t=1.0, mu=-3.618, Delta=0.1, leads=True): lat = kwant.lattice.square(a) syst = kwant.Builder() syst[(lat(x,y) for x in range(L) for y in range(W))] = -mu * s_z + Delta * s_x syst[lat.neighbors()] = -t * s_z if (leads): lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) lead[(lat(0, j) for j in range(W))] = -mu * s_z lead[lat.neighbors()] = -t * s_z syst.attach_lead(lead) syst.attach_lead(lead.reversed()) return syst
def plot_conductance(syst, energies): data = [] for energy in energies: smatrix = kwant.smatrix(syst, energy) # Conductance is N - R_ee + R_he data.append(smatrix.submatrix(0, 0).shape[0] - smatrix.transmission(0, 0) + smatrix.transmission(1, 0)) plt.figure() plt.plot(energies, data) plt.xlabel("energy [t]") plt.ylabel("conductance [e^2/h]") plt.show()
def plot_wave_function(sys): # Calculate the wave functions in the system. ham_mat = sys.hamiltonian_submatrix(sparse=True) evecs = sla.eigsh(ham_mat, k=20, which='SM')[1]
# Plot the probability density of the 10th eigenmode. kwant.plotter.map(sys, np.abs(evecs[:, 9])**2, colorbar=False, oversampling=1)
syst = make_system() kwant.plot(syst) syst = syst.finalized() plot_conductance(syst, energies=[-0.25 + 0.005 * i for i in range(100)]) plot_wave_function(syst)
Currently, I get the error "The number of sites doesn't match the number of provided values."
Thanks, Eric
-- Abbout Adel
Thanks! Eric Mascot College of Liberal Arts Graduate Student and Sciences Department of Physics emasco2@uic.edu 845 W Taylor St M: 248 433 6435 2158 SES O: 312 413 2109 Chicago, IL 60607 On Thu, Dec 15, 2016 at 2:29 AM, Abbout Adel <abbout.adel@gmail.com> wrote:
Dear Eric,
First, import the necessary library: import scipy.sparse.linalg as sla
Then, you should notice that the dimension of your wavevector is twice the number of sites (because you have two spins).
All what you need is to plot the wave function for each spin separately by replacing your wave fucntion by:
evecs[::2, 9])**2 or by evecs[1::2, 9])**2 (each one represents a different spin.)
I hope that this helps. Adel
On Thu, Dec 15, 2016 at 7:41 AM, Eric Mascot <emasco2@uic.edu> wrote:
I am going through the tutorials and I wanted to combine two of the lessons. 2.4. Beyond transport: Band structure and closed systems 2.6. Superconductors: orbital vs. lattice degrees of freedom
In 2.4, they plot the wavefunction using kwant.plotter.map In 2.6, the system uses tinyarrays Can I combine these and plot the wavefunction using map?
Here is my code
import kwant import numpy as np import matplotlib.pyplot as plt import tinyarray as ta
s_0 = ta.array([[1, 0], [0, 1]]) s_x = ta.array([[0, 1], [1, 0]]) s_y = ta.array([[0, -1j], [1j, 0]]) s_z = ta.array([[1, 0], [0, -1]])
def make_system(a=1, L=21, W=21, t=1.0, mu=-3.618, Delta=0.1, leads=True): lat = kwant.lattice.square(a) syst = kwant.Builder() syst[(lat(x,y) for x in range(L) for y in range(W))] = -mu * s_z + Delta * s_x syst[lat.neighbors()] = -t * s_z if (leads): lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0))) lead[(lat(0, j) for j in range(W))] = -mu * s_z lead[lat.neighbors()] = -t * s_z syst.attach_lead(lead) syst.attach_lead(lead.reversed()) return syst
def plot_conductance(syst, energies): data = [] for energy in energies: smatrix = kwant.smatrix(syst, energy) # Conductance is N - R_ee + R_he data.append(smatrix.submatrix(0, 0).shape[0] - smatrix.transmission(0, 0) + smatrix.transmission(1, 0)) plt.figure() plt.plot(energies, data) plt.xlabel("energy [t]") plt.ylabel("conductance [e^2/h]") plt.show()
def plot_wave_function(sys): # Calculate the wave functions in the system. ham_mat = sys.hamiltonian_submatrix(sparse=True) evecs = sla.eigsh(ham_mat, k=20, which='SM')[1]
# Plot the probability density of the 10th eigenmode. kwant.plotter.map(sys, np.abs(evecs[:, 9])**2, colorbar=False, oversampling=1)
syst = make_system() kwant.plot(syst) syst = syst.finalized() plot_conductance(syst, energies=[-0.25 + 0.005 * i for i in range(100)]) plot_wave_function(syst)
Currently, I get the error "The number of sites doesn't match the number of provided values."
Thanks, Eric
-- Abbout Adel
participants (2)
-
Abbout Adel -
Eric Mascot