def __init__(self, ecut, lattice, kpoint, gvecs, istwfk=1): """ Args: ecut: Cutoff energy in Hartree. lattice: Reciprocal lattice. kpoint: Reduced coordinates of the k-point. gvecs: Array with the reduced coordinates of the G-vectors. istwfk: Storage option (time-reversal symmetry, see abinit variable) """ self.ecut = ecut self.lattice = lattice self.kpoint = Kpoint.askpoint(kpoint, lattice) self._gvecs = np.reshape(np.array(gvecs), (-1, 3)) self.npw = self.gvecs.shape[0] self.istwfk = istwfk if istwfk != 1: raise NotImplementedError("istwfk %d is not implemented" % self.istwfk)
def __init__(self, qpoint, freq, displ_cart, structure): """ Args: qpoint: qpoint in reduced coordinates. freq: Phonon frequency in eV. displ: Displacement (Cartesian coordinates, Angstrom) structure: Pymatgen structure. """ self.qpoint = Kpoint.askpoint(qpoint, structure.reciprocal_lattice) self.freq = freq self.displ_cart = displ_cart self.structure = structure
def plot(self, qpoint=None, spin=None, kpoints=None, color_map=None, **kwargs): """ Plot the dipole matrix elements. Args: qpoint: The qpoint for the optical limit. if qpoint is None, we plot |<k|r|k>| else |<k|q.r|k>| spin: spin index. None if all spins are wanted kpoints: List of Kpoint objects, None if all k-points are wanted. ============== ============================================================== kwargs Meaning ============== ============================================================== title Title of the plot (Default: None). show True to show the figure (Default). savefig: 'abc.png' or 'abc.eps'* to save the figure to a file. colormap matplotlib colormap, see link below. ============== ============================================================== Returns: matplotlib figure. .. see: http://matplotlib.sourceforge.net/examples/pylab_examples/show_colormaps.html """ title = kwargs.pop("title", None) show = kwargs.pop("show", True) savefig = kwargs.pop("savefig", None) color_map = kwargs.pop("color_map", None) if qpoint is not None: # Will compute scalar product with q qpoint = Kpoint.askpoint(qpoint, self.structure.reciprocal_lattice).versor() else: # Will plot |<psi|r|psi>|. qpoint = Kpoint((1, 1, 1), self.structure.reciprocal_lattice) if spin in None: spins = range(self.nsppol) else: spins = [spin] if kpoints is None: kpoints = self.ibz # Extract the matrix elements for the plot. from abipy.tools.plotting_utils import ArrayPlotter plotter = ArrayPlotter() for spin in spins: for kpoint in kpoints: ik = self.kpoint_index(kpoint) rme = self.dipme_scvk[spin, ik, :, :, :] #qrme = qpoint * rme label = "qpoint %s, spin %s, kpoint = %s" % (qpoint, spin, kpoint) plotter.add_array(label, rme) # Plot matrix elements and return matplotlib figure. return plotter.plot(title=title, color_map=color_map, show=show, savefig=savefig, **kwargs)