Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def mk_spk(self, i, eta=1e-2):
- """
- It's possible to plot the approximate spectral functions by broadening
- the delta functions of A_{ij}(k, w) and summing them
- Args:
- i (int) : the entry of the diagonal spectral function A_{ii}
- eta (float) : artificial broadening of the delta function
- """
- """
- # A delta function is the limit eta->0+ of a lorentzian
- def lorentzian(w, a, eta=eta):
- return 1 / np.pi * eta / ((w - a)**2 + eta**2)
- """
- # fetch problem
- prb = self.SPC.PRB
- # avoid computing _constants_ repeatedly
- LZ0 = 1.0 / np.pi * eta
- ETA_2 = eta**2
- # initialize `spkf`
- spkf = np.zeros(len(self.SPC.ax_W))
- # for all momenta
- for k_vec in prb.k_grid:
- # diagonalize
- hamiltonian = prb.get_hamiltonian(k_vec)
- eigvals, eigvecs = LA.eigh(hamiltonian)
- # benefit from Numpy's SIMD vectorization
- # assumed `ax_W` is a vector like `eigvals`
- lorentzians = LZ0 / ( (self.SPC.ax_W - eigvals)**2 + ETA_2 )
- # update `spkf` by adding E^\dagger . L . E
- spkf += np.linalg.multi_dot(eigvects.conjugate(), lorentzians, eigvecs).real
- #END for
- #? WHY PLOT HERE?
- # plot
- fig, ax = plt.subplots()
- ax.plot(self.SPC.ax_W, spkf)
- fig.tight_layout()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement