
Hi Xavier, I appreciate your help! I updated my code to the following but now I receive an error that traces back to the Random_sites line and says that the list index is out of range. If I attempt to print sites2 then the output is an empty list. This is a bit confusing to me, is it because the system is not yet finalized? Once again thank you so much for your help! def make_syst(r=30, t=-1, a=1): syst = kwant.Builder() lat = kwant.lattice.honeycomb(a, norbs=1) sites2 = list(syst.sites()) Random_sites = random.choices(sites2, k = 10) def onsite(site): return 0.5 * kwant.digest.uniform(repr(Random_sites)) + 0.5 def circle(pos): x, y = pos return x ** 2 + y ** 2 < r ** 2 syst[lat.shape(circle, Random_sites)] = onsite syst[lat.neighbors()] = t syst.eradicate_dangling() return syst From: Xavier Waintal <xavier.waintal@cea.fr> Sent: Thursday, May 12, 2022 2:25 AM To: Blackwell, Raymond <rblackwel@bnl.gov> Cc: kwant-discuss@python.org Subject: Re: [Kwant] Help: Inputting Random Potential on Graphene Dear Raymond, I think that the problem comes from the last line of your code. syst[lat.shape(circle, (0, 0))] = onsite(bytes(3),bytes(3)) calls the function onsite with the 2 arguments you provided and then assign the result to all the sites. What you want to do is syst[lat.shape(circle, (0, 0))] = onsite In that case, when iterating over the sites, kwant will call the onsite function for each site. See the documentation for providing the salt parameter, e.g. https://kwant-project.org/doc/1/tutorial/spin_potential_shape<https://urldefense.com/v3/__https:/kwant-project.org/doc/1/tutorial/spin_potential_shape__;!!P4SdNyxKAPE!BY_Tx3Czr9bNjUVgs-Z_mSOn4Hj52FpSmhTjzfGAyP2tvHrviEg84oyfyg4fzcl-1n0Em6DZCCdCyArUVg0mceoRPw$> in the quantum_well.py example. Best regards, Xavier Le 12 mai 2022 à 00:26, Blackwell, Raymond <rblackwel@bnl.gov<mailto:rblackwel@bnl.gov>> a écrit : Hello, My name is Raymond Blackwell and I am attempting to use Kwant to simulate some experimental data. Our data involves dopant atoms intercalated under graphene, so I would like to simulate the LDOS but with a potential that randomly varies at several points within the system. I am trying to modify the code for the kernel_polynominal_method, but I cannot seem to get a random potential. I have used a similar method to randomly select a few points and modify the hopping parameter, but I am struggling with the seemingly more simple case where the potential varies. The relevant portion of my code is below. def make_syst(r=30, t=-1, a=1): syst = kwant.Builder() lat = kwant.lattice.honeycomb(a, norbs=1) def circle(pos): x, y = pos return x ** 2 + y ** 2 < r ** 2 sites2 = list(syst.sites()) Random_sites= random.choices(sites2, k=10) def onsite(site, salt): return 0.5 * kwant.digest.gauss(repr(Random_sites), salt) syst[lat.shape(circle, (0, 0))] = onsite(bytes(3),bytes(3)) Any help is greatly appreciated! Best, -Raymond