コード例 #1
0
    def incar(self):
        parent_incar = super(PRLRoughStaticSet, self).incar
        incar = Incar(self.prev_incar) if self.prev_incar is not None else \
            Incar(parent_incar)

        for k in ["MAGMOM", "NUPDOWN"] + list(
                self.kwargs.get("user_incar_settings", {}).keys()):
            # For these parameters as well as user specified settings, override
            # the incar settings.
            if parent_incar.get(k, None) is not None:
                incar[k] = parent_incar[k]
            else:
                incar.pop(k, None)

        # use new LDAUU when possible b/c the Poscar might have changed
        # representation
        if incar.get('LDAU'):
            u = incar.get('LDAUU', [])
            j = incar.get('LDAUJ', [])
            if sum([u[x] - j[x] for x, y in enumerate(u)]) > 0:
                for tag in ('LDAUU', 'LDAUL', 'LDAUJ'):
                    incar.update({tag: parent_incar[tag]})
            # ensure to have LMAXMIX for GGA+U static run
            if "LMAXMIX" not in incar:
                incar.update({"LMAXMIX": parent_incar["LMAXMIX"]})

        # Compare ediff between previous and staticinputset values,
        # choose the tighter ediff
        incar["EDIFF"] = min(incar.get("EDIFF", 1), parent_incar["EDIFF"])
        return incar
コード例 #2
0
def wf_task_is_converged(root):
    current_workflow_stage_number = get_workflow_stage_number(root)
    wf_input_cmds, wf_conv_cmds, wf_rerun_cmds, wf_stgnum_cmds = parse_wf_cmds(
        root)
    upgrade_workflow = False
    for task_name in wf_input_cmds:
        task_stage_number, task_input_command, task_rerun_command, task_convergence_command = get_task_info(
            root, task_name)
        workflow_path = os.path.join(root, task_name)
        convergence_file = os.path.join(workflow_path, 'TASK_CONVERGENCE')

        if task_stage_number == current_workflow_stage_number:
            if os.path.exists(convergence_file):
                task_convergence = Incar().from_file(convergence_file)
                if task_convergence['TASK_CONVERGED'] == True:
                    upgrade_workflow = True
                else:
                    os.system(task_convergence_command)
                    task_convergence = Incar().from_file(convergence_file)
                    if task_convergence['TASK_CONVERGED'] == True:
                        upgrade_workflow = True
            else:
                os.system(task_convergence_command)
                task_convergence = Incar().from_file(convergence_file)
                if task_convergence['TASK_CONVERGED'] == True:
                    upgrade_workflow = True

    return upgrade_workflow
コード例 #3
0
    def incar(self):
        parent_incar = super(PRLStaticSet, self).incar
        incar = Incar(self.prev_incar) if self.prev_incar is not None else \
            Incar(parent_incar)

        incar.update({
            "IBRION": -1,
            "ISMEAR": -5,
            "LAECHG": True,
            "LCHARG": True,
            "LORBIT": 11,
            "LVHAR": True,
            "LWAVE": False,
            "NSW": 0,
            "ICHARG": 0,
            "ALGO": "Normal"
        })

        if self.lepsilon:
            incar["IBRION"] = 8
            incar["LEPSILON"] = True

            # LPEAD=T: numerical evaluation of overlap integral prevents
            # LRF_COMMUTATOR errors and can lead to better expt. agreement
            # but produces slightly different results
            incar["LPEAD"] = True

            # Note that DFPT calculations MUST unset NSW. NSW = 0 will fail
            # to output ionic.
            incar.pop("NSW", None)
            incar.pop("NPAR", None)

        if self.lcalcpol:
            incar["LCALCPOL"] = True

        for k in ["MAGMOM", "NUPDOWN"] + list(
                self.kwargs.get("user_incar_settings", {}).keys()):
            # For these parameters as well as user specified settings, override
            # the incar settings.
            if parent_incar.get(k, None) is not None:
                incar[k] = parent_incar[k]
            else:
                incar.pop(k, None)

        # use new LDAUU when possible b/c the Poscar might have changed
        # representation
        if incar.get('LDAU'):
            u = incar.get('LDAUU', [])
            j = incar.get('LDAUJ', [])
            if sum([u[x] - j[x] for x, y in enumerate(u)]) > 0:
                for tag in ('LDAUU', 'LDAUL', 'LDAUJ'):
                    incar.update({tag: parent_incar[tag]})
            # ensure to have LMAXMIX for GGA+U static run
            if "LMAXMIX" not in incar:
                incar.update({"LMAXMIX": parent_incar["LMAXMIX"]})

        # Compare ediff between previous and staticinputset values,
        # choose the tighter ediff
        incar["EDIFF"] = min(incar.get("EDIFF", 1), parent_incar["EDIFF"])
        return incar
