Ejemplo n.º 1
0
def get_wavefunction(potcar="POTCAR",
                     wavecar="WAVECAR",
                     vasprun="vasprun.xml",
                     directory=None):
    from pawpyseed.core import pawpyc
    from pawpyseed.core.wavefunction import CoreRegion, Wavefunction

    if directory:
        wf = Wavefunction.from_directory(path=directory)
    else:
        if isinstance(vasprun, str):
            vasprun = Vasprun(vasprun)

        if isinstance(potcar, str):
            potcar = Potcar.from_file(potcar)

        ngx = vasprun.parameters["NGX"]
        ngy = vasprun.parameters["NGY"]
        ngz = vasprun.parameters["NGZ"]
        dim = np.array([ngx, ngy, ngz])
        symprec = vasprun.parameters["SYMPREC"]
        structure = vasprun.final_structure

        pwf = pawpyc.PWFPointer(wavecar, vasprun)
        core_region = CoreRegion(potcar)

        wf = Wavefunction(structure, pwf, core_region, dim, symprec, False)

    wf = wf.desymmetrized_copy(time_reversal_symmetry=False, symprec=1e-4)
    return wf
Ejemplo n.º 2
0
    def initialize_wf_and_mm(self):
        SIZE = 60
        self.wf = Wavefunction.from_directory(".")
        vol = self.wf.structure.volume
        self.realspace_wf = self.wf.get_state_realspace(0,
                                                        0,
                                                        0,
                                                        dim=(SIZE, SIZE, SIZE),
                                                        remove_phase=True)
        # self.realspace_chg = np.abs(self.realspace_wf)**2
        self.realspace_chg = self.wf.get_state_realspace_density(0,
                                                                 0,
                                                                 0,
                                                                 dim=(SIZE,
                                                                      SIZE,
                                                                      SIZE))
        self.recipspace_wf = np.fft.fftn(
            self.realspace_wf) / SIZE**3 * np.sqrt(vol)
        self.recipspace_chg = np.fft.fftn(self.realspace_chg) / SIZE**3 * vol
        self.mm_real = MomentumMatrix(self.wf, encut=3000)
        self.mm_direct = MomentumMatrix(self.wf)
        self.mm_direct2 = MomentumMatrix(self.wf, encut=self.wf.encut)

        self.ncl_wf = NCLWavefunction.from_directory("noncollinear")
        self.ncl_realspace_wf = self.ncl_wf.get_state_realspace(
            0, 0, 0, dim=(SIZE, SIZE, SIZE), remove_phase=True)
        self.ncl_recipspace_wf = (
            np.fft.fftn(self.ncl_realspace_wf[0]) / SIZE**3 * np.sqrt(vol),
            np.fft.fftn(self.ncl_realspace_wf[1]) / SIZE**3 * np.sqrt(vol),
        )