Hi devs,

I have been studying Kwant, specifically, Green’s functions. I am trying to 
obtain the electron density from the definition of the correlation function. 
The code follows below,
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
data3 = []
energies2 = []

Es = np.linspace(0, 30, 100)

for ie in Es:
    E = ie * 0.01
    G = kwant.greens_function(fsyst, E)
    
    # Funcoes de Green retardada indo da lead0 para lead1
    G_r = G.submatrix(1,0)
    
    # Funcao de Green avancada 
    G_a = conj((G_r).T)
    
    # Self-energy da lead 0
    SigmaL_r = lead_0.selfenergy(E) # Retardada
    SigmaL_a = conj((SigmaL_r).T) # Avancada
    
    # Self-energy da lead 1
    SigmaR_r = lead_1.selfenergy(E) # Retardada
    SigmaR_a = conj((SigmaR_r).T) # Avancada
    
    # Matriz de Alargamento
    Gamma_L = 1j*(SigmaL_r-SigmaL_a) # referente a lead_0
    Gamma_R = 1j*(SigmaR_r-SigmaR_a) # referente a lead_1
    
    # Funcao de distribuicao de Fermi-Dirac em T=0
    f_L = np.heaviside(mu_L - E, 1)
    f_R = np.heaviside(mu_R - E, 1)
    
    # Funcao inscattering
    Sigma_in = (f_L)*(Gamma_L) + (f_R)*(Gamma_R)
    
    # Funcao de correlacao
    G_n = np.dot(np.dot(G_r, Sigma_in), G_a)
    
    data3.append(imag(np.trace(G_n)))   
    energies2.append(E)

plt.figure()
plt.plot(energies2, data3)
plt.xlabel("energy [eV]")
plt.ylabel("electron density")
plt.show()
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>From this definition, is it possible to obtain this electron density as a 
>function of the sites position? How can I do that?

Best,
Gabriel

Reply via email to