Anton, Thanks for the rapid response, now it works - of course. I have started to wrestle with Python only because of Kwant, so it will take some time before I fully understand your reply. In the meantime, would you be so kind and suggest how to plot ldos for spin-up and spin-down components separately? Jerzy
Note for the future: it is always helpful to add the actual error messages to your reports. In this case however, the problem is clear:
kwant.ldos calculates local density of states on each degree of freedom of the system (so spin up and spin down separately). On the other hand, kwant.plotter.map expects to have as many values to plot as there are sites in the system, not more and not less. Both of these things are behaving as written in the docs. You can modify your function to plot the density of states per site for example like this:
def plot_ldos(sys, energy): # Compute local dos local_dos = kwant.ldos(sys, energy) # Calculate ldos per site, by summing spin up and spin down components local_dos = np.sum(local_dos.reshape(-1, 2), axis=1) kwant.plotter.map(sys, local_dos, num_lead_cells=5)
The line that I have added, as you can check, uses NumPy functions for manipulations with arrays: first out of a 1D array with shape (2xN) an array with shape (N, 2): my_array.reshape(-1, 2) where the elements with the same value of the 0th coordinate (NumPy counts array axes starting from 0) have the same site number. Then I sum this array along the second axis: np.sum(my_array, axis=1)
I hope this helps.
On Tue, Sep 24, 2013 at 8:20 PM, Jerzy Wrobel firstname.lastname@example.org wrote:
I have modified quantum_wire_revisited.py by adding new function
def plot_ldos(sys, energy): # Compute local dos local_dos = kwant.ldos(sys, energy) kwant.plotter.map(sys, local_dos, num_lead_cells=5)
and adding new command
to the already existing function main().
It works well. However, when I have modified the spin-orbit.py file in the same way, program halts. Some cryptic messages, which ended with ValueError: different number of values and points, are generated.
How to resolve this? Thanks in advance,