Exemple #1
0
def generate_files(args):
    from pymatgen.io.vaspio.vasp_input import Potcar
    if args.symbols:
        try:
            p = Potcar(args.symbols, functional=args.functional)
            p.write_file("POTCAR")
        except Exception as ex:
            print("An error has occurred: {}".format(str(ex)))

    else:
        print("No valid options selected.")
Exemple #2
0
def generate_files(args):
    from pymatgen.io.vaspio.vasp_input import Potcar
    if args.symbols:
        try:
            p = Potcar(args.symbols, functional=args.functional)
            p.write_file("POTCAR")
        except Exception as ex:
            print "An error has occurred: {}".format(str(ex))

    else:
        print "No valid options selected."
Exemple #3
0
 def get_potcar(self, structure):
     """
     Method for getting LDA potcars
     """
     if self.sort_structure:
         structure = structure.get_sorted_structure()
     return Potcar(self.get_potcar_symbols(structure), functional=self.functional)
Exemple #4
0
 def setUp(self):
     if "VASP_PSP_DIR" not in os.environ:
         test_potcar_dir = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..", "..",
                          "test_files"))
         os.environ["VASP_PSP_DIR"] = test_potcar_dir
     filepath = os.path.join(test_dir, 'POTCAR')
     self.potcar = Potcar.from_file(filepath)
Exemple #5
0
 def setUp(self):
     if "VASP_PSP_DIR" not in os.environ:
         test_potcar_dir = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "test_files")
         )
         os.environ["VASP_PSP_DIR"] = test_potcar_dir
     filepath = os.path.join(test_dir, "POTCAR")
     self.potcar = Potcar.from_file(filepath)
Exemple #6
0
 def test_potcar_map(self):
     fe_potcar = zopen(os.path.join(test_dir, "POT_GGA_PAW_PBE",
                                    "POTCAR.Fe_pv.gz")).read()
     #specify V instead of Fe - this makes sure the test won't pass if the
     #code just grabs the POTCAR from the config file (the config file would
     #grab the V POTCAR)
     potcar = Potcar(["V"], sym_potcar_map={"V": fe_potcar})
     self.assertEqual(potcar.symbols, ["Fe_pv"], "Wrong symbols read in "
                                                 "for POTCAR")
Exemple #7
0
def get_POTCAR(poscar):
    list_postfix = ['_pv','_sv','']

    potcar = Potcar()

    list_potcar_singles = []

    for symbol in poscar.site_symbols:
        for postfix in list_postfix:
            potcar_path = PSEUDOPOTENTIALS_DIRECTORY+'%s%s/POTCAR'%(symbol,postfix)
            if os.path.isfile(potcar_path):

                single = PotcarSingle.from_file(potcar_path)

                list_potcar_singles.append(single)
                potcar.insert(-1,single)

                break

    return list_potcar_singles, potcar
Exemple #8
0
 def __init__(self, chgcar_filename, potcar_filename=None):
     """
     Args:
         chgcar_filename:
             The filename of the CHGCAR.
         potcar_filename:
             Optional: the filename of the corresponding POTCAR file. Used
             for calculating the charge transfer. If None, the
             get_charge_transfer method will raise a ValueError.
     """
     temp_dir = tempfile.mkdtemp()
     self.chgcar = Chgcar.from_file(chgcar_filename)
     self.potcar = Potcar.from_file(potcar_filename) \
         if potcar_filename is not None else None
     self.natoms = self.chgcar.poscar.natoms
     try:
         shutil.copy(chgcar_filename, os.path.join(temp_dir, "CHGCAR"))
         current_dir = os.getcwd()
         os.chdir(temp_dir)
         rs = subprocess.Popen(["bader", "CHGCAR"],
                               stdout=subprocess.PIPE,
                               stdin=subprocess.PIPE,
                               close_fds=True)
         rs.communicate()
         data = []
         with open("ACF.dat") as f:
             raw = f.readlines()
             headers = [s.lower() for s in raw.pop(0).split()]
             raw.pop(0)
             while True:
                 l = raw.pop(0).strip()
                 if l.startswith("-"):
                     break
                 vals = map(float, l.split()[1:])
                 data.append(dict(zip(headers[1:], vals)))
             for l in raw:
                 toks = l.strip().split(":")
                 if toks[0] == "VACUUM CHARGE":
                     self.vacuum_charge = float(toks[1])
                 elif toks[0] == "VACUUM VOLUME":
                     self.vacuum_volume = float(toks[1])
                 elif toks[0] == "NUMBER OF ELECTRONS":
                     self.nelectrons = float(toks[1])
         self.data = data
         os.chdir(current_dir)
     except Exception as ex:
         print str(ex)
     finally:
         shutil.rmtree(temp_dir)
