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


Python vasp_input.Incar类代码示例

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


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

示例1: get_incar

    def get_incar(self, structure):
        incar = Incar()
        if self.sort_structure:
            structure = structure.get_sorted_structure()
        comp = structure.composition
        elements = sorted([el for el in comp.elements if comp[el] > 0],
                          key=lambda e: e.X)
        most_electroneg = elements[-1].symbol
        poscar = Poscar(structure)
        for key, setting in self.incar_settings.items():
            if key == "MAGMOM":
                mag = []
                for site in structure:
                    if hasattr(site, 'magmom'):
                        mag.append(site.magmom)
                    elif hasattr(site.specie, 'spin'):
                        mag.append(site.specie.spin)
                    elif str(site.specie) in setting:
                        mag.append(setting.get(str(site.specie)))
                    else:
                        mag.append(setting.get(site.specie.symbol, 0.6))
                incar[key] = mag
            elif key in ('LDAUU', 'LDAUJ', 'LDAUL'):
                if most_electroneg in setting.keys():
                    incar[key] = [setting[most_electroneg].get(sym, 0)
                                  for sym in poscar.site_symbols]
                else:
                    incar[key] = [0] * len(poscar.site_symbols)
            elif key == "EDIFF":
                if self.ediff_per_atom:
                    incar[key] = float(setting) * structure.num_sites
                else:
                    incar[key] = float(setting)
            else:
                incar[key] = setting

        has_u = ("LDAUU" in incar and sum(incar['LDAUU']) > 0)
        if has_u:
            # modify LMAXMIX if LSDA+U and you have d or f electrons
            # note that if the user explicitly sets LMAXMIX in settings it will
            # override this logic.
            if 'LMAXMIX' not in self.incar_settings.keys():
                # contains f-electrons
                if any([el.Z > 56 for el in structure.composition]):
                    incar['LMAXMIX'] = 6
                # contains d-electrons
                elif any([el.Z > 20 for el in structure.composition]):
                    incar['LMAXMIX'] = 4
        else:
            for key in incar.keys():
                if key.startswith('LDAU'):
                    del incar[key]

        if self.set_nupdown:
            nupdown = sum([mag if abs(mag) > 0.6 else 0
                           for mag in incar['MAGMOM']])
            incar['NUPDOWN'] = nupdown

        return incar
开发者ID:brendaneng1,项目名称:pymatgen,代码行数:59,代码来源:vaspio_set.py

示例2: run_task

    def run_task(self, fw_spec):
        chgcar_start = False
        # read the VaspInput from the previous run

        poscar = Poscar.from_file(zpath('POSCAR'))
        incar = Incar.from_file(zpath('INCAR'))

        # figure out what GGA+U values to use and override them
        # LDAU values to use
        mpvis = MPVaspInputSet()
        ggau_incar = mpvis.get_incar(poscar.structure).to_dict
        incar_updates = {k: ggau_incar[k] for k in ggau_incar.keys() if 'LDAU' in k}

        for k in ggau_incar:
            # update any parameters not set explicitly in previous INCAR
            if k not in incar and k in ggau_incar:
                incar_updates[k] = ggau_incar[k]

        incar.update(incar_updates)  # override the +U keys


        # start from the CHGCAR of previous run
        if os.path.exists('CHGCAR'):
            incar['ICHARG'] = 1
            chgcar_start = True

        # write back the new INCAR to the current directory
        incar.write_file('INCAR')
        return FWAction(stored_data={'chgcar_start': chgcar_start})
开发者ID:matk86,项目名称:MPWorks,代码行数:29,代码来源:vasp_setup_tasks.py

示例3: check_incar

