Dear Felix,

I understood the way you did in method one and it seems fine.
For the second method, although the general idea seems correct, I doubt the accuracy of the way you handle it.

You wrote :                           field[x_cut,ny,nz,0]) # field at n_x = x_cut, iterating through ny, nz and adding just Jx

The shape of "Field" is not very clear to me. I do not understand exactly how it depends on the parameter n  (the default value is n=9) in the documentation. So, it is not good to put x_cut  as a first index since the shape of "field" changes with n. The last parameter should not refer to Jx or any other component. It seems that it depends on the dimension of the system. (You can check this function with a spinless model, in 2D and 3D) 
Probably @Christoph Groth (or another person) can better explain this since the documentation is poor about this function.

I hope this helps,
Adel



On Mon, Jun 14, 2021 at 12:57 PM <felixmende2@web.de> wrote:
Dear Adel,

Thank you for your quick reply and also for providing some example code!

You created a 3D system, then a 2D system with same in plane hoppings (2d plane cut trough the wire)
and the projected the in plane current density onto these hoppings via kwant.plotter.current.

What I want is not displaying the in plane current, but the current density penetrating the 2D cut.
Following the Kwant logic I would have to project onto the out of plane hoppings. Therefore I
need to create a system with out of plane hoppings, which automatically is 3D. But in this case
kwant.plotter.current does not work any more.

My idea in my first method was, to specify "where" in  kwant.operator.Current with where= cut
and cut return site0.pos[0]==x_cut  and site1.pos[0]==x_cut+1  (so specifying the out of plane x hoppings).

I created a 2D system with just onsite terms and no hoppings, so that the current density in x direction is
maped on the onsites (I cannot map on the x hoppings because yz 2D system has no x hoppings)
Then using kwant.plotter.map to display this.

But I suspect something is wrong with this.


 In my method 2 I plotted the J_z component instead of the J_x component. I updated the minimal example accordingly
https://github.com/Quaki96/KwantQuestion_2D-current-density-profile-through-3D-nanowire-cut/blob/e6d772b05af68db65130e10f14a4dfd62fccd374/current_density_minimal_example.ipynb

My Question in particular is, whether my second method of doing things is correct, because in the case of no magnetic
field, the current density does not vanish, which makes me somewhat sceptical.


PS. If a reader of this thread is interested in an small extension of Adels example with norbs=2 the following thread would be
useful: https://mail.python.org/archives/list/kwant-discuss@python.org/thread/LJFBAXU4ZIJ7LNZRLCUG6HVHR4UITAUY/

Best,

Felix


--
Abbout Adel