Exemple #9
0
 def setUp(self):
     filepath = os.path.join(test_dir, 'INCAR')
     incar = Incar.from_file(filepath)
     filepath = os.path.join(test_dir, 'POSCAR')
     poscar = Poscar.from_file(filepath)
     if "VASP_PSP_DIR" not in os.environ:
         test_potcar_dir = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..", "..",
                          "test_files"))
         os.environ["VASP_PSP_DIR"] = test_potcar_dir
     filepath = os.path.join(test_dir, 'POTCAR')
     potcar = Potcar.from_file(filepath)
     filepath = os.path.join(test_dir, 'KPOINTS.auto')
     kpoints = Kpoints.from_file(filepath)
     self.vinput = VaspInput(incar, kpoints, poscar, potcar)
Exemple #10
0
 def setUp(self):
     filepath = os.path.join(test_dir, "INCAR")
     incar = Incar.from_file(filepath)
     filepath = os.path.join(test_dir, "POSCAR")
     poscar = Poscar.from_file(filepath)
     if "VASP_PSP_DIR" not in os.environ:
         test_potcar_dir = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "test_files")
         )
         os.environ["VASP_PSP_DIR"] = test_potcar_dir
     filepath = os.path.join(test_dir, "POTCAR")
     potcar = Potcar.from_file(filepath)
     filepath = os.path.join(test_dir, "KPOINTS.auto")
     kpoints = Kpoints.from_file(filepath)
     self.vinput = VaspInput(incar, kpoints, poscar, potcar)
Exemple #11
0
 def __init__(self, chgcar_filename, potcar_filename=None):
     """
     Args:
         chgcar_filename:
             The filename of the CHGCAR.
         potcar_filename:
             Optional: the filename of the corresponding POTCAR file. Used
             for calculating the charge transfer. If None, the
             get_charge_transfer method will raise a ValueError.
     """
     temp_dir = tempfile.mkdtemp()
     self.chgcar = Chgcar.from_file(chgcar_filename)
     self.potcar = Potcar.from_file(potcar_filename) \
         if potcar_filename is not None else None
     self.natoms = self.chgcar.poscar.natoms
     try:
         shutil.copy(chgcar_filename, os.path.join(temp_dir, "CHGCAR"))
         current_dir = os.getcwd()
         os.chdir(temp_dir)
         rs = subprocess.Popen(["bader", "CHGCAR"],
                               stdout=subprocess.PIPE,
                               stdin=subprocess.PIPE, close_fds=True)
         rs.communicate()
         data = []
         with open("ACF.dat") as f:
             raw = f.readlines()
             headers = [s.lower() for s in raw.pop(0).split()]
             raw.pop(0)
             while True:
                 l = raw.pop(0).strip()
                 if l.startswith("-"):
                     break
                 vals = map(float, l.split()[1:])
                 data.append(dict(zip(headers[1:], vals)))
             for l in raw:
                 toks = l.strip().split(":")
                 if toks[0] == "VACUUM CHARGE":
                     self.vacuum_charge = float(toks[1])
                 elif toks[0] == "VACUUM VOLUME":
                     self.vacuum_volume = float(toks[1])
                 elif toks[0] == "NUMBER OF ELECTRONS":
                     self.nelectrons = float(toks[1])
         self.data = data
         os.chdir(current_dir)
     except Exception as ex:
         print str(ex)
     finally:
         shutil.rmtree(temp_dir)
Exemple #12
0
def buildPOTCAR(atname, fpotcar="POTCAR"):
    """
    Build POTCAR file according to atom for wich CL calculation is required. The POTCAR of
    the atom is placed in first postion.
    """
    potcar = Potcar.from_file(fpotcar)
    add = False
    for pot in potcar:
        if pot.symbol == atname:
            newpot = pot
            add = True
            break
    if not add:
        print("Atom " + atname + " not found in POTCAR")
        exit(1)
    else:
        potcar.insert(0, newpot)

    potcar.write_file("POTCAR_CL")