def check_incar(task_type):
    errors = []
    incar = Incar.from_file("INCAR")

    if 'static' in task_type or 'Uniform' in task_type or 'band structure' in task_type:
        if incar["IBRION"] != -1:
            errors.append("IBRION should be -1 for non structure optimization runs")

        if "NSW" in incar and incar["NSW"] != 0:
            errors.append("NSW must be 0 for non structure optimization runs")

    if 'static' in task_type and not incar["LCHARG"]:
            errors.append("LCHARG must be True for static runs")

    if 'Uniform' in task_type and incar["ICHARG"]!=11:
            errors.append("ICHARG must be 11 for Uniform runs")

    if 'band structure' in task_type and incar["ICHARG"]!=11:
            errors.append("ICHARG must be 11 for band structure runs")

    if 'GGA+U' in task_type:
        # check LDAU
        if not incar["LDAU"]:
            errors.append("GGA+U requires LDAU parameter")

        if not incar["LMAXMIX"] >= 4:
            errors.append("GGA+U requires LMAXMIX >= 4")

        if not sum(incar["LDAUU"]) > 0:
            errors.append("GGA+U requires sum(LDAUU)>0")

    return errors
开发者ID:ctoher,项目名称:MPWorks,代码行数:32,代码来源:custodian_task.py

示例4: test_init

 def test_init(self):
     filepath = os.path.join(test_dir, "INCAR")
     incar = Incar.from_file(filepath)
     incar["LDAU"] = "T"
     self.assertEqual(incar["ALGO"], "Damped", "Wrong Algo")
     self.assertEqual(float(incar["EDIFF"]), 1e-4, "Wrong EDIFF")
     self.assertEqual(type(incar["LORBIT"]), int)
开发者ID:sikisis,项目名称:pymatgen,代码行数:7,代码来源:test_vasp_input.py

示例5: test_write

    def test_write(self):
        tmp_dir = "VaspInput.testing"
        self.vinput.write_input(tmp_dir)

        filepath = os.path.join(tmp_dir, "INCAR")
        incar = Incar.from_file(filepath)
        self.assertEqual(incar["NSW"], 99)

        for name in ("INCAR", "POSCAR", "POTCAR", "KPOINTS"):
            os.remove(os.path.join(tmp_dir, name))

        os.rmdir(tmp_dir)
开发者ID:ychaojia,项目名称:pymatgen,代码行数:12,代码来源:test_vasp_input.py

示例6: test_diff

 def test_diff(self):
     incar = self.incar
     filepath1 = os.path.join(test_dir, 'INCAR')
     incar1 = Incar.from_file(filepath1)
     filepath2 = os.path.join(test_dir, 'INCAR.2')
     incar2 = Incar.from_file(filepath2)
     self.assertEqual(
         incar1.diff(incar2),
         {'Different': {
             'NELM': {'INCAR1': None, 'INCAR2': 100},
             'ISPIND': {'INCAR1': 2, 'INCAR2': None},
             'LWAVE': {'INCAR1': True, 'INCAR2': False},
             'LDAUPRINT': {'INCAR1': None, 'INCAR2': 1},
             'MAGMOM': {'INCAR1': [6, -6, -6, 6, 0.6, 0.6, 0.6,
                                   0.6, 0.6, 0.6, 0.6, 0.6,
                                   0.6, 0.6, 0.6, 0.6, 0.6,
                                   0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6],
                        'INCAR2': None},
             'NELMIN': {'INCAR1': None, 'INCAR2': 3},
             'ENCUTFOCK': {'INCAR1': 0.0, 'INCAR2': None},
             'HFSCREEN': {'INCAR1': 0.207, 'INCAR2': None},
             'LSCALU': {'INCAR1': False, 'INCAR2': None},
             'ENCUT': {'INCAR1': 500, 'INCAR2': None},
             'NSIM': {'INCAR1': 1, 'INCAR2': None},
             'ICHARG': {'INCAR1': None, 'INCAR2': 1},
             'NSW': {'INCAR1': 99, 'INCAR2': 51},
             'NKRED': {'INCAR1': 2, 'INCAR2': None},
             'NUPDOWN': {'INCAR1': 0, 'INCAR2': None},
             'LCHARG': {'INCAR1': True, 'INCAR2': None},
             'LPLANE': {'INCAR1': True, 'INCAR2': None},
             'ISMEAR': {'INCAR1': 0, 'INCAR2': -5},
             'NPAR': {'INCAR1': 8, 'INCAR2': 1},
             'SYSTEM': {'INCAR1': 'Id=[0] dblock_code=[97763-icsd] formula=[li mn (p o4)] sg_name=[p n m a]',
                        'INCAR2': 'Id=[91090] dblock_code=[20070929235612linio-59.53134651-vasp] formula=[li3 ni3 o6] sg_name=[r-3m]'},
             'ALGO': {'INCAR1': 'Damped', 'INCAR2': 'Fast'},
             'LHFCALC': {'INCAR1': True, 'INCAR2': None},
             'TIME': {'INCAR1': 0.4, 'INCAR2': None}},
          'Same': {'IBRION': 2, 'PREC': 'Accurate', 'ISIF': 3, 'LMAXMIX': 4,
                   'LREAL': 'Auto', 'ISPIN': 2, 'EDIFF': 0.0001,
                   'LORBIT': 11, 'SIGMA': 0.05}})
