Esempio n. 1
0
def test_inputs():
    p = Poscar.from_file(pos)
    print(p)
    td = p.to_dict()
    print("td is:", td)
    fd = Poscar.from_dict(td)
    new_file, filename = tempfile.mkstemp()
    p.write_file(filename)
    i = Incar.from_file(inc)
    i.update({"ENCUT": 1000})
    assert (round(p.atoms.density, 2), i.to_dict()["ISIF"]) == (2.25, "3")
    f = open(pos, "r")
    lines = f.read()
    f.close()
    p = Poscar.from_string(lines)
    assert (round(p.atoms.density, 2), i.to_dict()["ISIF"]) == (2.25, "3")
    d = i.to_dict()
    ii = Incar.from_dict(d)
    pot = os.path.join(
        os.path.dirname(__file__), "POT_GGA_PAW_PBE", "Xe", "POTCAR",
    )
    potc = IndividualPotcarData.from_file(pot)
    print(potc)
    os.environ["JARVIS_VASP_PSP_DIR"] = os.path.join(os.path.dirname(__file__))
    new_file, filename = tempfile.mkstemp()
    pot = Potcar(elements=["Xe"])
    td = pot.to_dict()
    fd = Potcar.from_dict(td)
    print(pot)
    pot.write_file(filename)
Esempio n. 2
0
def test_cal():
    box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
    coords = [[0, 0, 0], [0.25, 0.2, 0.25]]
    elements = ["Si", "Si"]
    atoms = Atoms(lattice_mat=box, coords=coords, elements=elements)
    decorated_atoms, hall_number, wsymbols = get_selective_dyn_decorated_atoms(
        atoms)
    print(decorated_atoms)
    p = Poscar(decorated_atoms)
    p.write_file('POSCAR')
    #p2 = Poscar.from_file('POSCAR')
    #print (p2)
    assert (wsymbols, hall_number) == (["i", "i"], 63)
Esempio n. 3
0
def get_wann_electron(jid="JVASP-816"):
    """Download electron WTBH if available."""
    w = ""
    ef = ""
    fls = data("raw_files")
    for i in fls["WANN"]:
        if i["name"].split(".zip")[0] == jid:
            r = requests.get(i["download_url"])
            z = zipfile.ZipFile(io.BytesIO(r.content))
            wdat = z.read("wannier90_hr.dat").decode("utf-8")
            js_file = jid + ".json"
            js = z.read(js_file).decode("utf-8")
            fd, path = tempfile.mkstemp()
            with os.fdopen(fd, "w") as tmp:
                tmp.write(wdat)
            w = WannierHam(path)
            fd, path = tempfile.mkstemp()
            with os.fdopen(fd, "w") as tmp:
                tmp.write(js)
            d = loadjson(path)
            ef = d["info_mesh"]["efermi"]
            fd, path = tempfile.mkstemp()
            pos = z.read("POSCAR").decode("utf-8")
            with os.fdopen(fd, "w") as tmp:
                tmp.write(pos)
            atoms = Poscar.from_file(path).atoms
    return w, ef, atoms
Esempio n. 4
0
    def elastic(
        self,
        mat=None,
        encut=None,
        nbands=None,
        potim=0.015,
        npar=None,
        length=20,
    ):
        """
        Use for elastic property calculations using IBRION = 6.

        Enforces conventional standard structure.

        Args:
            mat :  Poscar object

            encut :  Plane-wave cut-off, 1.3 times will be used

            nbands : number of bands, generally high-value recommended

            npar : NPAR tag, see VASP manual, set it as number of cores

            length :  K-points in length unit
        """
        incar = self.use_incar_dict
        cvn = Spacegroup3D(mat.atoms).conventional_standard_structure
        comment = mat.comment
        p = Poscar(cvn, comment=comment)

        if npar is not None:
            incar.update({"NPAR": npar})

        if nbands is not None:
            nbands = int(nbands * 3)
            incar.update({"NBANDS": nbands})
        data = {
            "ENCUT": 1.3 * float(encut),
            "NEDOS": 5000,
            "ISIF": 3,
            "POTIM": potim,
            "ISPIN": 2,
            "IBRION": 6,
            "LCHARG": ".FALSE.",
        }
        incar.update(data)
        kpoints = Kpoints().automatic_length_mesh(
            lattice_mat=p.atoms.lattice_mat,
            length=length)  # Auto_Kpoints(mat=mat, length=length)

        en, contcar = VaspJob(
            poscar=p,
            incar=incar,
            pot_type=self.pot_type,
            kpoints=kpoints,
            jobname=str("MAIN-ELASTIC-") + str(p.comment.split()[0]),
        ).runjob()

        return en, contcar
Esempio n. 5
0
def test_input():
    p = Poscar.from_file(pos).atoms
    wtin = WTin(wtin=wtin_file, atoms=p, wannierout=wout).write_wt_in()
    wtc = WTin(wtin=wtin_file, atoms=p, wannierout=wout)
    td = wtc.to_dict()
    fd = WTin.from_dict(td)
    assert (os.path.isfile(wtin_file)) == (True)
    os.remove(wtin_file)
Esempio n. 6
0
 def from_dict(self, d={}):
     """Load from dictionary."""
     job = JobFactory(
         use_incar_dict=d["use_incar_dict"],
         pot_type=d["pot_type"],
         vasp_cmd=d["vasp_cmd"],
         copy_files=d["copy_files"],
         attempts=d["attempts"],
         stderr_file=d["stderr_file"],
         output_file=d["output_file"],
         poscar=Poscar.from_dict(d["poscar"]),
     )
     return job
Esempio n. 7
0
def test_2d_interface():
    jids = [
        "JVASP-649",
        "JVASP-652",
        "JVASP-658",
        "JVASP-664",
        "JVASP-688",
        "JVASP-6841",
        "JVASP-5983",
        "JVASP-60244",
        "JVASP-60389",
        "JVASP-76195",
    ]
    # jids = ["JVASP-652", "JVASP-664"]
    jids = ["JVASP-76195", "JVASP-5983"]
    jids = ["JVASP-76195", "JVASP-60389"]
    # jids = ["JVASP-76195", "JVASP-60244"]
    jids = ["JVASP-688", "JVASP-664"]
    jids = ["JVASP-652", "JVASP-646"]
    jids = ["JVASP-652", "JVASP-658"]  # WS2,WSe2
    count = 0
    for i in jids:
        for j in jids:
            if count < 100 and i != j:
                # try:
                intf = get_2d_hetero_jids(jid1=i, jid2=j)
                if intf.num_atoms < 200:

                    count = count + 1
                    print(i, j)
                    p = Poscar(intf)
                    filename = "POSCAR-" + str(i) + "_" + str(j) + ".vasp"
                    p.comment = "Surf@" + str(i) + "_" + str(j)
                    print(p)
                    # p.write_file(filename)
                    print()
                    print()
                    print()
Esempio n. 8
0
 def from_dict(self, info={}):
     """Load the class from a dictionary."""
     return VaspJob(
         poscar=Poscar.from_dict(info["poscar"]),
         kpoints=Kpoints.from_dict(info["kpoints"]),
         incar=Incar.from_dict(info["incar"]),
         potcar=Potcar.from_dict(info["potcar"]),
         vasp_cmd=info["vasp_cmd"],
         copy_files=info["copy_files"],
         attempts=info["attempts"],
         output_file=info["output_file"],
         stderr_file=info["stderr_file"],
         jobname=info["jobname"],
     )
Esempio n. 9
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)
Esempio n. 10
0
    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)
Esempio n. 11
0
    def read_file(self):
        """Read CHGCAR."""
        f = open(self.filename, "r")
        lines = f.read()
        f.close()
        self.atoms = Poscar.from_string(lines).atoms
        volume = self.atoms.volume
        text = lines.splitlines()
        ng_line = text[self.atoms.num_atoms + 9]
        ng = [int(j) for j in ng_line.split()]
        self.dim = np.array(ng)
        found = self.atoms.num_atoms + 8
        nsets = 0
        for i in text:
            if "augmentation occupancies   1 " in i:
                nsets = nsets + 1
        self.nsets = nsets
        if self.is_spin_orbit():
            ValueError("Not implemeted for spin-orbit calculations yet")
        # print ('nsets=',nsets)

        start = found + 2
        ngs = int(ng[0] * ng[1] * ng[2])
        if ngs % 5 == 0:
            nlines = int(ngs / 5.0)
        else:
            nlines = int(ngs / 5.0) + 1
        end = nlines + start  # +1

        for ii, i in enumerate(text):
            if text[ii] == ng_line:
                start = ii + 1
                end = start + nlines
                chg = self.chg_set(text, start, end, volume, ng)
                self.chg.append(chg)
        self.chg = np.array(self.chg)
Esempio n. 12
0
    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
Esempio n. 13
0
from jarvis.io.wannier.inputs import Wannier90win
from jarvis.core.atoms import Atoms
import os
from jarvis.io.vasp.inputs import Poscar

win = os.path.join(os.path.dirname(__file__), "win.input")

s1 = Poscar.from_file(
    os.path.join(
        os.path.dirname(__file__),
        "..",
        "..",
        "analysis",
        "structure",
        "POSCAR",
    )).atoms
s2 = Poscar.from_file(
    os.path.join(
        os.path.dirname(__file__),
        "..",
        "..",
        "analysis",
        "structure",
        "POSCAR-Cmcm",
    )).atoms
s3 = Poscar.from_file(
    os.path.join(
        os.path.dirname(__file__),
        "..",
        "..",
        "analysis",
Esempio n. 14
0
def test_form_en():
    atoms = Poscar.from_file(p).atoms

    total_energy = -9.974648
    fen = form_enp(atoms=atoms, total_energy=total_energy)
    assert fen == -0.40429
Esempio n. 15
0
    def phonons(self,
                atoms=None,
                lammps_cmd="",
                enforce_c_size=15.0,
                parameters={}):
        """Make Phonon calculation setup."""
        from phonopy import Phonopy
        from phonopy.file_IO import (
            #    parse_FORCE_CONSTANTS,
            write_FORCE_CONSTANTS, )

        bulk = atoms.phonopy_converter()

        dim = get_supercell_dims(atoms, enforce_c_size=enforce_c_size)
        atoms = atoms.make_supercell([dim[0], dim[1], dim[2]])

        Poscar(atoms).write_file("POSCAR")

        atoms = atoms.make_supercell_matrix([dim[0], dim[1], dim[2]])
        Poscar(atoms).write_file("POSCAR-Super.vasp")

        phonon = Phonopy(bulk,
                         [[dim[0], 0, 0], [0, dim[1], 0], [0, 0, dim[2]]])
        print("[Phonopy] Atomic displacements1:", bulk)
        print("[Phonopy] Atomic displacements2:", phonon, dim[0], dim[1],
              dim[2])
        phonon.generate_displacements(distance=0.03)
        disps = phonon.get_displacements()
        print("[Phonopy] Atomic displacements3:", disps)
        for d in disps:
            print("[Phonopy]", d[0], d[1:])
        supercells = phonon.get_supercells_with_displacements()

        # Force calculations by calculator
        set_of_forces = []
        disp = 0
        from ase import Atoms as AseAtoms

        for scell in supercells:
            ase_atoms = AseAtoms(
                symbols=scell.get_chemical_symbols(),
                scaled_positions=scell.get_scaled_positions(),
                cell=scell.get_cell(),
                pbc=True,
            )
            j_atoms = ase_to_atoms(ase_atoms)
            disp = disp + 1

            parameters["control_file"] = "run0.mod"
            a, b, forces = LammpsJob(
                atoms=j_atoms,
                lammps_cmd=lammps_cmd,
                parameters=parameters,
                jobname="disp-" + str(disp),
            ).runjob()
            print("forces=", forces)
            drift_force = forces.sum(axis=0)
            print("drift forces=", drift_force)
            # Simple translational invariance
            for force in forces:
                force -= drift_force / forces.shape[0]
            set_of_forces.append(forces)
        phonon.produce_force_constants(forces=set_of_forces)

        write_FORCE_CONSTANTS(phonon.get_force_constants(),
                              filename="FORCE_CONSTANTS")
        print()
        print("[Phonopy] Phonon frequencies at Gamma:")
Esempio n. 16
0
from jarvis.analysis.structure.spacegroup import (
    Spacegroup3D,
    symmetrically_distinct_miller_indices,
    get_wyckoff_position_operators,
)
from jarvis.core.atoms import Atoms
from jarvis.io.vasp.inputs import Poscar
import os
from collections import defaultdict
from jarvis.db.jsonutils import loadjson

s1 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "..", "defects",
                 "POSCAR-667.vasp")).atoms
s2 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "..", "..", "io", "wannier",
                 "POSCAR")).atoms
s3 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "POSCAR-tetragonal")).atoms
s4 = Poscar.from_file(os.path.join(os.path.dirname(__file__),
                                   "POSCAR-Cmcm")).atoms
s5 = Poscar.from_file(os.path.join(os.path.dirname(__file__),
                                   "POSCAR-Aem2")).atoms
s6 = Poscar.from_file(os.path.join(os.path.dirname(__file__),
                                   "POSCAR-C2m")).atoms
s7 = Poscar.from_file(os.path.join(os.path.dirname(__file__),
                                   "POSCAR-Pc")).atoms
s8 = Poscar.from_file(os.path.join(os.path.dirname(__file__),
                                   "POSCAR-P-1")).atoms
