Family-dependent onsite potential
Hello, I am making a system with 2 sublattices, so they belong to different families (a and b), and I wish to define a sublattice-dependent onsite energy. I tried using the following code for the onsite function. def onsite(site): onsite_a = 2 onsite_b = 2 return onsite_a if site.family == a else onsite_b but it does not work. I get error message: 'int' object has no attribute 'family'. How can I solve this, or what am I doing wrong? Best, Camilla
Dear Camilla, in which context do you use this function? What the error message tells you that `site` in your function is an integer. This shouldn't be if you passed onsite to a Builder. Are you getting this problem when using trying to plot this function? Best, Michael On 27-10-16 11:34, Camilla Espedal wrote:
Hello,
I am making a system with 2 sublattices, so they belong to different families (a and b), and I wish to define a sublattice-dependent onsite energy. I tried using the following code for the onsite function.
def onsite(site):
onsite_a = 2
onsite_b = 2
return onsite_a if site.family == a else onsite_b
but it does not work. I get error message: ‘int’ object has no attribute ‘family’. How can I solve this, or what am I doing wrong?
Best,
Camilla
The problem occurs when I try to plot a map of the voltage on the sample, to check that everything is working. The problem does not seem to occur when assigning it to a builder element
sys[lattice.shape(shape_sr, (1,1))] = onsite
gives no error messages.
This is what I am trying to do, I write a function that calculates the voltage (I followed one of your tutorials)
def V(sys):
Hd = onsite(site)
return (Hd[0,0] - Hd[1,1]).real
and then
sys = sys.finalized()
kwant.plotter.map(sys, V)
to try to plot it, but then I get the error.
-----Original Message-----
From: Christoph Groth [mailto:christoph.groth@cea.fr]
Sent: 27. oktober 2016 12:15
To: Camilla Espedal
(...) but it does not work. I get error message: ‘int’ object has no attribute ‘family’. How can I solve this, or what am I doing wrong?
This shouldn’t be. Can you provide a complete script that demostrates the problem? Christoph
Hi Camilla, you should do the plotting before the finalization, not after. The reason is that before the finalization, kwant always works still internally with sites. After finalization, it's integers (note though that internally kwant will still call your onsite function within the finalized builder!). Best, Michael On 27-10-16 14:50, Camilla Espedal wrote:
The problem occurs when I try to plot a map of the voltage on the sample, to check that everything is working. The problem does not seem to occur when assigning it to a builder element
sys[lattice.shape(shape_sr, (1,1))] = onsite
gives no error messages.
This is what I am trying to do, I write a function that calculates the voltage (I followed one of your tutorials)
def V(sys): Hd = onsite(site) return (Hd[0,0] - Hd[1,1]).real
and then
sys = sys.finalized() kwant.plotter.map(sys, V)
to try to plot it, but then I get the error.
-----Original Message----- From: Christoph Groth [mailto:christoph.groth@cea.fr] Sent: 27. oktober 2016 12:15 To: Camilla Espedal
Cc: kwant-discuss@kwant-project.org Subject: Re: [Kwant] Family-dependent onsite potential Camilla Espedal wrote:
(...) but it does not work. I get error message: ‘int’ object has no attribute ‘family’. How can I solve this, or what am I doing wrong?
This shouldn’t be. Can you provide a complete script that demostrates the problem?
Christoph
participants (3)
-
Camilla Espedal
-
Christoph Groth
-
Michael Wimmer