开发者ID:antoinedewandre,项目名称:pymatgen,代码行数:40,代码来源:test_vasp_input.py

示例7: test_optics

    def test_optics(self):
        if "VASP_PSP_DIR" not in os.environ:
            os.environ["VASP_PSP_DIR"] = test_dir
        self.mpopticsparamset = MPOpticsNonSCFVaspInputSet.from_previous_vasp_run(
            '{}/static_silicon'.format(test_dir), output_dir='optics_test_dir',
            nedos=1145)
        self.assertTrue(os.path.exists('optics_test_dir/CHGCAR'))
        incar = Incar.from_file('optics_test_dir/INCAR')
        self.assertTrue(incar['LOPTICS'])
        self.assertEqual(incar['NEDOS'], 1145)

        #Remove the directory in which the inputs have been created
        shutil.rmtree('optics_test_dir')
开发者ID:bcbwilla,项目名称:pymatgen,代码行数:13,代码来源:test_vaspio_set.py

示例8: setup

    def setup(self):
        """
        Performs initial setup for VaspJob, including overriding any settings
        and backing up.
        """
        files = os.listdir(".")
        num_structures = 0
        if not set(files).issuperset(VASP_INPUT_FILES):
            for f in files:
                try:
                    struct = read_structure(f)
                    num_structures += 1
                except:
                    pass
            if num_structures != 1:
                raise RuntimeError("{} structures found. Unable to continue."
                                   .format(num_structures))
            else:
                self.default_vis.write_input(struct, ".")

        if self.backup:
            for f in VASP_INPUT_FILES:
                shutil.copy(f, "{}.orig".format(f))

        if self.auto_npar:
            try:
                incar = Incar.from_file("INCAR")
                #Only optimized NPAR for non-HF and non-RPA calculations.
                if not (incar.get("LHFCALC") or incar.get("LRPA") or
                        incar.get("LEPSILON")):
                    if incar.get("IBRION") in [5, 6, 7, 8]:
                        # NPAR should not be set for Hessian matrix
                        # calculations, whether in DFPT or otherwise.
                        del incar["NPAR"]
                    else:
                        import multiprocessing
                        # try sge environment variable first
                        # (since multiprocessing counts cores on the current machine only)
                        ncores = os.environ.get('NSLOTS') or multiprocessing.cpu_count()
                        ncores = int(ncores)
                        for npar in range(int(round(math.sqrt(ncores))),
                                          ncores):
                            if ncores % npar == 0:
                                incar["NPAR"] = npar
                                break
                    incar.write_file("INCAR")
            except:
                pass

        if self.settings_override is not None:
            VaspModder().apply_actions(self.settings_override)
开发者ID:cnk118,项目名称:custodian,代码行数:51,代码来源:jobs.py

示例9: setUp

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

示例10: check

 def check(self):
     incar = Incar.from_file("INCAR")
     self.errors = set()
     with open(self.output_filename, "r") as f:
         for line in f:
             l = line.strip()
             for err, msgs in VaspErrorHandler.error_msgs.items():
                 for msg in msgs:
                     if l.find(msg) != -1:
                         # this checks if we want to run a charged
                         # computation (e.g., defects) if yes we don't
                         # want to kill it because there is a change in e-
                         # density (brmix error)
                         if err == "brmix" and 'NELECT' in incar:
                             continue
                         self.errors.add(err)
     return len(self.errors) > 0
开发者ID:image-tester,项目名称:custodian,代码行数:17,代码来源:handlers.py