Exemple #13
0
def buildPOTCAR(atname, fpotcar="POTCAR"):
    """
    Build POTCAR file according to atom for wich CL calculation is required. The POTCAR of
    the atom is placed in first postion.
    """
    from pymatgen.io.vaspio.vasp_input import Potcar
    potcar = Potcar.from_file(fpotcar)
    add = False
    for pot in potcar:
        if pot.symbol == atname:
            newpot = pot
            add = True
            break
    if not add:
        print("Atom " + atname + " not found in POTCAR")
        exit(1)
    else:
        potcar.insert(0, newpot)

    potcar.write_file("POTCAR_CL")
Exemple #14
0
 def test_to_from_dict(self):
     d = self.potcar.to_dict
     potcar = Potcar.from_dict(d)
     self.assertEqual(potcar.symbols, ["Fe", "P", "O"])
Exemple #15
0
 def run_task(self, fw_spec):
     Incar.from_dict(fw_spec['vasp']['incar']).write_file('INCAR')
     Poscar.from_dict(fw_spec['vasp']['poscar']).write_file('POSCAR')
     Potcar.from_dict(fw_spec['vasp']['potcar']).write_file('POTCAR')
     Kpoints.from_dict(fw_spec['vasp']['kpoints']).write_file('KPOINTS')
Exemple #16
0
def get_ModifiedMaterialsProject_VASP_inputs(structure, workdir, job_name, nproc=16, 
                                U_strategy_instance = None, supplementary_incar_dict = None):
    """
    Inputs will be inspired by MaterialsProject, but this function is appropriate
    when we are seriously modifying the inputs such that they no longer conform to Materials Project.
    """

    if os.path.exists(workdir):
        print 'WORKDIR ALREADY EXISTS. DELETE TO LAUNCH NEW JOB'
        return -1

    os.mkdir(workdir)

    # let's start with MP
    input_set = MPVaspInputSet()
   
    incar  = input_set.get_incar(structure)

    if U_strategy_instance != None:
        #  reading the structure here insures consistency, rather
        #  than having the strategy read the structure outside this driver.
        U_strategy_instance.read_structure(structure)

        # Generate all LDAU-related variables according to specified strategy.
        LDAU_dict, poscar_need_hack, potcar_need_hack = U_strategy_instance.get_LDAU()

        incar.update(LDAU_dict) 

    # set the number of parallel processors to sqrt(nproc), 
    # as recommended in manual.
    incar.update({'NPAR':int(np.sqrt(nproc))}) 

    if supplementary_incar_dict != None:
        incar.update(supplementary_incar_dict) 

    poscar = input_set.get_poscar(structure)

    kpoints = input_set.get_kpoints(structure)
    potcar = input_set.get_potcar(structure)

    incar.write_file(workdir+'INCAR')
    poscar.write_file(workdir+'POSCAR', vasp4_compatible = True)
    kpoints.write_file(workdir+'KPOINTS')
    potcar.write_file(workdir+'POTCAR')


    if poscar_need_hack:
        # do we need specialized hacking of the poscar because of the U strategy?       
        new_poscar_lines = U_strategy_instance.get_new_poscar_lines()
        with open(workdir+'POSCAR','w') as f:
            for line in new_poscar_lines:
                print >>f, line.strip()

    if potcar_need_hack:
        # do we need specialized hacking of the potcar because of the U strategy?       
        new_potcar_symbols = U_strategy_instance.get_new_potcar_symbols(potcar)
        new_potcar = Potcar(new_potcar_symbols) 
        # overwrite the previous potcar
        new_potcar.write_file(workdir+'POTCAR')

    with open(workdir+'job.sh','w') as f:
        f.write(submit_template.format(job_name,nproc))

    with open(workdir+'clean.sh','w') as f:
        f.write(clean_template)

    return 0
Exemple #17
0
 def test_to_from_dict(self):
     d = self.potcar.to_dict
     potcar = Potcar.from_dict(d)
     self.assertEqual(potcar.symbols, ["Fe", "P", "O"])
Exemple #18
0
 def test_init(self):
     self.assertEqual(self.potcar.symbols, ["Fe", "P", "O"],
                      "Wrong symbols read in for POTCAR")
     potcar = Potcar(["Fe_pv", "O"])
     self.assertEqual(potcar[0].enmax, 293.238)
