示例#1
0
def test_vrun():
    # print ('gapp',round(vrun.get_indir_gap,2))
    assert (round(vrun.get_indir_gap[0], 2)) == (0.73)
    assert (round(vrun.get_dir_gap, 2)) == (2.62)
    vrun.get_bandstructure(kpoints_file_path=band_kp,plot=True)
    assert (round(opt_vrun.get_dir_gap, 2)) == (2.62)
    assert (vrun.total_dos[0][0]) == -8.1917
    # TODO Serious issue: assert (opt_vrun.total_dos[0][0]) == -8.1917
    assert (vrun.eigenvalues[0][0][0][0]) == -6.1917
    assert (opt_vrun.eigenvalues[0][0][0][0]) == -6.1917
    assert vrun.is_spin_polarized == True
    assert opt_vrun.is_spin_polarized == False
    assert vrun.is_spin_orbit == False
    assert list(vrun.fermi_velocities[0]) == []
    pdos1 = vrun.partial_dos_spdf
    pdos2 = vrun.projected_atoms_spins_kpoints_bands
    pdos3 = vrun.projected_spins_kpoints_bands
    pdos4 = vrun.get_atom_resolved_dos(plot=True)
    pdos5 = vrun.get_spdf_dos(plot=True)
    td = vrun.to_dict()
    fd = Vasprun.from_dict(td)
    vrun_dm = Vasprun(
        os.path.join(os.path.dirname(__file__), "JVASP-86924.xml")
    )
    fv = vrun_dm.fermi_velocities
    assert round(fv[0][0], 2) == round(491630.23058338434, 2)
示例#2
0
def get_wann_phonon(jid="JVASP-1002", factor=15.633302):
    """Download phonon WTBH if available."""
    # Requires phonopy
    from jarvis.io.phonopy.outputs import get_phonon_tb

    fls = data("raw_files")

    for i in fls["FD-ELAST"]:
        if isinstance(i, dict):
            if i["name"].split(".zip")[0] == jid:
                r = requests.get(i["download_url"])
                z = zipfile.ZipFile(io.BytesIO(r.content))
                vrun_path = z.read("vasprun.xml").decode("utf-8")
                fd, path = tempfile.mkstemp()
                with os.fdopen(fd, "w") as tmp:
                    tmp.write(vrun_path)
                vrun = Vasprun(path)
                fc = vrun.phonon_data()["force_constants"]
                atoms = vrun.all_structures[0]
                # print(atoms)
                # atoms = Atoms.from_poscar(pos)
                # print(atoms)
                fd, path = tempfile.mkstemp()
                get_phonon_tb(fc=fc, atoms=atoms, out_file=path, factor=factor)
                # cvn = Spacegroup3D(atoms).conventional_standard_structure
                w = WannierHam(path)
                return w, atoms
示例#3
0
def test_solar():
    v = Vasprun(vrun_path)
    dirgap = v.get_dir_gap
    indirgap = v.get_indir_gap[0]
    en, abz = v.avg_absorption_coefficient
    abz = abz * 100
    eff_slme = SolarEfficiency().slme(
        en, abz, indirgap, indirgap, plot_current_voltage=True
    )
    # print("SLME", 100 * eff)
    eff_sq = SolarEfficiency().calculate_SQ(indirgap)
    # print("SQ", 100 * eff)
    assert (round(100 * eff_slme, 2), round(100 * eff_sq, 2)) == (33.23, 32.93)
示例#4
0
def test_dfpt():
    vrun = Vasprun(
        os.path.join(os.path.dirname(__file__), "vasprun.xml.JVASP-39"))
    out = Outcar(os.path.join(os.path.dirname(__file__), "OUTCAR.JVASP-39"))
    bec = round(vrun.dfpt_data["born_charges"][0][0][0], 2)
    eig = round(out.phonon_eigenvalues[2], 2)
    ionic_pz, total_pz = out.piezoelectric_tensor
    pz = total_pz[2][0]
    assert (bec, eig, pz) == (2.52, 19.58, -0.26756)
    # print (vrun.all_stresses)
    assert vrun.all_stresses[0][0][0] == -14.79381147
    assert vrun.all_forces[0][0][0] == 0
    assert vrun.all_energies[0] == -24.86360178
    assert vrun.all_structures[0].volume == 42.60334334259966
