当前位置: 首页>>代码示例>>Python>>正文


Python vasp_input.Potcar类代码示例

本文整理汇总了Python中pymatgen.io.vaspio.vasp_input.Potcar的典型用法代码示例。如果您正苦于以下问题:Python Potcar类的具体用法?Python Potcar怎么用?Python Potcar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Potcar类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_files

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.")
开发者ID:czhengsci,项目名称:tscccommand,代码行数:11,代码来源:pmg_example.py

示例2: setUp

 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)
开发者ID:sikisis,项目名称:pymatgen,代码行数:8,代码来源:test_vasp_input.py

示例3: get_POTCAR

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
开发者ID:rousseab,项目名称:VaspDrive,代码行数:20,代码来源:VaspSubmission.py

示例4: __init__

 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)
开发者ID:mathematicus,项目名称:pymatgen,代码行数:48,代码来源:bader_caller.py

示例5: buildPOTCAR

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")
开发者ID:Ambroise-quesne,项目名称:myScripts,代码行数:20,代码来源:makeCL.py

示例6: test_to_from_dict

 def test_to_from_dict(self):
     d = self.potcar.to_dict
     potcar = Potcar.from_dict(d)
     self.assertEqual(potcar.symbols, ["Fe", "P", "O"])
开发者ID:sikisis,项目名称:pymatgen,代码行数:4,代码来源:test_vasp_input.py

示例7: assimilate

    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
开发者ID:jesuansito,项目名称:pymatgen,代码行数:81,代码来源:hive.py

示例8: run_task

 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')
开发者ID:matk86,项目名称:MPWorks,代码行数:5,代码来源:vasp_io_tasks.py

示例9: Poscar

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, 
开发者ID:JARVIS-Unifies,项目名称:MPInterfaces,代码行数:31,代码来源:ligand_PbS_semiauto.py

示例10: test_write

 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)
开发者ID:antoinedewandre,项目名称:pymatgen,代码行数:6,代码来源:test_vasp_input.py

示例11: assimilate

    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
开发者ID:ATNDiaye,项目名称:pymatgen,代码行数:99,代码来源:hive.py

示例12: get_ModifiedMaterialsProject_VASP_inputs

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
开发者ID:rousseab,项目名称:VaspDrive,代码行数:67,代码来源:VaspSubmission.py


注:本文中的pymatgen.io.vaspio.vasp_input.Potcar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。