示例11: postprocess

    def postprocess(self):
        """
        Postprocessing includes renaming and gzipping where necessary.
        Also copies the magmom to the incar if necessary
        """
        for f in VASP_OUTPUT_FILES + [self.output_file]:
            if os.path.exists(f):
                if self.final and self.suffix != "":
                    shutil.move(f, "{}{}".format(f, self.suffix))
                elif self.suffix != "":
                    shutil.copy(f, "{}{}".format(f, self.suffix))

        if self.copy_magmom and not self.final:
            try:
                outcar = Outcar("OUTCAR")
                magmom = [m['tot'] for m in outcar.magnetization]
                incar = Incar.from_file("INCAR")
                incar['MAGMOM'] = magmom
                incar.write_file("INCAR")
            except:
                logging.error('MAGMOM copy from OUTCAR to INCAR failed')

        if self.gzipped:
            gzip_dir(".")
开发者ID:image-tester,项目名称:custodian,代码行数:24,代码来源:jobs.py

示例12: get_calibration_task

def get_calibration_task(structure, phase="CalibrateBulk", \
                         slab_interface_params={'hkl':[1,0,0], 'ligand': None},\
                         turn_knobs={}, incar_params={}, other_params={}):
    """
    returns general calibration task for a structure
    
    Args:
        structure    : pymatgen structure to be calibrated (can be a bulk, ligand, slab
                       or interface)  
        phase        : calibration type, viz. CalibrateBulk, CalibrateMolecule,
                       CalibrateSlab, CalibrateInterface
        hkl          : in case of Slab and Interface miller indices of facet 
        turn_knobs   : specifies the parameters to be calibrated 
        incar_params : dictionary of additional incar parameters, refer defined 
                       incar_dict for defaults 
        other_params : other parameters for calibration, viz. job_dir, is_matrix, etc. 
                       described in the calibrate module
    """
    #structure definition 
    
    poscar = Poscar(structure)
    incar_dict = { 'SYSTEM': 'slab',
                   'ENCUT': 500, 
                   'ISIF': 2, 
                   'IBRION': 2, 
                   'ISMEAR': 1, 
                   'EDIFF': 1e-05, 
                   'NPAR': 4, 
                   'SIGMA': 0.1, 
                   'PREC': 'Accurate'
                 }
    if incar_params: 
        incar_dict.update(incar_params)
    incar = Incar.from_dict(incar_dict)
    kpoints = Kpoints.monkhorst_automatic(kpts=(8, 8, 1))
    que  = { 'nnodes':1,
             'nprocs':16,
             'walltime':'48:00:00',
             'job_bin': '/home/km468/Software/VASP/vaspsol_kappa.5.3.5/vasp'             
            }
    # calibration task: relax hkl
    calparams = {}
    calparams['calibrate'] = phase
    calparams['incar'] = incar.as_dict()
    calparams['poscar'] = poscar.as_dict()
    calparams['kpoints'] = kpoints.as_dict()
    calparams['que_params'] = que
    calparams['turn_knobs'] = turn_knobs
    if phase == 'CalibrateSlab':
         calparams['system'] = {'hkl':slab_interface_params['hkl'],
                                'ligand':slab_interface_params['ligand']
                               }
    elif phase == 'CalibrateInterface':
         calparams['system'] = {'hkl':hkl,
                                'ligand':structure.ligand.reduced_formula
                               }
    calparams['other_params'] = {
        'is_matrix':False,
        'from_ase':True,
        'Grid_type':'M'
        }
    if other_params:
        calparams['other_params'].update(other_params)
    return MPINTCalibrateTask(calparams)
开发者ID:JARVIS-Unifies,项目名称:MPInterfaces,代码行数:64,代码来源:ligand_workflow.py

示例13: MPRester

from pymatgen.matproj.rest import MPRester
from pymatgen.io.vaspio_set import MPVaspInputSet, DictVaspInputSet
from pymatgen.io.vaspio.vasp_input import Kpoints,Incar
from pymatgen.io.vaspio.vasp_output import Outcar, Vasprun
import os

if __name__ == '__main__':
    mpr = MPRester(api_key="UhlZvcEux2kmJSQx")

id_expgap = open("ids.txt", "r")