Exemple #19
0
    def assimilate(self, path):
        files = os.listdir(path)
        try:
            files_to_parse = {}
            if "relax1" in files and "relax2" in files:
                for filename in ("INCAR", "POTCAR", "POSCAR"):
                    search_str = os.path.join(path, "relax1", filename + "*")
                    files_to_parse[filename] = glob.glob(search_str)[0]
                for filename in ("CONTCAR", "OSZICAR"):
                    search_str = os.path.join(path, "relax2", filename + "*")
                    files_to_parse[filename] = glob.glob(search_str)[-1]
            else:
                for filename in (
                    "INCAR", "POTCAR", "CONTCAR", "OSZICAR", "POSCAR", "DYNMAT"
                ):
                    files = glob.glob(os.path.join(path, filename + "*"))
                    if len(files) < 1:
                        continue
                    if len(files) == 1 or filename == "INCAR" or \
                       filename == "POTCAR" or filename == "DYNMAT":
                        files_to_parse[filename] = files[-1]\
                            if filename == "POTCAR" else files[0]
                    elif len(files) > 1:
                        """
                        This is a bit confusing, since there maybe be
                        multiple steps. By default, assimilate will try to find
                        a file simply named filename, filename.bz2, or
                        filename.gz.  Failing which it will try to get a relax2
                        from a custodian double relaxation style run if
                        possible. Or else, a random file is chosen.
                        """
                        for fname in files:
                            if fnmatch.fnmatch(os.path.basename(fname),
                                               "{}(\.gz|\.bz2)*"
                                               .format(filename)):
                                files_to_parse[filename] = fname
                                break
                            if fname == "POSCAR" and \
                                    re.search("relax1", fname):
                                files_to_parse[filename] = fname
                                break
                            if (fname in ("CONTCAR", "OSZICAR") and
                                    re.search("relax2", fname)):
                                files_to_parse[filename] = fname
                                break
                            files_to_parse[filename] = fname

            poscar, contcar, incar, potcar, oszicar, dynmat = [None]*6
            if 'POSCAR' in files_to_parse:
                poscar = Poscar.from_file(files_to_parse["POSCAR"])
            if 'CONTCAR' in files_to_parse:
                contcar = Poscar.from_file(files_to_parse["CONTCAR"])
            if 'INCAR' in files_to_parse:
                incar = Incar.from_file(files_to_parse["INCAR"])
            if 'POTCAR' in files_to_parse:
                potcar = Potcar.from_file(files_to_parse["POTCAR"])
            if 'OSZICAR' in files_to_parse:
                oszicar = Oszicar(files_to_parse["OSZICAR"])
            if 'DYNMAT' in files_to_parse:
                dynmat = Dynmat(files_to_parse["DYNMAT"])

            param = {"hubbards":{}}
            if poscar is not None and incar is not None and "LDAUU" in incar:
                param["hubbards"] = dict(zip(poscar.site_symbols,
                                             incar["LDAUU"]))
            param["is_hubbard"] = (
                incar.get("LDAU", False) and sum(param["hubbards"].values()) > 0
            ) if incar is not None else False
            param["run_type"] = None
            if incar is not None:
                param["run_type"] = "GGA+U" if param["is_hubbard"] else "GGA"
            param["history"] = _get_transformation_history(path)
            param["potcar_spec"] = potcar.spec if potcar is not None else None
            energy = oszicar.final_energy if oszicar is not None else 1e10
            structure = contcar.structure if contcar is not None\
                else poscar.structure
            initial_vol = poscar.structure.volume if poscar is not None else \
                None
            final_vol = contcar.structure.volume if contcar is not None else \
                None
            delta_volume = None
            if initial_vol is not None and final_vol is not None:
                delta_volume = (final_vol / initial_vol - 1)
            data = {"filename": path, "delta_volume": delta_volume}
            if dynmat is not None:
                data['phonon_frequencies'] = dynmat.get_phonon_frequencies()
            if self._inc_structure:
                entry = ComputedStructureEntry(
                    structure, energy, parameters=param, data=data
                )
            else:
                entry = ComputedEntry(
                  structure.composition, energy, parameters=param, data=data
                )
            return entry

        except Exception as ex:
            logger.debug("error in {}: {}".format(path, ex))
            return None
