Hi, Hi Kwant Users > > I notice an inconsistency in calculation result using Python IDLE (3.5.1, > Anaconda3). > > The issue is that every time I execute the same code, it gives me a > different result.The test code that I use is the example code for graphene > quantum dot calculation (2.7.1) . > > First, I used the different parameter (r=3). Each time I executed the same > code, it returned different wavefunction. If I use a large r (r=8), the > wavefunction(n=225) is consistent. But if I plot the wavefunction 22 > instead of 225 as an example, then the wavefunction is different for each > time. I tested the code within jupyter notebook and it doesn't show any > inconsistencies. > > Can anyone advise me what raises this issue ? Is it because of > Kwant package or Python IDLE or the calculation script itself? >
This works for me using Python 2, which gives me a clue as to what the problem is. The order of the Kwant sites in the finalized system (and hence the sort order of wavefunctions) is essentially given by the order that some keys are pulled out of a dictionary during finalization. For a given script this order was consistent across different runs in Python 2, but is not in Python 3 [1] The next question is the following: even if the order of sites is changed each time the script is run, a given site still corresponds to a given spatial position, so why does the (absolute value squared of the) wavefunction *look* different each time it is plotted? I believe that the answer lies in the symmetry of the system that you are studying. If I look at eigenvalues 21 and 22 I see that they are identical, i.e. there is a degeneracy (which is endowed by the symmetry of your system). The ordering of these two eigenstates is therefore arbitrary, and given that a different problem is being solved each time the script is run (the sites have been rearranged), it would not surprise me that these two eigenstates are ordered differently sometimes. This explanation is corroborated by the fact that when I run your script with the bleeding edge version of Kwant (notably after this merge request had been applied [2]) then I see consistent results across runs of the script. TLDR; degenerate eigenstates are being rearranged due to non-deterministic Python 3 dictionaries, this will be fixed in the next Kwant release Happy Kwanting, Joe [1]: https://docs.python.org/3/whatsnew/3.3.html [2]: https://gitlab.kwant-project.org/kwant/kwant/merge_requests/23