for line in id_expgap:
    words=line.split()
    print words
    id_line=words[0]
    vasp_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), str(id_line))
    vasp_run = Vasprun(os.path.join(vasp_dir,"vasprun.xml")).to_dict
    nelect = int(vasp_run['input']['parameters']['NELECT'])
    nband = nelect * 6 +96 - nelect % 96 

    os.chdir(id_line)
    #s = mpr.get_structure_by_material_id(id_line)
    user_incar_settings={"ALGO":'Exact',"NSW":0,"NELM":1,"NBANDS":nband,"LOPTICS":True,"LWAVE":True}
    mpvis = MPVaspInputSet(user_incar_settings=user_incar_settings)
    incar = Incar.from_file(os.path.join(vasp_dir,"INCAR"))
    incar.update(user_incar_settings)
    incar.write_file('INCAR')
    os.chdir('..')
id_expgap.close()
开发者ID:qimin,项目名称:python_script,代码行数:29,代码来源:PBE_2nd.py

示例14: test_diff

 def test_diff(self):
     filepath1 = os.path.join(test_dir, "INCAR")
     incar1 = Incar.from_file(filepath1)
     filepath2 = os.path.join(test_dir, "INCAR.2")
     incar2 = Incar.from_file(filepath2)
     self.assertEqual(
         incar1.diff(incar2),
         {
             "Different": {
                 "NELM": {"INCAR1": None, "INCAR2": 100},
                 "ISPIND": {"INCAR1": 2, "INCAR2": None},
                 "LWAVE": {"INCAR1": True, "INCAR2": False},
                 "LDAUPRINT": {"INCAR1": None, "INCAR2": 1},
                 "MAGMOM": {
                     "INCAR1": [
                         6,
                         -6,
                         -6,
                         6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                         0.6,
                     ],
                     "INCAR2": None,
                 },
                 "NELMIN": {"INCAR1": None, "INCAR2": 3},
                 "ENCUTFOCK": {"INCAR1": 0.0, "INCAR2": None},
                 "HFSCREEN": {"INCAR1": 0.207, "INCAR2": None},
                 "LSCALU": {"INCAR1": False, "INCAR2": None},
                 "ENCUT": {"INCAR1": 500, "INCAR2": None},
                 "NSIM": {"INCAR1": 1, "INCAR2": None},
                 "ICHARG": {"INCAR1": None, "INCAR2": 1},
                 "NSW": {"INCAR1": 99, "INCAR2": 51},
                 "NKRED": {"INCAR1": 2, "INCAR2": None},
                 "NUPDOWN": {"INCAR1": 0, "INCAR2": None},
                 "LCHARG": {"INCAR1": True, "INCAR2": None},
                 "LPLANE": {"INCAR1": True, "INCAR2": None},
                 "ISMEAR": {"INCAR1": 0, "INCAR2": -5},
                 "NPAR": {"INCAR1": 8, "INCAR2": 1},
                 "SYSTEM": {
                     "INCAR1": "Id=[0] dblock_code=[97763-icsd] formula=[li mn (p o4)] sg_name=[p n m a]",
                     "INCAR2": "Id=[91090] dblock_code=[20070929235612linio-59.53134651-vasp] formula=[li3 ni3 o6] sg_name=[r-3m]",
                 },
                 "ALGO": {"INCAR1": "Damped", "INCAR2": "Fast"},
                 "LHFCALC": {"INCAR1": True, "INCAR2": None},
                 "TIME": {"INCAR1": 0.4, "INCAR2": None},
             },
             "Same": {
                 "IBRION": 2,
                 "PREC": "Accurate",
                 "ISIF": 3,
                 "LMAXMIX": 4,
                 "LREAL": "Auto",
                 "ISPIN": 2,
                 "EDIFF": 0.0001,
                 "LORBIT": 11,
                 "SIGMA": 0.05,
             },
         },
     )
开发者ID:sikisis,项目名称:pymatgen,代码行数:77,代码来源:test_vasp_input.py

示例15: test_to_dict_and_from_dict

 def test_to_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, "INCAR")
     incar = Incar.from_file(file_name)
     d = incar.to_dict
     incar2 = Incar.from_dict(d)
     self.assertEqual(incar, incar2)
开发者ID:sikisis,项目名称:pymatgen,代码行数:6,代码来源:test_vasp_input.py


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