示例#5
0
def test_download(jid="JVASP-1002"):
    for i in fls["FD-ELAST"]:
        if isinstance(i, dict):
            if i["name"].split(".zip")[0] == jid:
                print(i)

                r = requests.get(i["download_url"])
                z = zipfile.ZipFile(io.BytesIO(r.content))
                vrun_path = z.read("vasprun.xml").decode("utf-8")
                fd, path = tempfile.mkstemp()
                with os.fdopen(fd, "w") as tmp:
                    tmp.write(vrun_path)
                vrun = Vasprun(path)
                fc = vrun.phonon_data()["force_constants"]
                atoms = vrun.all_structures[0]
                print(atoms)
                # atoms = Atoms.from_poscar(pos)
                print(atoms)
                fd, path = tempfile.mkstemp()
                get_phonon_tb(fc=fc, atoms=atoms, out_file=path)
                cvn = Spacegroup3D(atoms).conventional_standard_structure
                w = WannierHam(path)
                # print ('atoms',atoms)
                w.get_bandstructure_plot(atoms=atoms, yrange=[0, 550])
示例#6
0
    def workflow(self, generic_incar=""):
        """
        Use for functional based high-throughput calculations.

        This will converge k-points, cut-offs,
        and then carry several property calculations.

        Args:
            mat : Poscar object
        """
        job = JobFactory(
            use_incar_dict=generic_incar.incar,
            pot_type=generic_incar.pot_type,
            vasp_cmd=self.vasp_cmd,
            copy_files=self.copy_files,
            attempts=self.attempts,
            stderr_file=self.stderr_file,
            output_file=self.output_file,
            poscar=self.mat,
        )
        encut = job.converg_encut(mat=self.mat)
        length = job.converg_kpoint(mat=self.mat)
        energy, contcar_path = job.optimize_geometry(mat=self.mat,
                                                     encut=encut,
                                                     length=length)
        optimized_mat = Poscar.from_file(contcar_path)
        vrun = Vasprun(contcar_path.replace("CONTCAR", "vasprun.xml"))
        chg_path = contcar_path.replace("CONTCAR", "CHGCAR")
        nbands = int(vrun.all_input_parameters["NBANDS"])
        enB, contcB = job.band_structure(
            mat=optimized_mat,
            encut=encut,
            line_density=20,
            nbands=2 * nbands,
            copy_prev_chgcar=chg_path,
        )
        enL, contcL = job.loptics(mat=optimized_mat,
                                  encut=encut,
                                  nbands=2 * nbands,
                                  length=length)
        enM, contcM = job.mbj_loptics(mat=optimized_mat,
                                      encut=encut,
                                      nbands=2 * nbands,
                                      length=length)
        enE, contcE = job.elastic(mat=optimized_mat,
                                  encut=encut,
                                  nbands=2 * nbands,
                                  length=length)
示例#7
0
def test_ir():
    vrun = Vasprun(
        os.path.join(os.path.dirname(__file__), "vasprun.xml.JVASP-39"))
    out = Outcar(os.path.join(os.path.dirname(__file__), "OUTCAR.JVASP-39"))
    phonon_eigenvectors = vrun.dfpt_data["phonon_eigenvectors"]
    vrun_eigs = vrun.dfpt_data["phonon_eigenvalues"]
    phonon_eigenvalues = out.phonon_eigenvalues
    masses = vrun.dfpt_data["masses"]
    born_charges = vrun.dfpt_data["born_charges"]
    x, y = ir_intensity(
        phonon_eigenvectors=phonon_eigenvectors,
        phonon_eigenvalues=phonon_eigenvalues,
        masses=masses,
        born_charges=born_charges,
    )
    assert round(y[2], 2) == 0
