Fwd: Visualize current through a 2D cut for a 3D system
So, for example, I can print the on-site energies or the hopping integrals of the sites I want using: ----- print(kwant_sys[lattice.sublattices[4](0,0,-1)) and print(kwant_sys[lattice.sublattices[4](0,0,-1), lattice.sublattices[6](0,0,-1)]) ----- respectively. I can get the tags and families of the sites as such: -----
for x in kwant_sys.sites(): ... print(x.tag, ',', x.family) ... [0 0 -1] , <Monatomic lattice 0> [0 0 -1] , <Monatomic lattice 1> ....
However, I am still unsure about the 'where' argument -------------------------------------------------------------------------------------------------
J = kwant.operator.Current(kwant_sys, where=kwant_sys[lattice.sublattices[4](0,0,-1), lattice.sublattices[6](0,0,-1)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "kwant/operator.pyx", line 883, in kwant.operator.Current.__init__ File "kwant/operator.pyx", line 217, in kwant.operator._normalize_hopping_where File "kwant/operator.pyx", line 218, in genexpr ValueError: need more than 1 value to unpack J = kwant.operator.Current(kwant_sys, where=(lattice.sublattices[4](0,0,-1), lattice.sublattices[6](0,0,-1))) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "kwant/operator.pyx", line 883, in kwant.operator.Current.__init__ File "kwant/operator.pyx", line 223, in genexpr File "kwant/operator.pyx", line 223, in genexpr AttributeError: 'Builder' object has no attribute 'graph'
-------------------------------------------------------------------------------------------------- Eleni ----- Forwarded message from elchatz@auth.gr ----- Date: Mon, 26 Mar 2018 17:19:18 +0300 From: elchatz@auth.gr Subject: Re: [Kwant] Visualize current through a 2D cut for a 3D system To: kwant-discuss@kwant-project.org Hello Anton, Thank you very much for your reply. I am having a hard time with the "where" argument in kwant.operator.Current. My system is not finalized. How can I find the sites associated with the hopping? By their tag? Their position? Do you have a piece of code for that? Note that I am using TBModels and Wannier90 and the lattice has one sublattice for each WF (or site, or orbital). norb is not defined, but I see that for x in lattice.sublattices: x.norbs=1 works and looks correct. Regards, Eleni Quoting Anton Akhmerov <anton.akhmerov+kd@gmail.com>:
Dear Eleni,
I think this should be doable with not too much of low level work. * Firstly you probably will want to select only the hoppings that are close to the 2D cut. You can do this by using "where" parameter to Current operator (see https://kwant-project.org/doc/1/reference/generated/kwant.operator.Current#k...) * After computing the current across those hoppings, you would need to call kwant.plotter.interpolate_current. This function only does the interpolation, but no plotting. Having that interpolation in 3D you need to slice it and probably take a projection onto 2D plane. * Finally, the resulting 2D array you can feed to kwant.plotter.streamplot
kwant.plotter.current is essentially a straightforward combination of kwant.plotter.interpolate_current and kwant.plotter.streamplot
Also: your problem sounds like a useful thing to do. Please let me know if you succeed, and what you ended up doing (or if you face any further problems as well).
Best, Anton
On Fri, Mar 23, 2018 at 5:22 PM, <elchatz@auth.gr> wrote:
Hello everyone,
Is there currently way to visualize the current through a 2D cut for a 3D system that does not involve messing with the kwant code?
I have a 3D system and would like to see the differences in the current when I switch some specific hoppings on and off.
Regards,
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109 ----- End forwarded message ----- -- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
Hi,
So, for example, I can print the on-site energies or the hopping integrals of the sites I want using:
..
However, I am still unsure about the 'where' argument
-------------------------------------------------------------------------------------------------
J = kwant.operator.Current(kwant_sys, where=kwant_sys[lattice.sublattices[4](0,0,-1), lattice.sublattices[6](0,0,-1)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "kwant/operator.pyx", line 883, in kwant.operator.Current.__init__ File "kwant/operator.pyx", line 217, in kwant.operator._normalize_hopping_where File "kwant/operator.pyx", line 218, in genexpr ValueError: need more than 1 value to unpack J = kwant.operator.Current(kwant_sys, where=(lattice.sublattices[4](0,0,-1), lattice.sublattices[6](0,0,-1))) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "kwant/operator.pyx", line 883, in kwant.operator.Current.__init__ File "kwant/operator.pyx", line 223, in genexpr File "kwant/operator.pyx", line 223, in genexpr AttributeError: 'Builder' object has no attribute 'graph'
There are 2 problems here: 1. 'where' expects a *sequence* of places where you would like to evaluate the current. In your code snippet you pass the value function associated with some hopping. Using your example this would be something like this: lat1 = lattice.sublattices[4] lat2 = lattice.sublattices[6] J = kwant.operator.Current(syst, where=[(lat1(0, 0, -1), lat2(0, 0, -1))]) 2. 'Current' expects a *finalized* system, but you pass it an *unfinalized* system (Kwant calls this a "Builder"). Does that make sense? Can you also please point me to where you looked in the documentation and explain which bits were confusing? This will help us improve the documentation! Happy Kwanting, Joe
Hello Joseph, Thank you! I had finalized my system, but I was giving as input the unfinalized one. :S I was reading from here: https://kwant-project.org/doc/1/reference/generated/kwant.operator.Current#k... ---------------------------- where : sequence of pairs of int or Site, or callable, optional Where to evaluate the operator. If syst is not a finalized Builder, then this should be a sequence of pairs of integers. If a function is provided, it should take a pair of integers or a pair of Site (if syst is a finalized builder) and return True or False. If not provided, the operator will be calculated over all hoppings in the system. ---------------------------- I think this should be clear to someone with more experience with python. Eleni Quoting Joseph Weston <joseph.weston08@gmail.com>:
Hi,
So, for example, I can print the on-site energies or the hopping integrals of the sites I want using:
..
However, I am still unsure about the 'where' argument
-------------------------------------------------------------------------------------------------
J = kwant.operator.Current(kwant_sys, where=kwant_sys[lattice.sublattices[4](0,0,-1), lattice.sublattices[6](0,0,-1)]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "kwant/operator.pyx", line 883, in kwant.operator.Current.__init__ File "kwant/operator.pyx", line 217, in kwant.operator._normalize_hopping_where File "kwant/operator.pyx", line 218, in genexpr ValueError: need more than 1 value to unpack J = kwant.operator.Current(kwant_sys, where=(lattice.sublattices[4](0,0,-1), lattice.sublattices[6](0,0,-1))) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "kwant/operator.pyx", line 883, in kwant.operator.Current.__init__ File "kwant/operator.pyx", line 223, in genexpr File "kwant/operator.pyx", line 223, in genexpr AttributeError: 'Builder' object has no attribute 'graph'
There are 2 problems here:
1. 'where' expects a *sequence* of places where you would like to evaluate the current. In your code snippet you pass the value function associated with some hopping. Using your example this would be something like this:
lat1 = lattice.sublattices[4] lat2 = lattice.sublattices[6] J = kwant.operator.Current(syst, where=[(lat1(0, 0, -1), lat2(0, 0, -1))])
2. 'Current' expects a *finalized* system, but you pass it an *unfinalized* system (Kwant calls this a "Builder").
Does that make sense? Can you also please point me to where you looked in the documentation and explain which bits were confusing? This will help us improve the documentation!
Happy Kwanting,
Joe
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
participants (2)
-
elchatz@auth.gr
-
Joseph Weston