コード例 #4
0
 def __new__(cls, incar=None):
     # check if already pymatgen Incar instance
     if isinstance(incar, Incar):
         return incar
     elif isinstance(incar, dict):  # initialize from user input
         incar_params_upper = cls.keys_to_upper_case(incar)
         incar_data = Incar(params=incar_params_upper)
     elif incar is None:
         incar_data = Incar(params=None)
     else:
         raise IncarWrapperError(
             "Unknown type '{}' for incar parameters".format(type(incar)))
     return incar_data
コード例 #5
0
    def convert_computed_entry_to_job(self,entry):
        """
        Convert ComputedStructureEntry into VaspJob object

        Parameters
        ----------
        entry : 
            ComputedStructureEntry.

        Returns
        -------
        vaspjob : 
            VaspJob object.
        """
        e = entry
        path = e.data['dir_name']
        
        inp = e.data['calculations'][0]['input']           
        incar = Incar(inp['incar'])
        kpoints = Kpoints.from_dict(inp['kpoints'])
        poscar = Poscar(e.structure)
        potcar = Potcar(inp['potcar'])
        
        inputs = VaspInput(incar, kpoints, poscar, potcar)
        job_settings = e.data['job_settings']
        job_script_filename = e.data['job_script_filename']
        name = e.data['job_name']
        
        outputs = {'ComputedStructureEntry':e}
        
        vaspjob =  VaspJob(path,inputs,job_settings,outputs,job_script_filename,name)
        vaspjob._is_converged = e.data['is_converged']
        vaspjob._band_structure = None
            
        return vaspjob            
コード例 #6
0
def auto_incar(params: Dict[str, Any] = None) -> Incar:
    # kk = grep 'entropy T'  OUTCAR
    # rkk = kk/n_atom<0.001ev  检查
    """"""
    if params is None:
        params = {}
    notes, params = pop_note(params)
    params.update(_ISMEAR(notes, params))
    params.update(_SIGMA(notes, params))
    params.update(_ISTART(notes, params))
    params.update(_ICHARG(notes, params))
    params.update(_ISPIN(notes, params))
    params.update(_PREC(notes, params))
    params.update(_ENCUT(notes, params))
    params.update(_IBRION(notes, params))
    params.update(_ISIF(notes, params))
    params.update(_IVDW(notes, params))
    params.update(_NSW(notes, params))
    params.update(_LORBIT(notes, params))
    params.update(_NBANDS(notes, params))
    # if "SYSTEM" not in params:
    #     params.update({"SYSTEM": "test_write_time_{}".format(time.time())})

    incar = Incar(params)

    return incar
コード例 #7
0
    def get_vaspjob(self,setname='',pathname=''):
        """
        Generate VaspJob object from the input settings of the class.

        Parameters
        ----------
        setname : (str), optional
            String to be added to 'name' key in job_settings dictionary and to name attribute of VaspJob. The default is ''.
        pathname : (str), optional
            String to be added to self.path. The complete path will be input in 'path' arg of VaspJob. The default is ''.

        Returns
        -------
        vaspjob : (VaspJob object)
        """        
        incar_settings = self.incar_settings.copy()
        job_settings = self.job_settings.copy()
        
        incar = Incar(incar_settings)
        kpoints = self.kpoints
        poscar = Poscar(self.structure)
        potcar = self.potcar
        vaspinput = VaspInput(incar,kpoints,poscar,potcar)
        job_settings['name'] = '_'.join([self.job_settings['name'],setname])
        
        jobname = '_'.join([self.name,setname])
        jobpath = op.join(self.path,pathname)
        job_script_filename = job_settings['filename'] if 'filename' in job_settings.keys() else None
        vaspjob = VaspJob(path=jobpath,inputs=vaspinput,job_settings=job_settings,job_script_filename=job_script_filename,name=jobname)
        
        return vaspjob  