示例#8
0
文件: run.py 项目: xiajabra/jarvis
def run_phonopy(path="MAIN-ELAST"):
    """Run phonopy."""
    os.chdir(path)
    try:
        vrun = Vasprun(os.path.join(path, "vasprun.xml"))
        atoms = vrun.all_structures[-1]
        PhonopyInputs(atoms=atoms).generate_all_files()
        cmd = "phonopy -p meshdos.conf"
        os.system(cmd)
        cmd = "phonopy -t meshdos.conf"
        os.system(cmd)
        cmd = "phonopy -p bandd.conf"
        os.system(cmd)
        cmd = "bandplot -o PBAND.png"
        os.system(cmd)
    except Exception as exp:
        print("Cannot run phonopy. Check phonopy PATH and vasprun.", exp)
        pass
示例#9
0
def test_vrun():
    # print ('gapp',round(vrun.get_indir_gap,2))
    assert (round(vrun.get_indir_gap, 2)) == (0.73)
    assert (round(vrun.get_dir_gap, 2)) == (2.62)
    vrun.get_bandstructure(kpoints_file_path=band_kp)
    assert (round(opt_vrun.get_dir_gap, 2)) == (2.62)
    assert (vrun.total_dos[0][0]) == -8.1917
    # TODO Serious issue: assert (opt_vrun.total_dos[0][0]) == -8.1917
    assert (vrun.eigenvalues[0][0][0][0]) == -6.1917
    assert (opt_vrun.eigenvalues[0][0][0][0]) == -6.1917
    assert vrun.is_spin_polarized == True
    assert opt_vrun.is_spin_polarized == False
    assert vrun.is_spin_orbit == False
    assert list(vrun.fermi_velocities[0]) == []
    pdos1 = vrun.partial_dos_spdf
    pdos2 = vrun.projected_atoms_spins_kpoints_bands
    pdos3 = vrun.projected_spins_kpoints_bands
    td = vrun.to_dict()
    fd = Vasprun.from_dict(td)
示例#10
0
文件: vasp.py 项目: reid-a/jarvis
    def all_optb88vdw_props(self, mat=None):
        """
        Use for OptB88vdW functional based high-throughput calculations.

        This will converge k-points, cut-offs,
        and then carry several property calculations.

        Args:
            mat : Poscar object
        """
        optb88 = GenericIncars().optb88vdw()
        job = JobFactory(use_incar_dict=optb88.incar, pot_type=optb88.pot_type)
        encut = job.converg_encut(mat=mat)
        length = job.converg_kpoint(mat=mat)
        energy, contcar_path = job.optimize_geometry(mat=mat,
                                                     encut=encut,
                                                     length=length)
        optimized_mat = Poscar.from_file(contcar_path)
        vrun = Vasprun(contcar_path.replace("CONTCAR", "vasprun.xml"))
        chg_path = contcar_path.replace("CONTCAR", "CHGCAR")
        nbands = int(vrun.all_input_parameters["NBANDS"])
        enB, contcB = job.band_structure(
            mat=optimized_mat,
            encut=encut,
            line_density=20,
            nbands=2 * nbands,
            copy_prev_chgcar=chg_path,
        )
        enL, contcL = job.loptics(mat=optimized_mat,
                                  encut=encut,
                                  nbands=2 * nbands,
                                  length=length)
        enM, contcM = job.mbj_loptics(mat=optimized_mat,
                                      encut=encut,
                                      nbands=2 * nbands,
                                      length=length)
        enE, contcE = job.elastic(mat=optimized_mat,
                                  encut=encut,
                                  nbands=2 * nbands,
                                  length=length)