Exemple #20
0
    def assimilate(self, path):
        files = os.listdir(path)
        try:
            files_to_parse = {}
            if "relax1" in files and "relax2" in files:
                for filename in ("INCAR", "POTCAR", "POSCAR"):
                    search_str = os.path.join(path, "relax1", filename + "*")
                    files_to_parse[filename] = glob.glob(search_str)[0]
                for filename in ("CONTCAR", "OSZICAR"):
                    search_str = os.path.join(path, "relax2", filename + "*")
                    files_to_parse[filename] = glob.glob(search_str)[-1]
            else:
                files_to_parse["INCAR"] = glob.glob(os.path.join(path,
                                                                 "INCAR*"))[0]
                files_to_parse["POTCAR"] = glob.glob(
                    os.path.join(path, "POTCAR*"))[-1]

                for filename in ("CONTCAR", "OSZICAR", "POSCAR"):
                    files = glob.glob(os.path.join(path, filename + "*"))
                    if len(files) == 1:
                        files_to_parse[filename] = files[0]
                    elif len(files) > 1:
                        """
                        This is a bit confusing, since there maybe be
                        multiple steps. By default, assimilate will try to find
                        a file simply named filename, filename.bz2, or
                        filename.gz.  Failing which it will try to get a relax2
                        from an aflow style run if possible. Or else, a
                        randomly chosen file is chosen.
                        """
                        for fname in files:
                            if fnmatch.fnmatch(os.path.basename(fname),
                                               "{}(\.gz|\.bz2)*"
                                               .format(filename)):
                                files_to_parse[filename] = fname
                                break
                            if fname == "POSCAR" and \
                                    re.search("relax1", fname):
                                files_to_parse[filename] = fname
                                break
                            if (fname in ("CONTCAR", "OSZICAR") and
                                    re.search("relax2", fname)):
                                files_to_parse[filename] = fname
                                break
                            files_to_parse[filename] = fname

            poscar = Poscar.from_file(files_to_parse["POSCAR"])
            contcar = Poscar.from_file(files_to_parse["CONTCAR"])

            param = {}

            incar = Incar.from_file(files_to_parse["INCAR"])
            if "LDAUU" in incar:
                param["hubbards"] = dict(zip(poscar.site_symbols,
                                             incar["LDAUU"]))
            else:
                param["hubbards"] = {}
            param["is_hubbard"] = \
                incar.get("LDAU", False) and sum(param["hubbards"].values()) > 0
            param["run_type"] = "GGA+U" if param["is_hubbard"] else "GGA"
            potcar = Potcar.from_file(files_to_parse["POTCAR"])
            param["potcar_symbols"] = potcar.symbols
            oszicar = Oszicar(files_to_parse["OSZICAR"])
            energy = oszicar.final_energy
            structure = contcar.structure
            initial_vol = poscar.structure.volume
            final_vol = contcar.structure.volume
            delta_volume = (final_vol / initial_vol - 1)
            data = {"filename": path, "delta_volume": delta_volume}
            if self._inc_structure:
                entry = ComputedStructureEntry(structure, energy,
                                               parameters=param,
                                               data=data)
            else:
                entry = ComputedEntry(structure.composition, energy,
                                      parameters=param, data=data)
            return entry

        except Exception as ex:
            logger.debug("error in {}: {}".format(path, ex))
            return None
 def test_write(self):
     tempfname = "POTCAR.testing"
     self.potcar.write_file(tempfname)
     p = Potcar.from_file(tempfname)
     self.assertEqual(p.symbols, self.potcar.symbols)
     os.remove(tempfname)
Exemple #22
0
 def run_task(self, fw_spec):
     Incar.from_dict(fw_spec['vasp']['incar']).write_file('INCAR')
     Poscar.from_dict(fw_spec['vasp']['poscar']).write_file('POSCAR')
     Potcar.from_dict(fw_spec['vasp']['potcar']).write_file('POTCAR')
     Kpoints.from_dict(fw_spec['vasp']['kpoints']).write_file('KPOINTS')
Exemple #23
0
iface_slab = iface.slab
iface_slab.sort()
#set selective dynamics flags as required
true_site= [1, 1, 1]
false_site= [0, 0, 0]
sd_flag_iface= []
j= 0
sd_flag_slab= []
for i in iface.sites:
	sd_flag_iface.append(false_site)
for i in iface_slab.sites:
        sd_flag_slab.append(false_site)

#POSCAR and POTCAR construction, pending setting of exact flags for POSCAR
interface_poscar = Poscar(iface, selective_dynamics= sd_flag_iface)
interface_potcar= Potcar(interface_poscar.site_symbols)
slab_poscar = Poscar(iface_slab, selective_dynamics= sd_flag_slab)
slab_potcar= Potcar(slab_poscar.site_symbols)