コード例 #8
0
    def test_lsorbit_magmom(self):
        magmom1 = [[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]]
        magmom2 = [-1,-1,-1, 0, 0, 0, 0 ,0 ]

        ans_string1 = "LSORBIT = True\nMAGMOM = 0.0 0.0 3.0 0 1 0 2 1 2\n"
        ans_string2 = "LSORBIT = True\nMAGMOM = 3*3*-1 3*5*0\n"
        ans_string3 = "LSORBIT = False\nMAGMOM = 2*-1 2*9\n"

        incar = Incar({})
        incar["MAGMOM"] = magmom1
        incar["LSORBIT"] = "T"
        self.assertEqual(ans_string1, str(incar))

        incar["MAGMOM"] = magmom2
        incar["LSORBIT"] = "T"
        self.assertEqual(ans_string2, str(incar))

        incar = Incar.from_string(ans_string1)
        self.assertEqual(incar["MAGMOM"], [[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]])

        incar = Incar.from_string(ans_string2)
        self.assertEqual(incar["MAGMOM"], [[-1, -1, -1], [-1, -1, -1],
                                           [-1, -1, -1], [0, 0, 0],
                                           [0, 0, 0], [0, 0, 0],
                                           [0, 0, 0], [0, 0, 0]])

        incar = Incar.from_string(ans_string3)
        self.assertFalse(incar["LSORBIT"])
        self.assertEqual(incar["MAGMOM"], [-1, -1, 9, 9])
コード例 #9
0
    def _write_incar(self, calculator):
        """
        Writes INCAR file.
        
        Arguments
        ---------
        calculator: dict
            Calculation configulation as ASE format.
        
        Parameters
        ----------
        incar_dict: dict
            Dictionary of incar setting.
        """
        incar_dict = {
            "SYSTEM": self._struct_name,
            "ALGO": "VeryFast",
            "LWAVE": False,
            "ISTART": 0,
            "ICHARG": 2,
            "ISPIN": 1,
            "IBRION": 1,
            "ISYM": 0,
            "ISIF": 3
        }

        if calculator.get("maxiter") is not None:
            incar_dict["NELM"] = calculator["maxiter"]

        if calculator.get("isif") is not None:
            incar_dict["isif"] = calculator["isif"]

        with open("INCAR", mode="w") as file:
            file.writelines(str(Incar(incar_dict)))
コード例 #10
0
 def test_quad_efg(self):
     incar1 = Incar({})
     incar1["LEFG"] = True
     incar1["QUAD_EFG"] = [0.0, 146.6, -25.58]
     ans_string1 = "LEFG = True\nQUAD_EFG = 0.0 146.6 -25.58\n"
     self.assertEqual(ans_string1, str(incar1))
     incar2 = Incar.from_string(ans_string1)
     self.assertEqual(ans_string1, str(incar2))