示例#11
0
def ir_intensity_phonopy(
    run_dir=".",
    vasprun="vasprun.xml",
    BornFileName="BORN",
    PoscarName="POSCAR",
    ForceConstantsName="FORCE_CONSTANTS",
    supercell=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
    nac=True,
    symprec=1e-5,
    primitive=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
    degeneracy_tolerance=1e-5,
    vector=[0, 0, 0],
    smoothen=False,
):
    """Calculate IR intensity using DFPT and phonopy."""
    from phonopy import Phonopy
    from phonopy.interface.vasp import read_vasp
    from phonopy.file_IO import (
        parse_BORN,
        parse_FORCE_CONSTANTS,
    )
    import shutil
    from phonopy.units import VaspToCm

    # from phonopy.phonon.degeneracy import (
    #    degenerate_sets as get_degenerate_sets,
    # )
    # adapted from https://github.com/JaGeo/IR
    # TODO: Make directory indepndent
    cwd = os.getcwd()
    print("Directory:", cwd)
    os.chdir(run_dir)
    if not os.path.exists(vasprun):
        shutil.copy2(vasprun, "vasprun.xml")
    cmd = str("phonopy --fc vasprun.xml")
    os.system(cmd)
    born_file = os.path.join(os.getcwd(), BornFileName)
    cmd = str("phonopy-vasp-born >  ") + str(born_file)
    os.system(cmd)
    from jarvis.io.vasp.outputs import Vasprun

    v = Vasprun(vasprun)
    strt = v.all_structures[0]
    strt.write_poscar(PoscarName)
    unitcell = read_vasp(PoscarName)
    phonon = Phonopy(
        unitcell,
        supercell_matrix=supercell,
        primitive_matrix=primitive,
        factor=VaspToCm,
        symprec=symprec,
    )
    natoms = phonon.get_primitive().get_number_of_atoms()
    force_constants = parse_FORCE_CONSTANTS(filename=ForceConstantsName)
    phonon.set_force_constants(force_constants)
    masses = phonon.get_primitive().get_masses()
    phonon.set_masses(masses)
    BORN_file = parse_BORN(phonon.get_primitive(), filename=BornFileName)
    BORN_CHARGES = BORN_file["born"]
    # print ('born_charges2',BORN_CHARGES)
    if nac:
        phonon.set_nac_params(BORN_file)
    frequencies, eigvecs = phonon.get_frequencies_with_eigenvectors(vector)
    # frequencies=VaspToTHz*frequencies/VaspToCm
    # x, y = ir_intensity(
    #    phonon_eigenvectors=np.real(eigvecs),
    #    phonon_eigenvalues=frequencies,
    #    masses=masses, #np.ones(len(masses)),
    #    born_charges=born_charges,
    #    smoothen=smoothen,
    # )
    NumberOfBands = len(frequencies)
    EigFormat = {}
    for alpha in range(NumberOfBands):
        laufer = 0
        for beta in range(natoms):
            for xyz in range(0, 3):
                EigFormat[beta, alpha, xyz] = eigvecs[laufer][alpha]
                laufer = laufer + 1
    Intensity = {}
    intensities = []
    for freq in range(len(frequencies)):
        Intensity[freq] = 0
        tmp = 0
        for alpha in range(3):
            asum = 0
            for n in range(natoms):
                for beta in range(3):
                    asum = asum + BORN_CHARGES[n, alpha, beta] * np.real(
                        EigFormat[n, freq, beta]
                    ) / np.sqrt(masses[n])
                    tmp += asum
            Intensity[freq] = Intensity[freq] + np.power(np.absolute(asum), 2)
        intensities.append(Intensity[freq])
    os.chdir(cwd)
    return frequencies, intensities
示例#12
0
文件: test_ir.py 项目: tavazza/jarvis
    os.path.dirname(__file__),
    "..",
    "..",
    "io",
    "vasp",
    "vasprun.xml.JVASP-39",
)
dirc = os.path.join(
    os.path.dirname(__file__),
    "..",
    "..",
    "io",
    "vasp",
)

vrun = Vasprun(vrun_file)


def test_ir():
    phonon_eigenvectors = vrun.dfpt_data["phonon_eigenvectors"]
    vrun_eigs = vrun.dfpt_data["phonon_eigenvalues"]
    phonon_eigenvalues = out.phonon_eigenvalues
    masses = vrun.dfpt_data["masses"]
    born_charges = vrun.dfpt_data["born_charges"]
    x, y = ir_intensity(
        phonon_eigenvectors=phonon_eigenvectors,
        phonon_eigenvalues=phonon_eigenvalues,
        masses=masses,
        born_charges=born_charges,
    )
    print(max(y))
示例#13
0
文件: test_ir.py 项目: reid-a/jarvis
from jarvis.io.vasp.outputs import Vasprun, Outcar
from jarvis.analysis.phonon.ir import ir_intensity

import os

out = Outcar(
    os.path.join(os.path.dirname(__file__), "..", "..", "io", "vasp",
                 "OUTCAR.JVASP-39"))
