Dear KWANT developers, I have an Hamiltonian *H(k) = tx*σx* sin kx + ty*σy*sin ky + mk*σz + λ*σ0 *sin kz,* *mk = tz(cos β − cos kz) + t'(2 − cos kx − cos ky)* I am trying to introduce magnetic field in *x-direction* for a gauge *A = (0, 0, By),* Can I make a *template* for this hamiltonian using KWANT discretizer or I have to discretize it by hand to get the onsite and hopping matrix? If I have to discretize it by hand then how should I proceed for that. And then how to add the peierls phase to the hopping matrix? Then I want to plot the spectrum as a function of k_z, with Wx =10 and Wy=50 Could you please help me, I tried a lot but failed. Thanks in advance. Naveen
Hi, On 5/5/19 1:08 PM, Naveen Yadav wrote:
Dear KWANT developers,
I have an Hamiltonian *H(k) = tx*σx* sin kx + ty*σy*sin ky + mk*σz + λ*σ0 *sin kz,* * * *mk = tz(cos β − cos kz) + t'(2 − cos kx − cos ky)* **
I am trying to introduce magnetic field in *x-direction* for a gauge *A = (0, 0, By),* Can I make a *template* for this hamiltonian using KWANT discretizer or I have to discretize it by hand to get the onsite and hopping matrix?
I already answered this question in the previous thread. The Hamiltonian is essentially already discretized; you just have to identify which terms are onsites and which are hoppings. See the previous thread.
And then how to add the peierls phase to the hopping matrix?
For the gauge you have chosen the peierls phase will be non-zero only on hoppings in the z direction. You can specify these hoppings as a function and multiply the hopping by exp(2 * pi * 1j * B * a * y) where "a" is the lattice discretization length and "y" is the y position of the sites at either end of the hopping (will be the same for both sites, as we only apply this phase to hoppings in the z-direction).
Then I want to plot the spectrum as a function of k_z, with Wx =10 and Wy=50
The resulting Hamiltonian will be a function of k_z. You can use kwant.plotter.spectrum to plot the spectrum as a function of k_z. Happy Kwanting, Joe
Dear Joseph,
The resulting onsite and hopping terms as I found are:
Onsite: (tz *cos(/beta) +2t')*sigma_z
Hopping in x direction: -t'/2 *sigma_z - i tx/2 *sigma_x
Hopping in y direction: -t'/2 *sigma_z - i tx/2 *sigma_y
Hopping in z direction: -tz/2 *sigma_z - i lamda/2 *sigma_0
Then as you said I have to multiply the hopping in z direction by exp(2 *
pi * 1j * B * a* y). But how can I build a 3D system from here. I know
that 2D systems can be written as *lat = kwant.lattice.square(a), *but I
don't know how should I proceed to bulid a lattice in 3D using the above
onsite and hoppings? Please help me regarding this.
Thanks for your help.
Naveen
Department of Physics & Astrophysics
University of Delhi
New Delhi-110007
On Mon, May 6, 2019, 13:18 Joseph Weston
Hi, On 5/5/19 1:08 PM, Naveen Yadav wrote:
Dear KWANT developers,
I have an Hamiltonian *H(k) = tx*σx* sin kx + ty*σy*sin ky + mk*σz + λ*σ0 *sin kz,*
*mk = tz(cos β − cos kz) + t'(2 − cos kx − cos ky)*
I am trying to introduce magnetic field in *x-direction* for a gauge *A = (0, 0, By),* Can I make a *template* for this hamiltonian using KWANT discretizer or I have to discretize it by hand to get the onsite and hopping matrix?
I already answered this question in the previous thread. The Hamiltonian is essentially already discretized; you just have to identify which terms are onsites and which are hoppings. See the previous thread.
And then how to add the peierls phase to the hopping matrix?
For the gauge you have chosen the peierls phase will be non-zero only on hoppings in the z direction. You can specify these hoppings as a function and multiply the hopping by exp(2 * pi * 1j * B * a * y) where "a" is the lattice discretization length and "y" is the y position of the sites at either end of the hopping (will be the same for both sites, as we only apply this phase to hoppings in the z-direction).
Then I want to plot the spectrum as a function of k_z, with Wx =10 and Wy=50
The resulting Hamiltonian will be a function of k_z. You can use kwant.plotter.spectrum to plot the spectrum as a function of k_z.
Happy Kwanting,
Joe
Then as you said I have to multiply the hopping in z direction by exp(2 * pi * 1j * B * a* y). But how can I build a 3D system from here. I know that 2D systems can be written as *lat = kwant.lattice.square(a), *but I don't know how should I proceed to bulid a lattice in 3D using the above onsite and hoppings? Please help me regarding this.
The tutorials explain how to make lattices in arbitrary numbers of dimensions. How about making a cubic lattice in 3D? Happy Kwanting, Joe
Thanks, I'll check it out.
Naveen
Department of Physics & Astrophysics
University of Delhi
New Delhi-110007
On Mon, May 6, 2019, 15:10 Joseph Weston
Then as you said I have to multiply the hopping in z direction by exp(2 * pi * 1j * B * a* y). But how can I build a 3D system from here. I know that 2D systems can be written as *lat = kwant.lattice.square(a), *but I don't know how should I proceed to bulid a lattice in 3D using the above onsite and hoppings? Please help me regarding this.
The tutorials explain how to make lattices in arbitrary numbers of dimensions. How about making a cubic lattice in 3D?
Happy Kwanting,
Joe
Dear Joseph,
As per your instructions I have build the system, but the code is not
giving the desired result.
Here is the code please have a look on it.
import kwant
import matplotlib.pyplot as plt
import tinyarray
import numpy as np
from numpy import cos, sin, pi
import cmath
from cmath import exp
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]])
def make_system(a=1, L=10, W=50, H=5, t=1.0, t_x=1.0, t_y=1.0, t_z=1.0,
lamda=0.2, beta=1.05, B=0, y=1):
def onsite(site):
return (1.0 * cos(beta) + 2 * 1.0) * sigma_z
def hoppingx(site0, site1):
return -0.5 * t * sigma_z - 0.5 * 1j * t_x * sigma_x
def hoppingy(site0, site1):
return -0.5 * t_z * sigma_z - 0.5 * 1j * t_y * sigma_y
def hoppingz(site0, site1):
return (-0.5 * t_z * sigma_z - 0.5 * 1j * lamda * sigma_0) * exp(2
* pi * 1j * B * a * y)
syst = kwant.Builder()
lat = kwant.lattice.cubic(a)
syst[(lat(z, y, x) for z in range(H) for y in range(W) for x in
range(L))] = onsite
syst[kwant.builder.HoppingKind((1, 0, 0), lat, lat)] = hoppingx
syst[kwant.builder.HoppingKind((0, 1, 0), lat, lat)] = hoppingy
syst[kwant.builder.HoppingKind((0, 0, 1), lat, lat)] = hoppingz
lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0, 0)))
lead[(lat(z, y, x) for z in range(H) for y in range(W) for x in
range(L))] = onsite
lead[kwant.builder.HoppingKind((1, 0, 0), lat, lat)] = hoppingx
lead[kwant.builder.HoppingKind((0, 1, 0), lat, lat)] = hoppingy
lead[kwant.builder.HoppingKind((0, 0, 1), lat, lat)] = hoppingz
syst.attach_lead(lead)
syst.attach_lead(lead.reversed())
syst = syst.finalized()
return syst
def analyze_system():
syst = make_system()
kwant.plot(syst)
kwant.plotter.bands(syst.leads[0],
momenta=np.linspace(-3, 3, 201), show=False)
plt.grid()
plt.xlim(-3, 3)
plt.ylim(-0.2, 0.2)
plt.xlabel('momentum [1/A]')
plt.ylabel('energy [E]')
plt.show()
analyze_system()
best regards,
Naveen
On Mon, May 6, 2019 at 3:12 PM Naveen Yadav
Thanks, I'll check it out.
Naveen Department of Physics & Astrophysics University of Delhi New Delhi-110007
On Mon, May 6, 2019, 15:10 Joseph Weston
wrote: Then as you said I have to multiply the hopping in z direction by exp(2 * pi * 1j * B * a* y). But how can I build a 3D system from here. I know that 2D systems can be written as *lat = kwant.lattice.square(a), *but I don't know how should I proceed to bulid a lattice in 3D using the above onsite and hoppings? Please help me regarding this.
The tutorials explain how to make lattices in arbitrary numbers of dimensions. How about making a cubic lattice in 3D?
Happy Kwanting,
Joe
-- With Best Regards NAVEEN YADAV Ph.D Research Scholar Deptt. Of Physics & Astrophysics University Of Delhi.
Dear Joseph,
As per your instructions I have build the system, but the code is not giving the desired result. Here is the code please have a look on it.
'y' should be the y position of the sites of the hopping, not an input parameter to the system construction: def hoppingz(site0, site1): y = site0.pos[1] ... Happy Kwanting, Joe
That is okay, but still something wrong.
Naveen
Department of Physics & Astrophysics
University of Delhi
New Delhi-110007
On Tue, May 7, 2019, 13:29 Joseph Weston
Dear Joseph,
As per your instructions I have build the system, but the code is not giving the desired result. Here is the code please have a look on it.
'y' should be the y position of the sites of the hopping, not an input parameter to the system construction:
def hoppingz(site0, site1):
y = site0.pos[1]
...
Happy Kwanting,
Joe
And also, when I am plotting the spectrum in varing magnetic field with the
hamiltonian as a sparse matrix. I am getting an value error.
*ValueError: x and y must have same first dimension, but have shapes
(100,) and (1, 15)*
I don't know what does it mean?
*def plot_spectrum(syst, Bfields): energies = [] for B in
Bfields: ham_mat =
syst.hamiltonian_submatrix(params=dict(B=B), sparse=True) ev =
sla.eigsh(ham_mat.tocsc(), k=15, sigma=0,
return_eigenvectors=False) energies.append(ev) pyplot.figure()
pyplot.plot(Bfields, energies) pyplot.xlabel("magnetic field [arbitrary
units]") pyplot.ylabel("energy [t]") pyplot.show()*
*plot_spectrum(syst, [iB * 0.002 for iB in range(100)])*
Best regards,
Naveen
On Tue, May 7, 2019 at 1:35 PM Naveen Yadav
That is okay, but still something wrong.
Naveen Department of Physics & Astrophysics University of Delhi New Delhi-110007
On Tue, May 7, 2019, 13:29 Joseph Weston
wrote: Dear Joseph,
As per your instructions I have build the system, but the code is not giving the desired result. Here is the code please have a look on it.
'y' should be the y position of the sites of the hopping, not an input parameter to the system construction:
def hoppingz(site0, site1):
y = site0.pos[1]
...
Happy Kwanting,
Joe
-- With Best Regards NAVEEN YADAV Ph.D Research Scholar Deptt. Of Physics & Astrophysics University Of Delhi.
And also, when I am plotting the spectrum in varing magnetic field with the hamiltonian as a sparse matrix. I am getting an value error. *ValueError: x and y must have same first dimension, but have shapes (100,) and (1, 15) * I don't know what does it mean?
*def plot_spectrum(syst, Bfields): energies = [] for B in Bfields: ham_mat = syst.hamiltonian_submatrix(params=dict(B=B), sparse=True) ev = sla.eigsh(ham_mat.tocsc(), k=15, sigma=0, return_eigenvectors=False) energies.append(ev) pyplot.figure() pyplot.plot(Bfields, energies) pyplot.xlabel("magnetic field [arbitrary units]") pyplot.ylabel("energy [t]") pyplot.show()* *plot_spectrum(syst, [iB * 0.002 for iB in range(100)])*
The error message seems pretty clear to me; I am not sure where the confusion is, especially as the traceback will point to the exact line in the code where the error occurs. If I were you I would first take the time to really look at the code that you are writing and understanding what it is doing. Remember that this is not a general mailing list for coding help: it is specifically for asking questions about Kwant. Happy Kwanting, Joe
Thank you for the clarification.
Naveen
Department of Physics & Astrophysics
University of Delhi
New Delhi-110007
On Tue, May 7, 2019, 15:04 Joseph Weston
And also, when I am plotting the spectrum in varing magnetic field with the hamiltonian as a sparse matrix. I am getting an value error.
*ValueError: x and y must have same first dimension, but have shapes (100,) and (1, 15) *
I don't know what does it mean?
*def plot_spectrum(syst, Bfields): energies = [] for B in Bfields: ham_mat = syst.hamiltonian_submatrix(params=dict(B=B), sparse=True) ev = sla.eigsh(ham_mat.tocsc(), k=15, sigma=0, return_eigenvectors=False) energies.append(ev) pyplot.figure() pyplot.plot(Bfields, energies) pyplot.xlabel("magnetic field [arbitrary units]") pyplot.ylabel("energy [t]") pyplot.show()* *plot_spectrum(syst, [iB * 0.002 for iB in range(100)])*
The error message seems pretty clear to me; I am not sure where the confusion is, especially as the traceback will point to the exact line in the code where the error occurs. If I were you I would first take the time to really look at the code that you are writing and understanding what it is doing. Remember that this is not a general mailing list for coding help: it is specifically for asking questions about Kwant.
Happy Kwanting,
Joe
That is okay, but still something wrong.
Well I am afraid that the only way to proceed is for you to look closely at what you have implemented, and what is written in the paper and see where there is a discrepancy. You could also ask the authors for the code that they used to produce the images (usually it is good practice to publish the code that produced figures with a manuscript). Happy Kwanting, Joe
participants (2)
-
Joseph Weston
-
Naveen Yadav