コード例 #11
0
    def test_lsorbit_magmom(self):
        magmom1 = [[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]]
        magmom2 = [-1, -1, -1, 0, 0, 0, 0, 0]
        magmom4 = [Magmom([1.0, 2.0, 2.0])]

        ans_string1 = (
            "LANGEVIN_GAMMA = 10 10 10\nLSORBIT = True\n"
            "MAGMOM = 0.0 0.0 3.0 0 1 0 2 1 2\n"
        )
        ans_string2 = "LANGEVIN_GAMMA = 10\nLSORBIT = True\n" "MAGMOM = 3*3*-1 3*5*0\n"
        ans_string3 = "LSORBIT = False\nMAGMOM = 2*-1 2*9\n"
        ans_string4_nolsorbit = "LANGEVIN_GAMMA = 10\nLSORBIT = False\nMAGMOM = 1*3.0\n"
        ans_string4_lsorbit = (
            "LANGEVIN_GAMMA = 10\nLSORBIT = True\nMAGMOM = 1.0 2.0 2.0\n"
        )

        incar = Incar({})
        incar["MAGMOM"] = magmom1
        incar["LSORBIT"] = "T"
        incar["LANGEVIN_GAMMA"] = [10, 10, 10]
        self.assertEqual(ans_string1, str(incar))

        incar["MAGMOM"] = magmom2
        incar["LSORBIT"] = "T"
        incar["LANGEVIN_GAMMA"] = 10
        self.assertEqual(ans_string2, str(incar))

        incar["MAGMOM"] = magmom4
        incar["LSORBIT"] = "F"
        self.assertEqual(ans_string4_nolsorbit, str(incar))
        incar["LSORBIT"] = "T"
        self.assertEqual(ans_string4_lsorbit, str(incar))

        incar = Incar.from_string(ans_string1)
        self.assertEqual(incar["MAGMOM"], [[0.0, 0.0, 3.0], [0, 1, 0], [2, 1, 2]])
        self.assertEqual(incar["LANGEVIN_GAMMA"], [10, 10, 10])

        incar = Incar.from_string(ans_string2)
        self.assertEqual(
            incar["MAGMOM"],
            [
                [-1, -1, -1],
                [-1, -1, -1],
                [-1, -1, -1],
                [0, 0, 0],
                [0, 0, 0],
                [0, 0, 0],
                [0, 0, 0],
                [0, 0, 0],
            ],
        )
        self.assertEqual(incar["LANGEVIN_GAMMA"], [10])

        incar = Incar.from_string(ans_string3)
        self.assertFalse(incar["LSORBIT"])
        self.assertEqual(incar["MAGMOM"], [-1, -1, 9, 9])
コード例 #12
0
ファイル: incar_test.py プロジェクト: aiida-cusp/aiida-cusp
def test_get_incar_method():
    incar_parameters = {
        'EDIFF': 1.0E-6,
        'EDIFFG': -0.001,
        'ISMEAR': 0,
        'SIGMA': 0.01,
    }
    incar = VaspIncarData(incar=incar_parameters)
    pmg_incar = Incar(params=incar_parameters)
    assert str(incar.get_incar()) == str(pmg_incar)
コード例 #13
0
ファイル: myfiretasks.py プロジェクト: Baijianlu/AICON2
    def run_task(self, fw_spec):
        strain = self.get("strain", 0.0)
        user_incar_settings = self.get("user_incar_settings", {})

        struct = Structure.from_file("POSCAR")
        struct.apply_strain(strain)
        INCAR = Incar(user_incar_settings)

        struct.to(filename="POSCAR")
        INCAR.write_file("INCAR")
コード例 #14
0
ファイル: in_out.py プロジェクト: nimalec/Magmango
def write_incar(file_path, settings):
    """
    Generates VASP INCAR file for VASP calculation.

    **Args:

    workdir (str):
    input_settings (InputParameters):
    """

    #file_path = os.path.join(work_dir,"INCAR")
    incar = Incar().from_dict(settings)
    incar.write_file(file_path)
コード例 #15
0
    def cineb_pbe(self,scheme_name=None,stepnames=['CINEB']):
        """
        Climbing image NEB job with PBE. The force convergence is set to 0.05 eV/A, relaxation in done with damped 
        dynamics (IBRION=3), symmetry is turned off (ISYM=0). The maximum number of ionic steps is set to 25.
        """
        scheme_name = scheme_name if scheme_name != None else 'CINEB'
        
        inputs = {}
        incar_settings = self.incar_settings.copy()
        job_settings = self.job_settings.copy()

        incar_settings.update({
            'ISYM': 0,
            'EDIFF': 1e-05,
            'EDIFFG': -0.05,
            'ISIF': 2,
            'NSW' : 25,
            'IMAGES' : self.images,
            'SPRING' : -5,
            'IOPT' : 0,
            'IBRION' : 3,
            'POTIM' : 0.05,
            'ICHAIN' : 0,
            'LCLIMB' : '.TRUE.',
            'LTANGENTOLD' : '.FALSE.',
            'LDNEB' : '.FALSE.',
            'LNEBCELL' : '.FALSE.'
            })

        incar = Incar(incar_settings)
        kpoints = self.kpoints
        potcar = self.potcar
        
        inputs['structures'] = self.structures
        inputs['INCAR'] = incar
        inputs['KPOINTS'] = kpoints
        inputs['POTCAR'] = potcar
        
        job_settings['nodes'] = self.images
        job_settings['path_exe'] = '/home/lv51dypu/vasp.5.4.4_vtstcode/bin/vasp_std'
        if 'add_automation' not in job_settings:
            job_settings['add_automation'] = None        
        job_settings['name'] = '_'.join([self.name,scheme_name])


        jobname = '_'.join([self.name,scheme_name])
        jobpath = op.join(self.path,stepnames[0])
        nebjob = VaspNEBJob(path=jobpath,inputs=inputs,job_settings=job_settings,name=jobname)

        return nebjob
コード例 #16
0
    def __init__(self,path=None,vaspinput=None,structure=None,incar_settings=None,kpoints=None,potcar=None,
                 job_settings=None,name=None,add_parent_folder=False):
        """
        Parameters
        ----------
        path : (str)
            Main path for the scheme. If None the current work dir is used. The default is None.
        vaspinput : (Pymatgen VaspInput object), optional
            Set of VASP inputs, the default is None. if provided the other inputs of the class (structure,incar_settings,kpoints,potcar) are not needed 
        structure : (Pymatgen Structure object), optional
            Pymatgen Structure object.
        incar_settings : (Dict), optional
            Dictionary with incar flags. The default is None. If None the default settings for PBE functional from the DefaultInputs class are used.
        kpoints : (Pymatgen Kpoints object), optional
            Pymatgen Kpoints object. The default is None. If None the default settings from the DefaultInputs class are used.
        potcar : (Pymatgen kpoints object), optional
            Pymatgen kpoints object. The default is None. If None the default settings from the DefaultInputs class are used.
        job_settings : (Dict), optional
            Dictionary with job settings to create job script, parameters are defined in ScrpitHandler class function. The default is None.\n
            If job_settings is None, the 'name' key will be added, the value is the 'name' argument if provided, if 'name' arg is \n
            None the value will be: 'no_name'.
        name : (str), optional
            Name for the system to set up scheme for. The default is None.
        add_parent_folder : (bool), optional
            Add folder to the path names like the name of the InputSets. Default is False.
        """
        self.path = op.abspath(path) if path else os.getcwd()
        if vaspinput:
            structure = vaspinput['POSCAR'].structure
            incar_settings = Incar(vaspinput['INCAR'].copy())
            kpoints = vaspinput['KPOINTS']
            potcar = vaspinput['POTCAR']

        self.structure = structure if structure else None
        if structure:
            self.incar_settings = incar_settings if incar_settings else DefaultInputs(self.structure).get_incar_default()
            self.kpoints = kpoints if kpoints else DefaultInputs(self.structure).get_kpoints_default()
            self.potcar = potcar if potcar else DefaultInputs(self.structure).get_potcar()
            self.job_settings = job_settings if job_settings else ({'name':name} if name else {'name':'no_name'})
            self.name = name if name != None else self.job_settings['name'] 
            
            if self.name: # this return false if name is '', the previuos line considers only if name is None
                self.job_settings['name'] = self.name
                
        else:
            raise ValueError('You need to provide Structure, either as Poscar object in VaspInput or in "structure" arg')

        if add_parent_folder:
            self.path = op.join(self.path,self.name)
コード例 #17
0
def gen_incar(incar_config={}):

    _default_incar_config = {
        'ALGO': 'All',
        'ICHARG': '2',
        'PREC': 'Normal',
        'EDIFF': '1E-5',
        'ENCUT': '520',
        'ISMEAR': '0',
        'IBRION': '-1',
        'ISIF': '0',
        'NELM': '200',
        'NSW': '0',
        'SIGMA': '0.1',
        'ISYM': '2',
    }
    _default_incar_config.update(incar_config)
    Incar(_default_incar_config).write_file('INCAR')
コード例 #18
0
 def test_check_params(self):
     # Triggers warnings when running into nonsensical parameters
     with self.assertWarns(BadIncarWarning) as cm:
         incar = Incar(
             {
                 "ADDGRID": True,
                 "ALGO": "Normal",
                 "AMIN": 0.01,
                 "AMIX": 0.2,
                 "BMIX": 0.001,
                 "EDIFF": 5 + 1j,  # EDIFF needs to be real
                 "EDIFFG": -0.01,
                 "ENCUT": 520,
                 "IBRION": 2,
                 "ICHARG": 1,
                 "ISIF": 3,
                 "ISMEAR": 1,
                 "ISPIN": 2,
                 "LASPH": 5,  # Should be a bool
                 "LORBIT": 11,
                 "LREAL": "Auto",
                 "LWAVE": False,
                 "MAGMOM": [1, 2, 4, 5],
                 "METAGGA": "SCAM",  # spelling mistake
                 "NELM": 200,
                 "NPAR": 4,
                 "NSW": 99,
                 "PREC": "Accurate",
                 "SIGMA": 0.2,
                 "NBAND": 250,  # spelling mistake
                 "PHON_TLIST": "is_a_str",  # this parameter should be a list
                 "LATTICE_CONSTRAINTS": [
                     True,
                     False,
                     "f",
                 ],  # Should be a list of bools
                 "M_CONSTR": [True, 1, "string"],  # Should be a list of real numbers
             }
         )
         incar.check_params()
コード例 #19
0
    def incar(self):
        """
        Custom Incar attribute for HubbardHundLinRespSet
        """
        parent_incar = super().incar
        incar = Incar(parent_incar)

        incar.update({"ISYM": -1, "ISMEAR": 0, "LREAL": False, "LASPH": True})
        incar.update({"ISTART": 1})
        # incar.update({"ALGO": "Fast"})
        incar.pop("NSW", None)

        if self.kwargs.get("user_incar_settings")["LDAUU"]:

            incar.update(
                {"LDAUL": self.kwargs.get("user_incar_settings")["LDAUL"]})
            incar.update(
                {"LDAUU": self.kwargs.get("user_incar_settings")["LDAUU"]})
            incar.update(
                {"LDAUJ": self.kwargs.get("user_incar_settings")["LDAUJ"]})

            incar["LDAUL"] = [
                incar["LDAUL"][key] for key in incar["LDAUL"].keys()
            ]
            incar["LDAUU"] = [
                incar["LDAUU"][key] for key in incar["LDAUU"].keys()
            ]
            incar["LDAUJ"] = [
                incar["LDAUJ"][key] for key in incar["LDAUJ"].keys()
            ]

            incar["LDAU"] = self.kwargs.get("user_incar_settings")["LDAU"]
            incar["LDAUTYPE"] = self.kwargs.get(
                "user_incar_settings")["LDAUTYPE"]
            incar["LDAUPRINT"] = self.kwargs.get(
                "user_incar_settings")["LDAUPRINT"]
            incar["LORBIT"] = self.kwargs.get("user_incar_settings")["LORBIT"]

        return incar
コード例 #20
0
    def get_vasp_input(self,
                       xc='PBE',
                       ldauu=None,
                       aexx=0.25,
                       kppa=1000,
                       potcar_symbols=None,
                       potcar_functional='PBE'):
        """
        Get pymatgen VaspInput object with complete set of default inputs.

        Parameters
        ----------
        xc : (str), optional
            Which functional to use('PBE','PBE+U','HSE06' available). The default is 'PBE'.
        ldauu : (List), optional
            List of integers for U parameter to be given in order as required by VASP. The default is None. If None no 'LDAUU' flag is written.
        aexx : (Int), optional
            Value of Hartree-Fock contribution for HSE calculation. The default is 0.25.
        kppa : (Int), optional
            Value of k-points density per atom to generate automatic k-mesh as done by Pymatgen. The default is 1000.
        potcar_symbols : List, optional
            List of strings with symbols of POTCARs. The default is None. If None the default symbols from the Materials Project \n
            database are used for every specie in the given Structure object.
        potcar_functional : (str), optional
            Functional to be used, as defined by Pymatgen Potcar class. The default is 'PBE'.

        Returns
        -------
        Pymatgen VaspInput object.

        """

        incar = Incar(self.get_incar_default(xc=xc, ldauu=ldauu, aexx=aexx))
        kpoints = self.get_kpoints_default(kppa=kppa)
        poscar = self.get_poscar()
        potcar = self.get_potcar(potcar_symbols=potcar_symbols,
                                 potcar_functional=potcar_functional)

        return VaspInput(incar, kpoints, poscar, potcar)
