Advertisement
SepandMeenu

spkf

Feb 14th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. def mk_spk(self, i, eta=1e-2):
  2.     """
  3.    It's possible to plot the approximate spectral functions by broadening
  4.    the delta functions of A_{ij}(k, w) and summing them
  5.  
  6.    Args:
  7.        i (int) : the entry of the diagonal spectral function A_{ii}
  8.        eta (float) : artificial broadening of the delta function
  9.    """
  10.  
  11.     """
  12.    # A delta function is the limit eta->0+ of a lorentzian
  13.    def lorentzian(w, a, eta=eta):
  14.        return 1 / np.pi * eta / ((w - a)**2 + eta**2)
  15.    """
  16.    
  17.     # fetch problem
  18.     prb = self.SPC.PRB
  19.  
  20.     # avoid computing _constants_ repeatedly
  21.     LZ0 = 1.0 / np.pi * eta
  22.     ETA_2 = eta**2
  23.  
  24.     # initialize `spkf`
  25.     spkf = np.zeros(len(self.SPC.ax_W))
  26.    
  27.     # for all momenta
  28.     for k_vec in prb.k_grid:
  29.  
  30.         # diagonalize
  31.         hamiltonian = prb.get_hamiltonian(k_vec)
  32.         eigvals, eigvecs = LA.eigh(hamiltonian)
  33.  
  34.         # benefit from Numpy's SIMD vectorization
  35.         # assumed `ax_W` is a vector like `eigvals`
  36.         lorentzians = LZ0 / ( (self.SPC.ax_W - eigvals)**2 + ETA_2 )
  37.  
  38.         # update `spkf` by adding E^\dagger . L . E
  39.         spkf += np.linalg.multi_dot(eigvects.conjugate(), lorentzians, eigvecs).real
  40.  
  41.     #END for
  42.    
  43.  
  44.     #? WHY PLOT HERE?
  45.     # plot
  46.     fig, ax = plt.subplots()
  47.     ax.plot(self.SPC.ax_W, spkf)
  48.     fig.tight_layout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement