Hey Anton, I should have thought of the physics behind my hopping values when calling the conservation law I have used realistic hopping values instead of np.eye(2, 6) and it is working now. Regards, Adel
Le dim. 15 août 2021 à 14:43, Anton Akhmerov <anton.akhmerov...@gmail.com> a écrit : > Hi Adel, > > Running the code you provided also produces the following warning. > > > UserWarning: Hamiltonian breaks Conservation law, ignoring the symmetry > in the computation. > > This should explain what is happening. > > Best, > Anton > > On Sun, 15 Aug 2021 at 14:19, Adel Belayadi <adelp...@gmail.com> wrote: > > > > Dear Anton; > > > > Thank you for your reply > > > > I have used the conservation_law as you have suggested. In fact, a > dictionary or function definition of the conservation law is working fine > now. I am not getting an error while defining the conservation law. > However, when calling smatrix.transmission((1, 1), (0, 1)) which stands > for spin up-up transmittance it raises: index 2 is out of bounds for axis 0 > with size 2. > > > > Please see for example the following script which have two site > families, one with 2 orbitals and the second with 6 orbitals > > > > Cheers, Adel > > > > > > import kwant > > from matplotlib import pyplot > > import numpy as np > > from math import sqrt > > lat = kwant.lattice.honeycomb(a=1, norbs=[2, 6] , name=["a", "b"]) > > a, b =lat.sublattices > > def make_sys(l, w, cons_law): > > def rect(pos): > > x, y = pos > > return abs(x) < l and abs(y) < w > > sys=kwant.Builder() > > sys[a.shape(rect, (0, 0))] = np.eye(2) > > sys[b.shape(rect, (0, 0))] = np.eye(6) > > ab_hopps= (((0, 0), a, b), ((0, 1), a, b), ((-1, 1), a, b)) > > sys[[kwant.builder.HoppingKind(*hopping) for hopping in ab_hopps]] = > np.eye(2,6) > > sys.eradicate_dangling() > > sys[a.neighbors(1)] = np.eye(2) > > sys[b.neighbors(1)] = np.eye(6) > > ### creating leads > > def lead_shape(pos): > > x, y = pos > > return abs(y)< w > > sym = kwant.TranslationalSymmetry(lat.vec((-1, 0))) > > sym.add_site_family(lat.sublattices[0], other_vectors=[(-1, 2)]) > > sym.add_site_family(lat.sublattices[1], other_vectors=[(-1, 2)]) > > lead = kwant.Builder(sym, conservation_law=cons_law) > > lead[a.shape(rect, (0, 0))] = np.eye(2) > > lead[b.shape(rect, (0, 0))] = np.eye(6) > > lead[[kwant.builder.HoppingKind(*hopping) for hopping in ab_hopps]] > = np.eye(2,6) > > lead.eradicate_dangling() > > lead[a.neighbors(1)] = np.eye(2) > > lead[b.neighbors(1)] = np.eye(6) > > sys.attach_lead(lead) > > sys.attach_lead(lead.reversed()) > > return sys > > > > > > syst = make_sys(l=3, w=2, cons_law= None) > > kwant.plot(syst ,fig_size=(8, 8)) > > pyplot.show() > > > > print('************ calling the conservation law **************') > > sigma_z = np.array([[1, 0], [0, -1]]) > > cons_law = {a: -sigma_z , b: -np.kron(sigma_z, np.eye(3))} > > syst = make_sys(l=3, w=2, cons_law=cons_law) > > smatrix = kwant.smatrix(syst.finalized(), 0.01) > > total_trans = smatrix.transmission(1, 0) > > up_up_trans = smatrix.transmission((1, 0), (0, 0)) > > dn_dn_trans = smatrix.transmission((1, 1), (0, 1)) > > up_dn_trans = smatrix.transmission((1, 1), (0, 0)) > > dn_up_trans = smatrix.transmission((1, 0), (0, 1)) > > print(total_trans) > > print(up_up_trans) > > print(dn_dn_trans) > > print(up_dn_trans) > > print(dn_up_trans) > > print(round(total_trans, > 3)==round(up_up_trans+dn_dn_trans+up_dn_trans+dn_up_trans, 3)) > > > > > > > > Le sam. 14 août 2021 à 17:06, Anton Akhmerov < > anton.akhmerov...@gmail.com> a écrit : > >> > >> Hi Adel, > >> > >> Please check the documentation [1]. Since you have multiple site > >> families, you need to specify the conservation law as a dictionary, so > >> {metal_like_sub: -np.kron(sigma_z, np.eye(3)), C_like_sub1: -sigma_z, > >> C_like_sub2: -sigma_z}. > >> > >> Best, > >> Anton > >> > >> > https://kwant-project.org/doc/1/reference/generated/kwant.builder.Builder#kwant.builder.Builder > >> > >> On Sat, 14 Aug 2021 at 16:08, Adel Belayadi <adelp...@gmail.com> wrote: > >> > > >> > Dear Kwant user, > >> > Good day and I hope this email finds you well. > >> > Using conservation law was fully explained, in the Kwant mailing > list, while we are having sublattices with the same degree of freedom (same > number of orbitals). For instance, if we have two sites with 3 orbitals in > the case of a spin full Hamiltonian, the onsite matrix is > (onsite_matrix(6*6) for each site ). So in this case, the conservation law > will be straightforward: conservation_law=-np.kron(sigma_z, np.eye(3)).But > what would be the case if we are dealing with sublattices which have > different numbers of orbitals? > >> > > >> > In my case, I am interested in spin conductance. I am using 3 > sublattices with different orbitals. Let us say for instance > >> > sublattice0 has (6-orbitals), sublattice1 with (2-orbitals) and > sublattice2 with (2-orbitals). In fact I am working on hetero-structure > with two sites of C-like(pz with spin up and down) and one site of > metal-like(3d-orbitals with spin up and down). I can resume my lattice as > follow > >> > > >> > lat = kwant.lattice.general(prim_vecs, basis=[ [...], [...], [...]] , > norbs=[6, 2, 2]) > >> > metal-like_sub, C-like_sub1, C-like_sub2 = lat.sublattices > >> > > >> > According to my understanding the conservation law would be something > like > >> > conservation_law=-np.kron(sigma_z, np.eye(5)). However Kwant raises > an error with my choice of the conservation law. > >> > > >> > Is there something missing with my understanding of the conservation > law!. Or in the case of different orbitals per site, we need to define two > lattices (lattice1 for spin up and lattice2 for spindown). > >> > Thanks in advance, > >> > Best > >> > > >> > > >> > >