コード例 #21
0
    def preconverge(self,scheme_name=None,stepnames=['NEB-preconverge']):
        """
        Do SCF convergence for all images before starting NEB calculation
        """      
        scheme_name = scheme_name if scheme_name!=None else 'SCF'

        self.incar_settings.update({
            'EDIFF' : 1e-04,
            'NSW': 0
            })

        jobs = []
        structures = self.structures
        for s in structures:
            
            index = structures.index(s)
            image_name = str(index).zfill(2)
            
            incar = Incar(self.incar_settings)
            kpoints = self.kpoints
            potcar = self.potcar
            poscar = Poscar(s)
            vaspinput = VaspInput(incar, kpoints, poscar, potcar)
            
            job_settings = self.job_settings.copy()
            if 'add_automation' not in job_settings:
                if index ==  structures.index(structures[-1]):
                    job_settings['add_automation'] = '(cd ../ && automation_vasp_NEB.py)'
                else:
                    job_settings['add_automation'] = 'automation_vasp.py --chgcar --wavecar'
            job_settings['name'] = '_'.join([self.name,scheme_name,image_name])
            
            jobname = '_'.join([self.name,scheme_name,image_name])
            jobpath = op.join(self.path,stepnames[0],image_name)
            vaspjob = VaspJob(path=jobpath,inputs=vaspinput,job_settings=job_settings,name=jobname)
            jobs.append(vaspjob)
            
        return jobs      
コード例 #22
0
    def write_incar(self, relax: bool, incar_config: dict = {}):
        """
        writes an INCAR file with some default settings, and also can modify the tags
        :param relax:
                --True: writes an INCAR for relax use
                --False: wirtes an INCAR only supporting static run
        :param incar_config: customized incar settings
        """

        incar_file_name = os.path.join(self._save_to_path, 'INCAR')

        _default_incar_config = {
            'ALGO': 'ALL',
            'ICHARG': '2',
            'PREC': 'Normal',
            'EDIFF': '1E-5',
            'EDIFFG': '-0.1',
            'ENCUT': '430',
            'ISMEAR': '0',
            'IBRION': '-1',
            'ISIF': '0',
            'NELM': '200',
            'NSW': '0',
            'SIGMA': '0.1',
            'ISYM': '2',
        }
        if relax:
            relax_incar_config = {
                'IBRION': '2',
                'NSW': '100',
                'ISIF': '3',  # only cell will move, the atoms won't move
            }
            _default_incar_config.update(relax_incar_config)

        _default_incar_config.update(incar_config)

        Incar(_default_incar_config).write_file(incar_file_name)
コード例 #23
0
def driver():
    pwd = os.getcwd()
    other_calculators_in_workflow, workflow_commands_in_workflow = workflow_progress(
        pwd)

    num_jobs_in_workflow = check_num_jobs_in_workflow(
        pwd)  #currently only checks for vasp jobs

    if num_jobs_in_workflow > 1 or other_calculators_in_workflow == True or workflow_commands_in_workflow == True:
        if os.path.exists(os.path.join(pwd, 'WORKFLOW_NAME')):
            workflow_file = Incar().from_file(
                os.path.join(pwd, 'WORKFLOW_NAME'))
            workflow_name = workflow_file['NAME']

        else:
            print('\n#---------------------------------#\n')
            workflow_name = input("Please enter a name for this workflow: ")
            print('\n#---------------------------------#\n')

            with open(os.path.join(pwd, 'WORKFLOW_NAME'), 'w') as f:
                writeline = 'NAME = ' + str(workflow_name)
                f.write(writeline)
                f.close()

    else:
        workflow_name = get_single_job_name(pwd)

    computed_entries = vasp_run_main(pwd)

    if not computed_entries:
        pass
    else:
        with open(os.path.join(pwd,
                               str(workflow_name) + '_converged.json'),
                  'w') as f:
            json.dump(computed_entries, f)
