I am a PhD student of Hong Kong University of Science and Technology. I
want to use KWANT to caculate Hall resistance of a Hall bar structure.We
can get the conductance between 6 electrodes, but how to get hall
resistance? Can you give me some help? Thank you very much.
I am a B.Tech Student using Kwant for simulations.Python Version: 3.7.8
Kwant Version: 1.4.2Ubuntu 20The Error I faced is given below.
AttributeError Traceback (most recent call last)
<ipython-input-6-c80da766c4bb> in <module>
17 pyplot.ylabel("conductance [e^2/h]")
---> 19 solving(model.tokwant())
<ipython-input-6-c80da766c4bb> in solving(sys)
7 energy = ie * 0.01
8 # compute the scattering matrix at a given energy
----> 9 smatrix = kwant.greens_function(sys, energy,check_hermiticity=False)
10 # compute the transmission probability from lead 0 to
11 # lead 1
~/Downloads/112358/lib/python3.7/site-packages/kwant/_common.py in inner(*args, **kwargs)
70 if sig.bind(*args, **kwargs).arguments.get(parameter_name):
---> 72 return f(*args, **kwargs)
74 return inner
~/Downloads/112358/lib/python3.7/site-packages/kwant/solvers/common.py in greens_function(self, sys, energy, args, out_leads, in_leads, check_hermiticity, params)
485 rhs = sp.bmat([[i for i in linsys.rhs if i.shape]],
--> 487 flhs = self._factorized(linsys.lhs)
488 data = self._solve_linear_sys(flhs, rhs, kept_vars)
~/Downloads/112358/lib/python3.7/site-packages/kwant/solvers/mumps.py in _factorized(self, a)
102 def _factorized(self, a):
103 inst = mumps.MUMPSContext()
--> 104 inst.factor(a, ordering=self.ordering)
105 return inst
~/Downloads/112358/lib/python3.7/site-packages/kwant/linalg/mumps.py in factor(self, a, ordering, ooc, pivot_tol, reuse_analysis, overwrite_a)
318 row, col, data)
--> 320 self.analyze(a, ordering=ordering, overwrite_a=overwrite_a)
322 self.mumps_instance.icntl = 1 if ooc else 0
~/Downloads/112358/lib/python3.7/site-packages/kwant/linalg/mumps.py in analyze(self, a, ordering, overwrite_a)
228 if dtype != self.dtype:
--> 229 self.mumps_instance = getattr(_mumps, dtype+"mumps")(self.verbose)
230 self.dtype = dtype
AttributeError: module 'kwant.linalg._mumps' has no attribute 'dmumps'
Kindly guide me so I can overcome this error.
In the following code I have defined a three-dimensional structure.
The geometry of the lead and the scattering region are the same, but the
lead is not ploted as I expected.
I expected the lead to have a cubic structure.
What is the problem with my code?
lat = kwant.lattice.general([(0, 0.5, 0.5), (0.5, 0, 0.5), (0.5, 0.5,
[(0, 0, 10), (0.25, 0.25, 10.25)], name=['a1', 'a2'])
a1, a2 = lat.sublattices
def make_system(a=10, b=10, c=30):
syst = kwant.Builder()
x, y, z = pos
return 0 <= x < a and 0 <= y < b and 0 <= z < 10
syst[a1.shape(cuboid_shape, (0, 0, 0))] = 1
syst[a2.shape(cuboid_shape, (0, 0, 0))] = 1
syst[lat.neighbors()] = 1
x,y,z = pos
return 0 <= x < a and 0 <= y < b and 10 <= z < 25
lead = kwant.Builder(kwant.TranslationalSymmetry((0,0,1)))
lead[a1.shape(lead_shape, (0, 0, 10))] = 1
lead[a2.shape(lead_shape, (0, 0, 10))] = 1
lead[lat.neighbors()] = 1
return syst , lead
syst,lead = make_system(a=1.1, b=1.1, c=1.1)
if __name__ == '__main__':
Hi, we are 2 students at Imperial College looking to incorporate your boundstate algorithm (https://scipost.org/submissions/1711.08250v1<https://scipost.org/submissions/1711.08250v1/>) in the context of a lateral Josephson junction. The code we used was copied and pasted from here: ( https://gitlab.kwant-project.org/jbweston/kwant/-/blob/feature/boundstate/k…) As an exercise we are trying to reproduce fig. 9 in this paper. Implementing the same parameters, we managed to obtain similar graphs shown below for a value of t=0.7.
However, we notice that at some values of t, the boundstate algorithm starts yielding non-physical results. Examples include:
1. At t=-1 (which is what we assumed t to be initially from the captions in fig. 7), the algorithm returned energies above the band gap in the JJ in topological regime for some values of phi, the phase difference, and returned true values for some values of phi but not for others in the trivial regime.
1. In the B scan for t=-1 boundstates start disappearing from B=0.325 onwards, well before crossing the degeneracy point, and in the topological regime they do not line up with the band edge.
1. We also noticed that the algorithm results are dependent on the system setup. To be able to independently replicate fig. 9 my partner and I set up a 2-site (left lead - super - normal - right lead) and 3-site (left lead - super - normal - super - right lead) system respectively to implement the phase from crossing the S-N interface. A schematic of this is shown below.
3. While most standard kwant functionalities seem to recognise the 2 systems are equivalent to each other, we obtained drastically different results from the boundstate algorithm. Examples include a t-scan at B=1 to uncover possible t values where physical ABS spectra could be returned.
5. 2 site 3 site
6. (We checked that the thing causing the drastically different behaviour is the number of sites in the system. We were able to replicate each other's results only by changing the number of sites in the scattering region.)
1. We plotted f(E) in the find_boundstate function for t=-1, B=0.3 (where the algorithm succeeds in detecting the bound state) and B=0.35 (where the algorithm fails to do so), respectively. We noticed that the 2 roots from B=0.3 which are validated to be the true bound states are omitted in B=0.35, not because the validation operator rejects them, but because min_eigenvalue() (or lowest value of sparse_diag()) at these 2 energies indeed returned a value much larger than tol=1e-8 (0.003). We incremented the B field to see when the boundstate to no-boundstate transition occurs and it's at B=0.325 that the min_eigenvalue suddenly shoots up to 1e-4 (for B=0.324 we have 1e-9). We do not understand how this comes to be.
3. The above disappearance of boundstates past B=0.325 is encountered when we set sparse=False too.
We would like to know if similar problems with the boundstate algorithm have been encountered before, and if so, what do these signatures tell us is wrong, or does this indeed suggest something is incomplete in the implementation? Finally, we would also like to ask about your specific system setup in Kwant to obtain figure 9, as well as the parameter t that was used, as this was not specified explicitly. Many thanks in advance for answering our query!
Chi Zhang & Ryan Tiew
Imperial College London
I am using Kwant to study a system with both spins and electron and hole,
so the hopping matrix is 4X4. Now I want to know how to separate the spins,
electron and hole. I study this through the "2.6. Superconductors: orbital
degrees of freedom, conservation laws and symmetries"
smatrix = kwant.smatrix(syst, energy)
data.append(smatrix.submatrix((0, 0), (0, 0)).shape
-smatrix.transmission((0, 0), (0, 0)) +smatrix.transmission((0, 1), (0, 0)))
I do not find more information about this for kwant.
For my system, if I have 3 leads, and the hopping and onsite energy is set
in this order:
(e↑,0,0,0)- spin up electron,first row of the 4X4matrix
(0,e↓,0,0)- spin down electron,second row of the 4X4matrix
(0,0, h↑ ,0)- spin up hole,third row of the 4X4matrix
(0,0, 0, h ↓ )- spin down hole,fourth row of the 4X4matrix
I want to obtain the transmissions from 0 →2.
smatrix = kwant.smatrix(syst, energy)
The transmission from h↑ to e↑ is: smatrix.transmission((2, 1), (0, 2))
The transmission from h ↓ to e↑ is: smatrix.transmission((2, 1), (0, 3))
Is my understanding correct?
Thanks very much in advance!
I am somewhat new to Kwant and am trying to achieve the following:
I have a 2D 3-band continuum model that I want to see edge states of using band and density diagrams via a 1D real-space strip. I make the system finite in the x direction (implying translational symmetry in the y direction, making k_y a good quantum number and so constant). I setup the domain wall by choosing between two values for a potential, dependent on whether the site is before length/2 or after. I use kwant.continuum.discretize() for builder().
However, I am having trouble with the setup in general. For one, I cannot seem to apply translational symmetry to builder() because I am not sure what vector to use (I tried (0,1) and (1,0)), but to no avail. Second, if I proceed without translational symmetry, kwant.plotter.bands(syst, show=False) gives me "TypeError: Expecting an instance of InfiniteSystem." When I browsed the email archives, people suggested syst.leads, etc: but the issue is that I don't have these leads explicitly and that gives me an error. My understanding is that I can get a proper band diagram showing edge states if I plot eigenvalues from looping through different values of k_y that I fixed earlier. However, I don't think I saw examples of the Kwant examples doing it this way.
So, it seems as if I have confused some basic applications in Kwant. Would someone mind clarifying my confusions for me? All I want to see is the a typical band structure diagram for this 3-band continuum model in a domain wall setup. Following is my code (I know that the given Hamiltonian will not give edge states, but I just want to get the code working for starters). Thank you for your time!
# Minimal example
import numpy as np
import matplotlib.pyplot as plt
lat_const = 3.19 # lattice constant
hami = """
[[2* t0 * ((1-(2*((1/2)*k_x*a))**2/2)+2*(1-(((1/2)*k_x*a))**2/2)*(1-((momentumY*a*sqrt(3)/2))**2/2))+e1,
M1(x,y)-2*sqrt(3)*t2*(((1/2)*k_x*a))*((momentumY*a*sqrt(3)/2)) + 2*1j*t1*((2*((1/2)*k_x*a)) + (((1/2)*k_x*a))*(1-((momentumY*a*sqrt(3)/2))**2/2)),
2*t2*((1-(2*((1/2)*k_x*a))**2/2) - (1-(((1/2)*k_x*a))**2/2)*(1-((momentumY*a*sqrt(3)/2))**2/2)) + 2*sqrt(3)*1j*t1*(1-(((1/2)*k_x*a))**2/2)*((momentumY*a*sqrt(3)/2))],
[-M1(x,y)-2*sqrt(3)*t2*(((1/2)*k_x*a))*((momentumY*a*sqrt(3)/2)) - 2*1j*t1*((2*((1/2)*k_x*a)) + (((1/2)*k_x*a))*(1-((momentumY*a*sqrt(3)/2))**2/2)),
2*t11*(1-(2*((1/2)*k_x*a))**2/2) + (t11+3*t22)*(1-(((1/2)*k_x*a))**2/2)*(1-((momentumY*a*sqrt(3)/2))**2/2)+e2,
[2*t2*((1-(2*((1/2)*k_x*a))**2/2) - (1-(((1/2)*k_x*a))**2/2)*(1-((momentumY*a*sqrt(3)/2))**2/2)) - 2*sqrt(3)*1j*t1*(1-(((1/2)*k_x*a))**2/2)*((momentumY*a*sqrt(3)/2)),
2*t22*(1-(2*((1/2)*k_x*a))**2/2) + (3*t11+ t22)*(1-(((1/2)*k_x*a))**2/2)*(1-((momentumY*a*sqrt(3)/2))**2/2)+e2]]
template = kwant.continuum.discretize(hami, grid = lat_const)
L = 100
(x, ) = site.pos
val1 = 10.07822923*1j
val2 = 12.42088476*1j
syst = kwant.Builder();
syst = syst.finalized();
ham = syst.hamiltonian_submatrix(params=dict(M1=pot1,M2=pot2, momentumY = momY, y=0, a = 3.19, e1 = 1.046, e2 = 2.104, t0 = -0.184, t1 = 0.401, t2 = 0.507, t11 = 0.218, t12 = 0.338, t22 = 0.057),sparse = False)
#plt.spy(ham) #block off-diagonal
# Band structure diagram???
# different momentumY's to iterate over
v1=-2*np.pi; v2=2*np.pi; v_segs=10;
vary_range = np.linspace(v1, v2, num=v_segs) # np.linspace(kx0_1, kx0_2, num=kx_segs, retstep=True)
for i in range(v_segs):
ham = get_ham(vary_range[i])
ev,evecs = scipy.linalg.eigh(ham)
plt.plot(ev) # plot eigenvalues
# Wavefunction density diagram??? Should show peak at edge states, if there are any.
for i in range(v_segs):
ham = get_ham(vary_range[i])
ev,evecs = scipy.linalg.eigh(ham)
wavefunction = evecs[:, len(ham)-1]
up,middle,down = wavefunction[::3],wavefunction[1::3],wavefunction[2::3]
density = np.abs(up)**2 + np.abs(middle)**2 + np.abs(down)**2
##kwant.plotter.map(syst, density, show=False)
Hello Kwant Community,
I created a 3D nanowire grown along x direction with leads attached in the x direction and want to plot the current density profile through a cut at a x = const plane.
I think this Problem was never really solved in the public community communication channels, and personally I think this is quiet useful, because people might want to show surface currents of TI's etc.
I created a minimal example displaying two methods to calculate and display the current density through a plane x = const:
see my jupyter notebook on GitHub:
There at "# current density through x=const plane METHOD 1":
I build a 2D slice of the 3D nanowire and use kwant.operator.Current(fsyst, where=cut) and specifying for which hoppings in should calculate the current density:
return site0.pos==x_cut and site1.pos==x_cut+1 # calculating current just for this x hopping
This yields a current density profil with only non negativ current densities even if I have no magnetic field, hence this somehow breaks time reversal symmetry.
If I instead define
return site0.pos==x_cut+1 and site1.pos==x_cut # calculating current just for this x hopping
I get the same picture except that the sign changed completely.
"# current density through plane x = const METHOD 2
Here I use kwant.operator.Current(fsyst), and calculate the current density over all hoppings of the system. Then I use kwant.plotter.interpolate_current(fsyst, current_density) to interpolate
the current density vectorfield which returns it as field, box.
In a simple inefficient for loop I then create an array of y_vals and z_vals and their corresponding current density z (2) component values = values.append(field[x_cut,ny,nz,2]) at x = x_cut.
This yields a current density profile which seems to respect time reversal symmetry (vanishes when B = 0) is non zero when B != 0 but because no bias is applied integration over the plain yields zero
I think this might be a correct implementation. But I am really not sure because I don't know what I might did wrong in the first implementation.
raise RuntimeError("Numbers of left- and right-propagating "
RuntimeError: Numbers of left- and right-propagating modes differ, possibly due to a numerical instability.
I am getting the above error message while doing transport calculations in Silicene(next nearest neighbour hopping due to intrinsic SO). But it disappears when I set the the intrinsic SO to zero. What could be the possible reason.
Thanks and Regards,
Hi! I'm new at kwant, can anyone help me with my problem. Is it possible to get SdH oscillation for layered system with kwant? There is two type of layers in the system, normal insulators and topological insulators with edge states and we build a system by alternating different types of layers, and there is hopping between edge states through normal insulator layer (Burkov model - https://journals.aps.org/prb/abstract/10.1103/PhysRevB.85.165110 ). It will be very nice if someone give me advice