Re: [Kwant] Effective Hamiltonian with leads
Hi Gerson, It's not easy to speed up the calculation that you doing. You could try to save a bit on constructing the system, but otherwise I don't see anything easy. Parallelization on the other hand works quite easily: you can just use poor man's parallelization and run different energies on different cores. Right now this means you'd also need to define the system in each core separately, since Kwant systems cannot be serialized yet. This shouldn't result in much overhead, but if you want I can also advise on serializing Kwant systems. Best, Anton On Thu, Jul 2, 2015, 19:03 Gerson J. Ferreira <gersonfjunior@yahoo.com.br> wrote:
Thanks Anton,
Slava Ostroukh had already replied to me some days ago. But his answer didn't go to the gmane interface. The code is working well now.
But let me take the chance to ask other questions:
1) Regarding the numerical efficiency, I just need the GF on a single site as a function of energy. But for a thin energy grid, the code is a bit slow because the system is not small. This is my first time dealing with Python and Kwant, so I'm wondering if it is possible to speed up the energy loop. Here's my code:
se = []; ldos = []; elist = np.arange(0,1,0.001); for en in elist: gf = kwant.greens_function(sys, energy=en, in_leads=[2], out_leads=[2]).data[0,0]; gfinv = 1/gf; se.append( gfinv.imag ) ldos.append( -gf.imag/3.141592 )
Is it possible to run in parallel this loop? OpenMP for Python+Kwant works?
2) When I calculate the LDOS of the full system like in the code below, how can I access the LDOS of a single site lat(i,j) from the ldos array? I don't see how the mapping of site position to the struct of data is done.
ldos = kwant.ldos(sysdos, energy=0.1); kwant.plotter.map(sysdos, ldos, vmin=0, vmax=0.9);
Thanks again, Best, Gerson
On Wed, Jul 1, 2015 at 4:03 PM, Anton Akhmerov <anton.akhmerov@gmail.com> wrote:
Dear Gerson,
Firstly, apologies for the delayed reply. The easiest way to get a Green's function on a subset of sites intrinsic to the system is to attach a virtual lead with zero self-energy to a group of sites. Specifically you'll want to use
http://kwant-project.org/doc/1.0/reference/generated/kwant.builder.SelfEnerg... There the selfenergy_func should just return a zero matrix of a proper size, and interface should be a list of sites that are of interest to you. Then you can just use kwant.greens_function to return the Green's function corresponding to that virtual lead.
Importantly this will only be numerically efficient if you are interested in a Green's function of a small subgroup of sites.
Best, Anton
On Fri, Jun 19, 2015 at 6:18 PM, Gerson <gersonfjunior@yahoo.com.br> wrote:
I would like to either get the local Green's function at a single site of my system with the effect of the leads included.
The Green's function method of Kwant does not give me this, right?
But I could get I want combining the system Hamiltonian if the leads self- energy:
Heff = Hsys + Sigma
However, "sys.hamiltonian_submatrix()" gives me the full Hsys, while "sys.leads[0].selfenergy(energy=0.01)" gives me only the submatrix of lead interface.
How can I reshape the self-energy to obtain the Heff?
Once I have Heff, I can calculate the GF via
Geff = [w - i.eta - Heff]^{-1}
Then, how can I access the local GF of a given site? Geff[lat(i,j)]?
Best, Gerson
Thanks again Anton, This was exactly what I wanted to know. If I could parallelize the loop without having to redefine the system in each fork/thread... For now I'll simply do the poor man's approach duplicating the system in each core. Best, Gerson On Sat, Jul 4, 2015 at 10:04 AM, Anton Akhmerov <anton.akhmerov@gmail.com> wrote:
Hi Gerson,
It's not easy to speed up the calculation that you doing. You could try to save a bit on constructing the system, but otherwise I don't see anything easy. Parallelization on the other hand works quite easily: you can just use poor man's parallelization and run different energies on different cores. Right now this means you'd also need to define the system in each core separately, since Kwant systems cannot be serialized yet. This shouldn't result in much overhead, but if you want I can also advise on serializing Kwant systems.
Best, Anton
On Thu, Jul 2, 2015, 19:03 Gerson J. Ferreira <gersonfjunior@yahoo.com.br> wrote:
Thanks Anton,
Slava Ostroukh had already replied to me some days ago. But his answer didn't go to the gmane interface. The code is working well now.
But let me take the chance to ask other questions:
1) Regarding the numerical efficiency, I just need the GF on a single site as a function of energy. But for a thin energy grid, the code is a bit slow because the system is not small. This is my first time dealing with Python and Kwant, so I'm wondering if it is possible to speed up the energy loop. Here's my code:
se = []; ldos = []; elist = np.arange(0,1,0.001); for en in elist: gf = kwant.greens_function(sys, energy=en, in_leads=[2], out_leads=[2]).data[0,0]; gfinv = 1/gf; se.append( gfinv.imag ) ldos.append( -gf.imag/3.141592 )
Is it possible to run in parallel this loop? OpenMP for Python+Kwant works?
2) When I calculate the LDOS of the full system like in the code below, how can I access the LDOS of a single site lat(i,j) from the ldos array? I don't see how the mapping of site position to the struct of data is done.
ldos = kwant.ldos(sysdos, energy=0.1); kwant.plotter.map(sysdos, ldos, vmin=0, vmax=0.9);
Thanks again, Best, Gerson
On Wed, Jul 1, 2015 at 4:03 PM, Anton Akhmerov <anton.akhmerov@gmail.com> wrote:
Dear Gerson,
Firstly, apologies for the delayed reply. The easiest way to get a Green's function on a subset of sites intrinsic to the system is to attach a virtual lead with zero self-energy to a group of sites. Specifically you'll want to use
http://kwant-project.org/doc/1.0/reference/generated/kwant.builder.SelfEnerg... There the selfenergy_func should just return a zero matrix of a proper size, and interface should be a list of sites that are of interest to you. Then you can just use kwant.greens_function to return the Green's function corresponding to that virtual lead.
Importantly this will only be numerically efficient if you are interested in a Green's function of a small subgroup of sites.
Best, Anton
On Fri, Jun 19, 2015 at 6:18 PM, Gerson <gersonfjunior@yahoo.com.br> wrote:
I would like to either get the local Green's function at a single site of my system with the effect of the leads included.
The Green's function method of Kwant does not give me this, right?
But I could get I want combining the system Hamiltonian if the leads self- energy:
Heff = Hsys + Sigma
However, "sys.hamiltonian_submatrix()" gives me the full Hsys, while "sys.leads[0].selfenergy(energy=0.01)" gives me only the submatrix of lead interface.
How can I reshape the self-energy to obtain the Heff?
Once I have Heff, I can calculate the GF via
Geff = [w - i.eta - Heff]^{-1}
Then, how can I access the local GF of a given site? Geff[lat(i,j)]?
Best, Gerson
participants (2)
-
Anton Akhmerov
-
Gerson J. Ferreira