I am attempting to approximate the first derivate over the system's wavefunction values, yet it seems there is no neighbors() function to call after finalization of the system. What would be the method to attain a list of neighboring sites after finalizaion? Is the ordering of the sites preserved before and after finalization?
Hi Henry, The builder is internally a dictionary, and hence on recent versions of Python it stores sites in the order in which they were added. The finalized system, on the other hand, stores the sites in lexicographic ordering [1]. To get the neighbors of a site in a finalized system you should use its graph attribute, so the method syst.graph.in_neighbors(site_number) [2]. The graph works with integer-indexed sites, to convert to the corresponding site objects, use syst.sites and syst.id_by_site. Cheers, Anton [1]: https://kwant-project.org/doc/1/pre/whatsnew/1.3#consistent-ordering-of-site... [2]: https://kwant-project.org/doc/1/reference/generated/kwant.graph.CGraph#kwant... On Thu, 12 Aug 2021 at 11:12, Henry Axt <henry.axt@gmail.com> wrote:
I am attempting to approximate the first derivate over the system's wavefunction values, yet it seems there is no neighbors() function to call after finalization of the system. What would be the method to attain a list of neighboring sites after finalizaion? Is the ordering of the sites preserved before and after finalization?
Dear Anton, Thank you for your answer! Am I mistaken or is it indeed the case that the in_neighbors method is not availabe in the current version of Kwant?
Henry Axt wrote:
Am I mistaken or is it indeed the case that the in_neighbors method is not availabe in the current version of Kwant?
Builder graphs are only "one-way" and not "two-way" (using the terminology of Kwant’s graph module). That’s why you have to use the method ’out_neighbors’. The method ’in_neigbhors’ has never been available for graphs as they are prepared for finalized builders as far as I remember.
import kwant kwant.__version__ '1.4.2' lat = kwant.lattice.chain() syst = kwant.Builder() syst[ (lat(x) for x in range(10)) ] = 0 syst[lat.neighbors()] = 1 fsyst = syst.finalized() list(fsyst.graph.out_neighbors(0)) [1] list(fsyst.graph.out_neighbors(1)) [0, 2]
participants (3)
-
Anton Akhmerov
-
Christoph Groth
-
Henry Axt