vrun = Vasprun(
    os.path.join(os.path.dirname(__file__), "..", "..", "io", "vasp",
                 "vasprun.xml.JVASP-39"))


def test_ir():
    phonon_eigenvectors = vrun.dfpt_data["phonon_eigenvectors"]
    vrun_eigs = vrun.dfpt_data["phonon_eigenvalues"]
    phonon_eigenvalues = out.phonon_eigenvalues
    masses = vrun.dfpt_data["masses"]
    born_charges = vrun.dfpt_data["born_charges"]
    x, y = ir_intensity(
        phonon_eigenvectors=phonon_eigenvectors,
        phonon_eigenvalues=phonon_eigenvalues,
        masses=masses,
        born_charges=born_charges,
    )
    assert x[0] == 713.8676686817399
示例#14
0
from jarvis.analysis.thermodynamics.energetics import form_enp,get_twod_defect_energy
import os
from jarvis.io.vasp.outputs import Vasprun
tmp_xml=os.path.join(os.path.dirname(__file__), "JVASP-667_C_C_c.xml")
vrun=Vasprun(tmp_xml)
def test_get_twod_defect_energy():
  Ef=get_twod_defect_energy(vrun=vrun,jid="JVASP-667",atom="C")
  print (Ef)
def test_form_enp():
   atoms=vrun.all_structures[-1]
   total_energy=vrun.final_energy
   Ef=form_enp(atoms=atoms,total_energy=total_energy)
   print (Ef)
#test_get_twod_defect_energy()
#test_form_enp()

示例#15
0
    def compare_dft_wann(
        self,
        vasprun_path="",
        energy_tol=0.75,
        plot=True,
        kp_labels_points=[],
        kp_labels=[],
        filename="compare.png",
    ):
        """Compare DFT and Wannier bands to check accuracy."""
        vrun = Vasprun(vasprun_path)
        kpoints = vrun.kpoints._kpoints
        fermi = vrun.efermi
        eigs_wan = self.band_structure_eigs(
            kpath=kpoints, efermi=vrun.efermi
        )  # -fermi#[::-1]#.T
        eigs_vrun = vrun.eigenvalues[0][:, :, 0] - fermi  # [::-1]#.T
        nbands = eigs_vrun.shape[1]
        nwann = eigs_wan.shape[1]
        info = {}
        print(
            "eigs.shape,eigs_vrun.shape",
            eigs_wan.shape,
            eigs_vrun.shape,
            nbands,
            nwann,
        )
        min_arr = []
        erange = [-energy_tol, energy_tol]
        for k in range(len(kpoints)):
            for n in eigs_wan[k]:
                diff_arr = []
                if n > erange[0] and n < erange[1]:
                    for v in eigs_vrun[k]:
                        diff = abs(n - v)
                        diff_arr.append(diff)
                if diff_arr != []:
                    tmp = np.min(diff_arr)
                    min_arr.append(tmp)
        maxdiff = "na"
        if min_arr != []:
            # print ('min_arr',min_arr)
            print("MAX diff", max(min_arr))
            maxdiff = max(min_arr)
        print("maxdiff", maxdiff)
        if plot:
            for i, ii in enumerate(eigs_wan.T):
                plt.plot(ii, color="b")
            for i, ii in enumerate(eigs_vrun.T):
                plt.plot(ii, color="r")
            plt.ylim([-energy_tol, energy_tol])
            if kp_labels_points != [] and kp_labels != []:
                plt.xticks(kp_labels_points, kp_labels)

            plt.savefig(filename)
            plt.close()
        info["eigs_wan"] = list(eigs_wan.tolist())
        info["eigs_vrun"] = list(eigs_vrun.tolist())
        info["kp_labels_points"] = list(kp_labels_points)
        info["kp_labels"] = kp_labels
        info["maxdiff"] = maxdiff
        info["efermi"] = fermi
        # print (info)
        return info  # ,eigs_wan.T,eigs_vrun.T
示例#16
0
def single_element_vrun():
    vrun = Vasprun(
        os.path.join(os.path.dirname(__file__), "vasprun.xml.JVASP-816")
    )
    p = vrun.partial_dos_spdf()
