Thanks Anton, I solved the problem using the following procedure. Maybe it is useful for someone:
def plot_vector_field(sys, Maj_x, Maj_y): x = np.zeros(len(sys.sites)) y = np.zeros(len(sys.sites)) for s in range(len(sys.sites)): x[s], y[s] = sys.pos(s) plt.quiver(x, y , Maj_x, Maj_y, scale = 50) plt.xlim(-200,300) plt.ylim(-200,300) plt.show() 2017-10-31 17:59 GMT-02:00 Anton Akhmerov <[email protected]>: > Hi Antonio. > > I imagine you could evaluate that vector field at the positions of the > lattice sites and then feed it to an interpolation routine. > > Best, > Anton > > On Tue, Oct 31, 2017 at 12:35 PM, Antonio Lucas Rigotti Manesco > <[email protected]> wrote: > > Hi, > > > > As Majorana polarization is a vector field, I am trying to plot the > values > > using quiver by adding the two functions: > > > > def plot_vector_field(sys, Maj_x, Maj_y): > > xmin, ymin = min(s.tag for s in sys.sites) > > xmax, ymax = max(s.tag for s in sys.sites) > > x, y = np.meshgrid(np.arange(xmin, xmax+1), np.arange(ymin, ymax+1)) > > > > plt.quiver(x, y, Maj_x, Maj_y) > > plt.show() > > > > def majorana_polarization(sys, energy): > > wf = kwant.wave_function(sys, energy) > > psi = wf(0) > > eup, edown, hup, hdown = psi[::2], psi[1::2], psi[3::2], - psi[2::2] > > Maj = eup * hup + edown * hdown > > print(Maj) > > Maj_x = np.real(Maj) > > Maj_y = np.imag(Maj) > > plot_vector_field(sys, Maj_x, Maj_y) > > > > But since I am dealing with a honeycomb lattice the meshgrid will not > work. > > How could I generate that using the sys sites? > > > > 2017-10-30 19:10 GMT-02:00 Anton Akhmerov <[email protected]>: > >> > >> Dear Antonio, > >> > >> In Kwant 1.3 you can compute expectation values of any local operator, > >> applied to any wave function, as described in this Kwant tutorial: > >> https://kwant-project.org/doc/1/tutorial/operators > >> > >> It is also possible that you can compute what you want using the > >> output of ldos. The ordering of internal degrees of freedom of each > >> there is the same as in the Hamiltonian you define. > >> > >> Best, > >> Anton > >> > >> On Mon, Oct 30, 2017 at 9:44 PM, Antonio Lucas Rigotti Manesco > >> <[email protected]> wrote: > >> > Dear Kwant users, > >> > > >> > I am interested to calculate Majorana polarization for a system I am > >> > currently studying. I was wondering if it is possible to obtain it > from > >> > kwant.ldos. The system is constructed as a kronecker product between > >> > particle-hole and spin in that order but I am not sure how kwant.ldos > >> > orders the internal degrees of freedom. Does any of you have some hint > >> > about > >> > that? > >> > > >> > Thanks in advance. > > > > > > > > > > -- > > Antônio Lucas Rigotti Manesco > > PhD fellow - University of São Paulo, Brazil > -- Antônio Lucas Rigotti Manesco PhD fellow - University of São Paulo, Brazil