s9 = Poscar.from_file(os.path.join(os.path.dirname(__file__),
                                   "POSCAR-P21m")).atoms
Esempio n. 17
0
    get_orbitals,
)
import os
import tempfile
from jarvis.core.kpoints import generate_kgrid
from jarvis.io.vasp.inputs import Poscar
import matplotlib.pyplot as plt

plt.switch_backend("agg")

new_file, filename = tempfile.mkstemp()
atoms = Poscar.from_file(
    os.path.join(
        os.path.dirname(__file__),
        "..",
        "..",
        "analysis",
        "structure",
        "POSCAR",
    )).atoms
wann_soc_win_hr = os.path.join(os.path.dirname(__file__), "wannier90_hr.dat")
wann_wout = os.path.join(os.path.dirname(__file__), "wannier90.wout")
soc_scfband_vrun = os.path.join(os.path.dirname(__file__),
                                "vasprun.xml")  # for JVASP-1067


def test_outputs_bi2se3():
    pp = get_projectors_for_formula(formula_dict={"Cr": 1, "I": 3})[0]
    orb = get_orbitals()[0]
    x = get_orbitals(
        projection_info=[["Cr", 4, ["s", "d"]], ["I", 3, ["s", "p"]]],
Esempio n. 18
0
import os
from jarvis.tasks.vasp.vasp import JobFactory, write_jobfact_optb88vdw
from jarvis.db.figshare import get_jid_data

tmp_dict = get_jid_data(jid="JVASP-816", dataset="dft_3d")["atoms"]
atoms = Atoms.from_dict(tmp_dict)

vasp_cmd = "mpirun /users/knc6/VASP/vasp54/src/vasp.5.4.1DobbySOC2/bin/vasp_std"
copy_files = ["/users/knc6/bin/vdw_kernel.bindat"]
submit_cmd = ["qsub", "submit_job"]
jids = ["JVASP-1002", "JVASP-1067"]

for jid in jids:
    d = get_jid_data(jid=jid, dataset="dft_3d")
    atoms = Atoms.from_dict(d["atoms"]).get_primitive_atoms
    mat = Poscar(atoms)
    mat.comment = "bulk@" + str(jid)
    cwd_home = os.getcwd()
    dir_name = d["jid"] + "_" + str("PBEBO")
    if not os.path.exists(dir_name):
        os.makedirs(dir_name)
    os.chdir(dir_name)
    job = JobFactory(
        vasp_cmd=vasp_cmd,
        poscar=mat,
        copy_files=copy_files,
    )
    dumpjson(data=job.to_dict(), filename="job_fact.json")
    write_jobfact_optb88vdw(pyname="job_fact.py", job_json="job_fact.json")

    # Example job commands, need to change based on your cluster
Esempio n. 19
0
def test_2d():
    p = Poscar.from_file(C).atoms
    vacs = Vacancy(atoms=p).generate_defects(enforce_c_size=10.0, extend=1)
    # print (vacs[0]._defect_structure)
    assert (Atoms.from_dict(
        vacs[0].to_dict()["defect_structure"]).num_atoms == 49)
Esempio n. 20
0
    def write_poscar(self, filename="POSCAR"):
        """Write POSCAR format file from Atoms object."""
        from jarvis.io.vasp.inputs import Poscar

        pos = Poscar(self)
        pos.write_file(filename)
Esempio n. 21
0
    def from_poscar(self, filename="POSCAR"):
        """Read POSCAR/CONTCAR file from to make Atoms object."""
        from jarvis.io.vasp.inputs import Poscar

        return Poscar.from_file(filename).atoms
Esempio n. 22
0
from jarvis.core.kpoints import (
    Kpoints3D,
    generate_kpath,
    generate_kgrid,
    HighSymmetryKpoint3DFactory,
)
from jarvis.analysis.structure.spacegroup import Spacegroup3D
from jarvis.core.atoms import Atoms
from jarvis.io.vasp.inputs import Poscar
import os
import tempfile

s1 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "..", "analysis", "structure",
                 "POSCAR")).atoms
s2 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "..", "analysis", "structure",
                 "POSCAR-Aem2")).atoms
s3 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "..", "analysis", "structure",
                 "POSCAR-C2m")).atoms
s4 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "..", "analysis", "structure",
                 "POSCAR-Cmcm")).atoms
s5 = Poscar.from_file(
    os.path.join(os.path.dirname(__file__), "..", "analysis", "structure",
                 "POSCAR-P-1")).atoms
s6 = Poscar.from_file(
    os.path.join(
        os.path.dirname(__file__),
        "..",