Hi Crhistoph,
Thanks a lot for the detailed information. Now I understand much better how the algorithm works. For me it's good enough as it is now, I just wanted to understand a little bit more how to interpret the maps I get.
Kind regards,
Marc
------------------------
Marc Vila Tusell
La Caixa - Severo Ochoa PhD in the Theoretical and Computational Nanoscience Group
Catalan Institute of Nanoscience and Nanotechnology (ICN2)
Barcelona Institute of Science and Technology (BIST)
Additional information:
http://icn2.cat/en/theoretical-and-computational-nanoscience-group
https://www.researchgate.net/profile/Marc_Vila_Tusell
https://www.becarioslacaixa.net/marc-vila-tusell-BI00042?nav=true
https://orcid.org/0000-0001-9118-421X
________________________________________
From: Christoph Groth
I thought the current was plotted with kwant.plotter.current(), so I just checked that documentation. Now I see that it's a shortcut for the stremplot.
kwant.plotter.current() calls kwant.plotter.streamplot() to do the plotting which in turns piggybacks on matplotlib.streamplot() to trace the streamlines. The added value of kwant.plotter.streamplot() is that it plots both the streamlines (using matplotlib's streamplot()) and the background color plot (using matplotlib's imshow()).
I understand your explanation about how the lines are drawn, but, if the algorithm doesn't know about the form of the current field, how does it know how thick it needs to draw the arrow?
The current field data is of course available to matplotlib.streamplot(). It's just that the streamline tracing algorithm doesn't use this information (if you normalize the stream speed to 1 everywhere, you'd get the same streamlines). When plotting the streamlines, the density is taken into account.
In any case, could it be safer to plot the arrows with always the same thickness and just look at the colorplot to see the value?
We tried that, but then in a case like yours the whole plot is full of streamlines even where the current density is practically zero. This is ugly and confusing. One can also imagine a completely different kind of streamplot where all streamlines have the same thickness and it's their density that is proportional to the local flow speed. Such a streamplot would avoid the many problems and would correspond better to what physicists are used to. But it would require implementing something completely independent from matplotlib.streamplot(). Meanwhile, matplotlib.streamplot() works as follows: The plotting domain is subdivided into a grid of cells (30*30 by default) where each cell can have, at most, one traversing streamline. The streamlines start at points specified by the 'start_points' parameter. The docstring doesn't say what happens if 'start_points' is not given, but looking at the source code unearths the following: def _gen_starting_points(shape): """Yield starting points for streamlines. Trying points on the boundary first gives higher quality streamlines. This algorithm starts with a point on the mask corner and spirals inward. This algorithm is inefficient, but fast compared to rest of streamplot. """ I suspect that a better algorithm to generate starting points would have to actually look at the stream field and try to put streamlines at significant places, like the centers of "streams". But such an algorithm would be tricky, because it would also have to respect that streamlines should be equally spaced. In any way, plotter.streamplot() is just a small part of Kwant, so we don't want to spend too much time on it. (We've already spent a lot of time on doing the current density interpolation right.) If there are people who are motivated to improve current density plots, I'd be happy to assist.