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 in the 
quantum_well.py example.
 
Best regards,

Xavier



> Le 12 mai 2022 à 00:26, Blackwell, Raymond <rblack...@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 

Reply via email to