示例#17
0
)

if not os.path.isdir(example_fold):
    tar = tarfile.open(example_fold_tgz)
    tar.extractall(example_fold)
    tar.close()


vrun = Vasprun(
    filename=os.path.join(
        os.path.dirname(__file__),
        "..",
        "..",
        "..",
        "..",
        "examples",
        "vasp",
        "SiOptb88",
        "SiOptb88",
        "MAIN-RELAX-bulk@mp_149",
        "vasprun.xml",
    )
)
band_vrun = Vasprun(
    filename=os.path.join(
        os.path.dirname(__file__),
        "..",
        "..",
        "..",
        "..",
        "examples",
示例#18
0
文件: vasp.py 项目: reid-a/jarvis
    def runjob(self):
        """Provide main function for running a generic VASP calculation."""
        # poscar=self.poscar
        # incar=self.incar
        # kpoints=self.kpoints
        # copy_files=self.copy_files

        # cwd = str(os.getcwd())
        if self.jobname == "":
            jobname = str(self.poscar.comment)
        # job_dir = str(self.jobname)
        run_file = (str(os.getcwd()) + str("/") + str(self.jobname) +
                    str(".json"))
        run_dir = str(os.getcwd()) + str("/") + str(self.jobname)
        if self.poscar.comment.startswith("Surf"):
            [a, b, c] = self.kpoints.kpts[0]
            # self.kpoints.kpts = [[a, b, 1]]
            self.kpoints = Kpoints3D(kpoints=[[a, b, 1]])
            try:
                pol = self.poscar.atoms.check_polar
                if pol:
                    COM = self.poscar.atoms.get_center_of_mass()
                    print("COM=", COM)
                    print("Found polar surface,setting dipole corrections")
                    self.incar.update({
                        "LDIPOL":
                        ".TRUE.",
                        "IDIPOL":
                        3,
                        "ISYM":
                        0,
                        "DIPOL":
                        str(COM[0]) + str(" ") + str(COM[2]) + str(" ") +
                        str(COM[2]),
                    })
                    print(
                        "Polar surface encountered in run_job",
                        self.poscar.comment,
                    )
            except Exception:
                pass
        wait = False
        json_file = str(self.jobname) + str(".json")
        print(
            "json should be here=",
            str(os.getcwd()) + str("/") + str(json_file),
        )
        print("json should be=", json_file, run_file, os.getcwd())
        if os.path.exists(str(os.getcwd()) + str("/") + str(json_file)):
            try:
                data_cal = loadjson(
                    str(os.getcwd()) + str("/") + str(json_file))
                tmp_outcar = (str(os.getcwd()) + str("/") +
                              str(json_file.split(".json")[0]) +
                              str("/OUTCAR"))
                print("outcar is", tmp_outcar)
                wait = Outcar(tmp_outcar).converged  # True
                print("outcar status", wait)
                if wait:
                    f_energy = data_cal[0]["final_energy"]
                    contcar = (str(os.getcwd()) + str("/") +
                               str(json_file.split(".json")[0]) +
                               str("/CONTCAR"))
                    return f_energy, contcar
            except Exception:
                pass
        attempt = 0
        while not wait:
            attempt = attempt + 1
            if attempt == self.attempts:
                wait = True
            # print("Setting up POTCAR")
            # if self.potcar is None:
            #  new_symb = list(set(self.poscar.atoms.elements))
            #  self.potcar = Potcar(elements=new_symb, pot_type=self.pot_type)
            if not os.path.exists(run_dir):
                print("Starting new job")
                os.makedirs(run_dir)
                os.chdir(run_dir)
                self.poscar.write_file("POSCAR")
            else:
                os.chdir(run_dir)
                if os.path.isfile("OUTCAR"):
                    try:
                        wait = Outcar(
                            "OUTCAR"
                        ).converged  # Vasprun("vasprun.xml").converged
                        # wait=Vasprun("vasprun.xml").converged
                    except Exception:
                        pass
                    try:
                        self.potcar.write_file("POTCAR")
                        print("FOUND OLD CONTCAR in", os.getcwd())
                        copy_cmd = str("cp CONTCAR POSCAR")
                        self.poscar.write_file("POSCAR")
                        # pos = Poscar.from_file("CONTCAR")
                        print("copy_cmd=", copy_cmd)
                        if ("ELAST" not in jobname
                                and "LEPSILON" not in jobname):
                            # Because in ELASTIC calculations
                            # structures are deformed
                            os.system(copy_cmd)
                        # time.sleep(3)
                    except Exception:
                        pass

            self.incar.write_file("INCAR")
            self.potcar.write_file("POTCAR")
            self.kpoints.write_file("KPOINTS")
            for i in self.copy_files:
                print("copying", i)
                shutil.copy2(i, "./")

            self.run()  # .wait()
            print("Queue 1")
            if os.path.isfile("OUTCAR"):
                try:
                    wait = Outcar(
                        "OUTCAR").converged  # Vasprun("vasprun.xml").converged
                except Exception:
                    pass
            print("End of the first loop", os.getcwd(), wait)

        f_energy = "na"
        # enp = "na"
        contcar = str(os.getcwd()) + str("/") + str("CONTCAR")
        final_str = Poscar.from_file(contcar).atoms
        vrun = Vasprun("vasprun.xml")
        f_energy = float(vrun.final_energy)
        # enp = float(f_energy) / float(final_str.num_atoms)
        # natoms = final_str.num_atoms
        os.chdir("../")
        if wait:
            data_cal = []
            data_cal.append({
                "jobname": self.jobname,
                "poscar": self.poscar.atoms.to_dict(),
                "incar": self.incar.to_dict(),
                "kpoints": self.kpoints.to_dict(),
                "final_energy": (f_energy),
                "contcar": final_str.to_dict(),
            })
            json_file = str(self.jobname) + str(".json")
            f_json = open(json_file, "w")
            f_json.write(json.dumps(data_cal))
            f_json.close()
            print("Wrote json file", f_energy)
            return f_energy, contcar
示例#19
0
文件: inputs.py 项目: zishengz/jarvis
    def __init__(
        self,
        vasprun_path="",
        dos_type="HISTO",
        tmax=1300,
        tgrid=50,
        doping=[],
        run_type="BOLTZ",
        symprec=1e-2,
        energy_grid=0.005,
        lpfac=10,
        energy_span_around_fermi=1.5,
        energy=None,
        struct=None,
        intrans=None,
    ):
        """
        Require following information.

        energy: energy window.

        struct: Atoms object.

        intrans: name of intrans.

        vasprun_path:  path of vasprun file.

        dos_type: type of densit of states.

        tmax: maximum temperature.

        tgrid: temperature grid.

        doping: doping levels

        run_type:

        symprec: symmetry precision.

        energy_grid: energy grid.

        lpfac:

        energy_span_around_fermi:

        """
        self.energy = energy
        self.struct = struct
        self.intrans = intrans
        self.vasprun_path = vasprun_path
        self.vrun = Vasprun(filename=vasprun_path)
        self.energy_grid = energy_grid
        self.lpfac = lpfac
        self.run_type = run_type
        self.energy_span_around_fermi = energy_span_around_fermi
        self.tmax = tmax
        self.tgrid = tgrid
        self.dos_type = dos_type
        self.doping = doping
        if self.doping == []:
            for d in [1e16, 1e17, 1e18, 1e19, 1e20, 1e21]:
                self.doping.extend([1 * d, 2.5 * d, 5 * d, 7.5 * d])
            self.doping.append(1e22)
示例#20
0
    "vasp",
    "SiOptb88",
)

if not os.path.isdir(example_fold):
    tar = tarfile.open(example_fold_tgz)
    tar.extractall(example_fold)
    tar.close()

vrun = Vasprun(filename=os.path.join(
    os.path.dirname(__file__),
    "..",
    "..",
    "..",
    "..",
    "examples",
    "vasp",
    "SiOptb88",
    "SiOptb88",
    "MAIN-RELAX-bulk@mp_149",
    "vasprun.xml",
))
band_vrun = Vasprun(filename=os.path.join(
    os.path.dirname(__file__),
    "..",
    "..",
    "..",
    "..",
    "examples",
    "vasp",
    "SiOptb88",