コード例 #24
0
 def test_check_params(self):
     # Triggers warnings when running into nonsensical parameters
     with self.assertWarns(BadIncarWarning) as cm:
         incar = Incar({
             'ADDGRID': True,
             'ALGO': 'Normal',
             'AMIN': 0.01,
             'AMIX': 0.2,
             'BMIX': 0.001,
             'EDIFF': 5 + 1j,  # EDIFF needs to be real
             'EDIFFG': -0.01,
             'ENCUT': 520,
             'IBRION': 2,
             'ICHARG': 1,
             'ISIF': 3,
             'ISMEAR': 1,
             'ISPIN': 2,
             'LASPH': 5,  # Should be a bool
             'LORBIT': 11,
             'LREAL': 'Auto',
             'LWAVE': False,
             'MAGMOM': [1, 2, 4, 5],
             'METAGGA': 'SCAM',  # spelling mistake
             'NELM': 200,
             'NPAR': 4,
             'NSW': 99,
             'PREC': 'Accurate',
             'SIGMA': 0.2,
             'NBAND': 250,  # spelling mistake
             'PHON_TLIST': 'is_a_str',  # this parameter should be a list
             'LATTICE_CONSTRAINTS': [True, False,
                                     'f'],  # Should be a list of bools
             'M_CONSTR': [True, 1,
                          'string']  # Should be a list of real numbers
         })
         incar.check_params()
コード例 #25
0
def replace_incar_tags(path, tag, value):
    incar = Incar().from_file(os.path.join(path, 'INCAR'))
    incar.__setitem__(tag, value)
    incar.write_file(os.path.join(path, 'INCAR'))
コード例 #26
0
from mpinterfaces.firetasks import MPINTCalibrateTask

a0 = 3.965
lattice_matrix = a0 * np.array([ [0.5, 0.0, 0.5], 
                                 [0.5, 0.5, 0.0], 
                                 [0.0, 0.5, 0.5] ])
lattice = Lattice(lattice_matrix)
structure = Structure( lattice, ['Pt'], 
                       [ [0.0, 0.0, 0.0] ],
                       coords_are_cartesian=False)
incarparams = {'System':'test',
               'ENCUT': 400,
               'ISMEAR': 1,
               'SIGMA': 0.1,
               'EDIFF':1E-6 }
incar = Incar(params=incarparams)
poscar = Poscar(structure, comment='Pt', selective_dynamics=None)
potcar = Potcar(symbols = poscar.site_symbols, 
                functional='PBE',
                sym_potcar_map=None)
kpoints = Kpoints(kpts=((8, 8, 8),))
turn_knobs = { 'ENCUT' : range(400, 500, 100),
               'KPOINTS': [k for k in range(20, 30, 10)]
             }
job_dir = 'calBulk'
job_cmd = ['mpirun', '/home/km468/Software/VASP/vasp.5.3.5/vasp']
qparams= dict(nnodes='1', ppnode='16', 
              job_name='vasp_job', pmem='1000mb',
              walltime='24:00:00',
              rocket_launch=''.join(job_cmd))
# set qadapter to None to launch via qlaunch
コード例 #27
0
 def get_incar(working_dir: str, incar_config: dict):
     file_name = working_dir+'INCAR'
     Incar(incar_config).write_file(file_name)
コード例 #28
0
def get_incar_value(path, tag):
    incar = Incar().from_file(os.path.join(path, 'INCAR'))
    value = incar[tag]
    return value
コード例 #29
0
def get_workflow_stage_number(path):
    workflow_stage = Incar().from_file(os.path.join(path, 'WORKFLOW_STAGE'))
    current_workflow_stage_number = workflow_stage['WORKFLOW_STAGE_NUMBER']

    return current_workflow_stage_number
コード例 #30
0
        "ISMEAR": 0,
        "SIGMA": 0.05,
        "ALGO": "All",
        "ISYM": 2,
        "AMIX": 0.2,
        "LREAL": ".FALSE.",
        # "LVTOT": ".TRUE."
        # "NEDOS": 2000,
        #    "LHFCALC" : ".TRUE.",
        #    "HFSCREEN": 0.2,
        #    "NKRED": 2,
        #    "PRECFOCK": "Fast",
        #    "AEXX": 0.24,
    }
    # creating Incar object from 'incar_dict'
    incar = Incar(incar_dict)

    # POSCAR
    poscar = Poscar(struct)
    poscar_dict = poscar.as_dict()

    # KPOINTS
    k = 7
    kpoints = Kpoints.gamma_automatic(kpts=(k, k, k), shift=(0.0, 0.0, 0.0))

    # get POTCAR with right order from POSCAR
    # check for prevoius element - if it's the same don't write it twice
    prevoius_el = None
    # initializing potcar_symbols
    potcar_symbols = []
    #getting sites list