#write the files in appropriate directories 
interface_poscar.write_file("./Interface/POSCAR_PbS100DMF_interface_with_sd.vasp")
slab_poscar.write_file("./Slab/POSCAR_PbS100_slab_with_sd.vasp")
interface_potcar.write_file("./Interface_with_vdw/POTCAR")
slab_potcar.write_file("./Slab_with_vdw/POTCAR")

#set the common INCAR file and KPOINTS
incar_dict = {
                 'SYSTEM': 'ligand_PbS', 
                 'ENCUT': 600, 
                 'ISIF': 2, 
                 'IBRION': 2, 
Exemple #24
0
 def get_potcar(self, structure):
     if self.sort_structure:
         structure = structure.get_sorted_structure()
     return Potcar(self.get_potcar_symbols(structure))
Exemple #25
0
 def get_potcar(self, structure):
     return Potcar(self.get_potcar_symbols(structure))
Exemple #26
0
    def assimilate(self, path):
        files = os.listdir(path)
        try:
            files_to_parse = {}
            if "relax1" in files and "relax2" in files:
                for filename in ("INCAR", "POTCAR", "POSCAR"):
                    search_str = os.path.join(path, "relax1", filename + "*")
                    files_to_parse[filename] = glob.glob(search_str)[0]
                for filename in ("CONTCAR", "OSZICAR"):
                    search_str = os.path.join(path, "relax2", filename + "*")
                    files_to_parse[filename] = glob.glob(search_str)[-1]
            else:
                files_to_parse["INCAR"] = glob.glob(
                    os.path.join(path, "INCAR*"))[0]
                files_to_parse["POTCAR"] = glob.glob(
                    os.path.join(path, "POTCAR*"))[-1]

                for filename in ("CONTCAR", "OSZICAR", "POSCAR"):
                    files = glob.glob(os.path.join(path, filename + "*"))
                    if len(files) == 1:
                        files_to_parse[filename] = files[0]
                    elif len(files) > 1:
                        """
                        This is a bit confusing, since there maybe be
                        multiple steps. By default, assimilate will try to find
                        a file simply named filename, filename.bz2, or
                        filename.gz.  Failing which it will try to get a relax2
                        from an aflow style run if possible. Or else, a
                        randomly chosen file is chosen.
                        """
                        for fname in files:
                            if fnmatch.fnmatch(
                                    os.path.basename(fname),
                                    "{}(\.gz|\.bz2)*".format(filename)):
                                files_to_parse[filename] = fname
                                break
                            if fname == "POSCAR" and \
                                    re.search("relax1", fname):
                                files_to_parse[filename] = fname
                                break
                            if (fname in ("CONTCAR", "OSZICAR")
                                    and re.search("relax2", fname)):
                                files_to_parse[filename] = fname
                                break
                            files_to_parse[filename] = fname

            poscar = Poscar.from_file(files_to_parse["POSCAR"])
            contcar = Poscar.from_file(files_to_parse["CONTCAR"])

            param = {}

            incar = Incar.from_file(files_to_parse["INCAR"])
            if "LDAUU" in incar:
                param["hubbards"] = dict(
                    zip(poscar.site_symbols, incar["LDAUU"]))
            else:
                param["hubbards"] = {}
            param["is_hubbard"] = (incar.get("LDAU", False)
                                   and sum(param["hubbards"].values()) > 0)
            param["run_type"] = "GGA+U" if param["is_hubbard"] else "GGA"
            param["history"] = _get_transformation_history(path)

            potcar = Potcar.from_file(files_to_parse["POTCAR"])
            param["potcar_symbols"] = potcar.symbols
            oszicar = Oszicar(files_to_parse["OSZICAR"])
            energy = oszicar.final_energy
            structure = contcar.structure
            initial_vol = poscar.structure.volume
            final_vol = contcar.structure.volume
            delta_volume = (final_vol / initial_vol - 1)
            data = {"filename": path, "delta_volume": delta_volume}
            if self._inc_structure:
                entry = ComputedStructureEntry(structure,
                                               energy,
                                               parameters=param,
                                               data=data)
            else:
                entry = ComputedEntry(structure.composition,
                                      energy,
                                      parameters=param,
                                      data=data)
            return entry

        except Exception as ex:
            logger.debug("error in {}: {}".format(path, ex))
            return None
Exemple #27
0
 def test_write(self):
     tempfname = "POTCAR.testing"
     self.potcar.write_file(tempfname)
     p = Potcar.from_file(tempfname)
     self.assertEqual(p.symbols, self.potcar.symbols)
     os.remove(tempfname)