Dear John,
The solution I am proposing is not very clean, but at least it works fine.
To plot the wavefunction of a system for a fixed slice, you need to save the result of the wavefunction for the desired sites, and then define a new 2D system recovering the slice you chose, and by reordering the results of the wavefunction to fit the new order of the sites in the new system, the plot becomes straightforward.
for your program it works like this:
# plots for the mode 0 and 1
sys = make_system_cyl(a=1, s=50, L = 15)
kwant.plot(sys)
sysf = sys.finalized()
params = SimpleNamespace(t=1)
wf = kwant.wave_function(sysf, 1.5, args=[params])
#define a new system for the desired slice.
lat2 = kwant.lattice.square()
sys_b = kwant.Builder() #new 2D system used for the plot
slice_x=5
mode=1
def Plot_mode(sys_b,slice_x,mode):
wavefunction = wf(1)[mode]
Sites= [site for (index,site) in enumerate(sysf.sites) if site.pos[0]==slice_x ]
Indexes=[index for (index,site) in enumerate(sysf.sites) if site.pos[0]==slice_x ]
waves=[wavefunction[index] for index in Indexes]
Sites2=[lat2(site.pos[1],site.pos[2]) for site in Sites] #used to define the new system sys_b
sys_b[Sites2]=0
sys_b[lat2.neighbors()]=-1
Sites_b=[site for site in sys_b.finalized().sites] # sites of the new system: with a different order!
Index_b=[Sites2.index(site) for site in Sites_b]
waves_b=[waves[index] for index in Index_b] # results is reordered according to the new order of the sites.
return sys_b, waves_b
sys_b, waves_b= Plot_mode(sys_b=sys_b,slice_x=5,mode=0)
kwant.plotter.map(sys_b.finalized(),abs(array(waves_b))**2)
sys_b, waves_b= Plot_mode(sys_b=sys_b,slice_x=5,mode=1)
kwant.plotter.map(sys_b.finalized(),abs(array(waves_b))**2)
I hope this helps.
Regards,
Adel