Exemplo n.º 1
0
    def __init__(
        self,
        parents=None,
        prev_calc_dir=None,
        structure=None,
        mode="gap",
        name=None,
        vasp_cmd=VASP_CMD,
        db_file=DB_FILE,
        **kwargs,
    ):
        """
        For getting a more accurate band gap or a full band structure with HSE - requires previous
        calculation that gives VBM/CBM info or the high-symmetry kpoints.

        Args:
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            prev_calc_dir (str): Path to a previous calculation to copy from
            structure (Structure): Input structure - used only to set the name of the FW.
            mode (string): options:
                "line" to get a full band structure along symmetry lines or
                "uniform" for uniform mesh band structure or
                "gap" to get the energy at the CBM and VBM
            name (str): Name for the Firework.
            vasp_cmd (str): Command to run vasp.
            db_file (str): Path to file specifying db credentials.
            **kwargs: Other kwargs that are passed to Firework.__init__.
        """
        name = name if name else "{} {}".format("hse", mode)

        fw_name = "{}-{}".format(
            structure.composition.reduced_formula if structure else "unknown",
            name)

        t = []
        if prev_calc_dir:
            t.append(
                CopyVaspOutputs(calc_dir=prev_calc_dir,
                                additional_files=["CHGCAR"]))
        elif parents:
            t.append(
                CopyVaspOutputs(calc_loc=True, additional_files=["CHGCAR"]))
        else:
            raise ValueError("Must specify a previous calculation for HSEBSFW")

        t.append(WriteVaspHSEBSFromPrev(prev_calc_dir=".", mode=mode))
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))
        t.append(PassCalcLocs(name=name))

        parse_dos = True if mode == "uniform" else False
        bandstructure_mode = mode if mode in ["line", "uniform"] else "line"

        t.append(
            VaspToDb(
                db_file=db_file,
                additional_fields={"task_label": name},
                parse_dos=parse_dos,
                bandstructure_mode=bandstructure_mode,
            ))
        super().__init__(t, parents=parents, name=fw_name, **kwargs)
Exemplo n.º 2
0
    def __init__(self, structure=None, prev_calc_dir=None, name="static dielectric", vasp_cmd=VASP_CMD,
                 copy_vasp_outputs=True, lepsilon=True,
                 db_file=DB_FILE, parents=None, user_incar_settings=None,
                 pass_nm_results=False, **kwargs):
        """
         Static DFPT calculation Firework

        Args:
            structure (Structure): Input structure. If copy_vasp_outputs, used only to set the
                name of the FW.
            name (str): Name for the Firework.
            lepsilon (bool): Turn on LEPSILON to calculate polar properties
            vasp_cmd (str): Command to run vasp.
            copy_vasp_outputs (str or bool): Whether to copy outputs from previous
                run. Defaults to True.
            prev_calc_dir (str): Path to a previous calculation to copy from
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            user_incar_settings (dict): Parameters in INCAR to override
            pass_nm_results (bool): if true the normal mode eigen vals and vecs are passed so that
                next firework can use it.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        name = "static dielectric" if lepsilon else "phonon"

        fw_name = "{}-{}".format(structure.composition.reduced_formula if structure else "unknown", name)

        user_incar_settings = user_incar_settings or {}
        t = []

        if prev_calc_dir:
            t.append(CopyVaspOutputs(calc_dir=prev_calc_dir, contcar_to_poscar=True))
            t.append(WriteVaspStaticFromPrev(lepsilon=lepsilon, other_params={
                'user_incar_settings': user_incar_settings, 'force_gamma': True}))
        elif parents and copy_vasp_outputs:
            t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True))
            t.append(WriteVaspStaticFromPrev(lepsilon=lepsilon, other_params={
                'user_incar_settings': user_incar_settings, 'force_gamma': True}))
        elif structure:
            vasp_input_set = MPStaticSet(structure, lepsilon=lepsilon, force_gamma=True,
                                         user_incar_settings=user_incar_settings)
            t.append(WriteVaspFromIOSet(structure=structure,
                                        vasp_input_set=vasp_input_set))
        else:
            raise ValueError("Must specify structure or previous calculation")

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))

        if pass_nm_results:
            t.append(pass_vasp_result({"structure": "a>>final_structure",
                                       "eigenvals": "a>>normalmode_eigenvals",
                                       "eigenvecs": "a>>normalmode_eigenvecs"},
                                      parse_eigen=True,
                                      mod_spec_key="normalmodes"))

        t.append(PassCalcLocs(name=name))
        t.append(VaspToDb(db_file=db_file, additional_fields={"task_label": name}))

        super(DFPTFW, self).__init__(t, parents=parents, name=fw_name, **kwargs)
Exemplo n.º 3
0
def use_custodian(original_wf, fw_name_constraint=None, custodian_params=None):
    """
    Replaces all tasks with "RunVasp*" (e.g. RunVaspDirect) to be RunVaspCustodian. Thus, this
    powerup adds error correction into VASP runs if not originally present and/or modifies
    the correction behavior.

    Args:
        original_wf (Workflow): original workflow
        fw_name_constraint (str): Only apply changes to FWs where fw_name contains this substring.
            For example, use custodian only for certain runs, or set job_type to
            "double_relaxation_run" only for structure optimization run, or set different
            handler_group for different runs.
        custodian_params (dict): A dict of parameters for RunVaspCustodian. e.g., use it to set
            a "scratch_dir" or "handler_group".

    Returns:
       Workflow
    """
    custodian_params = custodian_params if custodian_params else {}
    vasp_fws_and_tasks = get_fws_and_tasks(
        original_wf,
        fw_name_constraint=fw_name_constraint,
        task_name_constraint="RunVasp")
    for idx_fw, idx_t in vasp_fws_and_tasks:
        if "vasp_cmd" not in custodian_params:
            custodian_params["vasp_cmd"] = original_wf.fws[idx_fw].tasks[
                idx_t]["vasp_cmd"]
        original_wf.fws[idx_fw].tasks[idx_t] = \
            RunVaspCustodian(**custodian_params)
    return original_wf
Exemplo n.º 4
0
    def __init__(self,
                 structure,
                 name="structure optimization",
                 vasp_input_set=None,
                 vasp_cmd=VASP_CMD,
                 override_default_vasp_params=None,
                 ediffg=None,
                 db_file=DB_FILE,
                 force_gamma=True,
                 job_type="double_relaxation_run",
                 max_force_threshold=RELAX_MAX_FORCE,
                 auto_npar=">>auto_npar<<",
                 half_kpts_first_relax=HALF_KPOINTS_FIRST_RELAX,
                 parents=None,
                 **kwargs):
        """
        Optimize the given structure.

        Args:
            structure (Structure): Input structure.
            name (str): Name for the Firework.
            vasp_input_set (VaspInputSet): input set to use. Defaults to MPRelaxSet() if None.
            override_default_vasp_params (dict): If this is not None, these params are passed to 
                the default vasp_input_set, i.e., MPRelaxSet. This allows one to easily override 
                some settings, e.g., user_incar_settings, etc.
            vasp_cmd (str): Command to run vasp.
            ediffg (float): Shortcut to set ediffg in certain jobs
            db_file (str): Path to file specifying db credentials to place output parsing.
            force_gamma (bool): Force gamma centered kpoint generation
            job_type (str): custodian job type (default "double_relaxation_run")
            max_force_threshold (float): max force on a site allowed at end; otherwise, reject job
            auto_npar (bool or str): whether to set auto_npar. defaults to env_chk: ">>auto_npar<<"
            half_kpts_first_relax (bool): whether to use half the kpoints for the first relaxation
            parents ([Firework]): Parents of this particular Firework.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        override_default_vasp_params = override_default_vasp_params or {}
        vasp_input_set = vasp_input_set or MPRelaxSet(
            structure, force_gamma=force_gamma, **override_default_vasp_params)

        t = []
        t.append(
            WriteVaspFromIOSet(structure=structure,
                               vasp_input_set=vasp_input_set))
        t.append(
            RunVaspCustodian(vasp_cmd=vasp_cmd,
                             job_type=job_type,
                             max_force_threshold=max_force_threshold,
                             ediffg=ediffg,
                             auto_npar=auto_npar,
                             half_kpts_first_relax=half_kpts_first_relax))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file, additional_fields={"task_label": name}))
        super(OptimizeFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
Exemplo n.º 5
0
def run_task_ext(t, vasp_cmd, db_file, structure, tag,
                 override_default_vasp_params):
    try:
        store_raw_vasprunxml = override_default_vasp_params[
            'user_incar_settings']['store_raw_vasprunxml']
    except:
        store_raw_vasprunxml = False
    if type(store_raw_vasprunxml) == int: kmesh_factor = store_raw_vasprunxml
    elif type(store_raw_vasprunxml) == bool:
        if store_raw_vasprunxml: kmesh_factor = 2
        else: kmesh_factor = 0
    else: kmesh_factor = 0
    #    print ("eeeeeeeeeeeeeeee", store_raw_vasprunxml, kmesh_factor)
    if kmesh_factor > 1:
        t.append(nonscalc(kmesh_factor=kmesh_factor))
        t.append(
            RunVaspCustodian(vasp_cmd=vasp_cmd,
                             auto_npar=">>auto_npar<<",
                             gzip_output=False))
        t.append(
            InsertXMLToDb(db_file=db_file,
                          structure=structure,
                          tag=tag,
                          xml="vasprun.xml",
                          kmesh_factor=kmesh_factor))
    elif kmesh_factor == 1:
        t.append(
            InsertXMLToDb(db_file=db_file,
                          structure=structure,
                          tag=tag,
                          xml="vasprun.xml",
                          kmesh_factor=1))
Exemplo n.º 6
0
    def __init__(self, structure, isif=2, scale_lattice=None, name="static", vasp_input_set=None, 
                 vasp_cmd="vasp", metadata=None, prev_calc_loc=True, Prestatic=False, modify_incar=None, 
                 db_file=None, parents=None, tag=None, override_default_vasp_params=None,
                 store_volumetric_data=False, **kwargs):

        # TODO: @computron - I really don't like how you need to set the structure even for
        # prev_calc_loc jobs. Sometimes it makes appending new FWs to an existing workflow
        # difficult. Maybe think about how to remove this need? -computron
        metadata = metadata or {}
        tag = tag or metadata.get('tag')
        # generate a tag with a warning
        if tag is None:
            tag = str(uuid4())
            metadata['tag'] = tag

        if isinstance(store_volumetric_data, (list, tuple)):
            store_volumetric_data = store_volumetric_data
        elif isinstance(store_volumetric_data, bool):
            if store_volumetric_data:
                store_volumetric_data = STORE_VOLUMETRIC_DATA
            else:
                store_volumetric_data = ()
        else:
            raise ValueError('The store_volumetric_data should be list or bool')

        override_default_vasp_params = override_default_vasp_params or {}
        self.override_default_vasp_params = override_default_vasp_params
        vasp_input_set = vasp_input_set or StaticSet(structure, isif=isif, **override_default_vasp_params)
        site_properties = deepcopy(structure).site_properties
        # Avoids delivery (prev_calc_loc == '' (instead by True))
        t = []
        if type(prev_calc_loc) == str:
            t.append(CopyVaspOutputs(calc_dir=prev_calc_loc, contcar_to_poscar=True))
            t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=site_properties))
        elif parents:
            if prev_calc_loc:
                t.append(CopyVaspOutputs(calc_loc=prev_calc_loc, contcar_to_poscar=True))
            t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=site_properties))
        else:
            t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=site_properties))
        if (scale_lattice is not None) and not Prestatic:
            t.append(ScaleVolumeTransformation(scale_factor=scale_lattice, structure=structure))
        t.append(ModifyIncar(incar_update=">>incar_update<<"))
        if modify_incar != None:
             t.append(ModifyIncar(incar_update=modify_incar))
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<", gzip_output=False))
        t.append(PassCalcLocs(name=name))
        if Prestatic:
            t.append(Record_PreStatic_result(db_file = ">>db_file<<", metadata = metadata, structure = structure, scale_lattice = scale_lattice))
        else:
            t.append(VaspToDb(db_file=">>db_file<<", parse_dos=True, additional_fields={"task_label": name, "metadata": metadata,
                                "version_atomate": atomate_ver, "version_dfttk": dfttk_ver, "adopted": True, "tag": tag},
                                store_volumetric_data=store_volumetric_data))
            run_task_ext(t,vasp_cmd,">>db_file<<",structure,tag,self.override_default_vasp_params)

        t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, site_properties=site_properties))
        super(StaticFW, self).__init__(t, parents=parents, name="{}-{}".format(
            structure.composition.reduced_formula, name), **kwargs)
Exemplo n.º 7
0
    def __init__(self, mode, displacement, prev_calc_dir=None, structure=None, name="raman",
                 vasp_cmd=VASP_CMD, db_file=DB_FILE,
                 parents=None, user_incar_settings=None, **kwargs):
        """
        Static calculation Firework that computes the DFPT dielectric constant for
        structure displaced along the given normal mode direction.

        Args:
            structure (Structure): Input structure. If copy_vasp_outputs, used only to set the
                name of the FW.
            mode (int): normal mode index.
            displacement (float): displacement along the normal mode in Angstroms.
            name (str): Name for the Firework.
            prev_calc_dir (str): Path to a previous calculation to copy from
            vasp_cmd (str): Command to run vasp.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            user_incar_settings (dict): Parameters in INCAR to override
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        name = "{}_{}_{}".format(name, str(mode), str(displacement))
        fw_name = "{}-{}".format(structure.composition.reduced_formula if structure else "unknown", name)

        user_incar_settings = user_incar_settings or {}

        t = []

        if prev_calc_dir:
            t.append(CopyVaspOutputs(calc_dir=prev_calc_dir, contcar_to_poscar=True))
        elif parents:
            t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True))
        else:
            raise ValueError("Must specify a previous calculation")

        t.append(WriteVaspStaticFromPrev(lepsilon=True, other_params={
            'user_incar_settings': user_incar_settings}))

        t.append(WriteNormalmodeDisplacedPoscar(mode=mode,
                                                displacement=displacement))

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))

        key = "{}_{}".format(mode, displacement).replace('-', 'm').replace('.',
                                                                           'd')
        t.append(pass_vasp_result(pass_dict={"mode": mode,
                                             "displacement": displacement,
                                             "epsilon": "a>>epsilon_static"},
                                  mod_spec_key="raman_epsilon->{}".format(key),
                                  parse_eigen=True))

        t.append(PassCalcLocs(name=name))

        t.append(
            VaspToDb(db_file=db_file, additional_fields={"task_label": name}))

        super(RamanFW, self).__init__(t, parents=parents, name=fw_name, **kwargs)
Exemplo n.º 8
0
    def __init__(self,
                 structure,
                 scale_lattice=None,
                 name="static",
                 vasp_input_set=None,
                 vasp_cmd="vasp",
                 metadata=None,
                 prev_calc_loc=True,
                 db_file=None,
                 parents=None,
                 **kwargs):

        # TODO: @computron - I really don't like how you need to set the structure even for
        # prev_calc_loc jobs. Sometimes it makes appending new FWs to an existing workflow
        # difficult. Maybe think about how to remove this need? -computron
        metadata = metadata or {}
        vasp_input_set = vasp_input_set or StaticSet(structure)
        site_properties = deepcopy(structure).site_properties

        t = []

        if parents:
            if prev_calc_loc:
                t.append(
                    CopyVaspOutputs(calc_loc=prev_calc_loc,
                                    contcar_to_poscar=True))
            t.append(
                WriteVaspFromIOSetPrevStructure(
                    vasp_input_set=vasp_input_set,
                    site_properties=site_properties))
        else:
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))
        if scale_lattice is not None:
            t.append(ScaleVolumeTransformation(scale_factor=scale_lattice))
        t.append(ModifyIncar(incar_update=">>incar_update<<"))
        t.append(
            RunVaspCustodian(vasp_cmd=vasp_cmd,
                             auto_npar=">>auto_npar<<",
                             gzip_output=False))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(
                db_file=db_file,
                parse_dos=True,
                additional_fields={
                    "task_label": name,
                    "metadata": metadata
                },
            ))
        super(StaticFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
Exemplo n.º 9
0
    def __init__(self,
                 structure,
                 name="static",
                 vasp_input_set=None,
                 vasp_cmd="vasp",
                 prev_calc_loc=True,
                 db_file=None,
                 parents=None,
                 **kwargs):
        """
        Standard static calculation Firework - either from a previous location or from a structure.

        Args:
            structure (Structure): Input structure. Note that for prev_calc_loc jobs, the structure 
                is only used to set the name of the FW and any structure with the same composition 
                can be used.
            name (str): Name for the Firework.
            vasp_input_set (VaspInputSet): input set to use (for jobs w/no parents)
                Defaults to MPStaticSet() if None.
            vasp_cmd (str): Command to run vasp.
            prev_calc_loc (bool or str): If true (default), copies outputs from previous calc. If 
                a str value, grabs a previous calculation output by name. If False/None, will create
                new static calculation using the provided structure.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """

        # TODO: @computron - I really don't like how you need to set the structure even for
        # prev_calc_loc jobs. Sometimes it makes appending new FWs to an existing workflow
        # difficult. Maybe think about how to remove this need? -computron

        t = []

        if parents:
            if prev_calc_loc:
                t.append(
                    CopyVaspOutputs(calc_loc=prev_calc_loc,
                                    contcar_to_poscar=True))
            t.append(WriteVaspStaticFromPrev())
        else:
            vasp_input_set = vasp_input_set or MPStaticSet(structure)
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd,
                                  auto_npar=">>auto_npar<<"))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file, additional_fields={"task_label": name}))
        super(StaticFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
Exemplo n.º 10
0
    def __init__(self,
                 structure,
                 name="nscf",
                 mode="uniform",
                 vasp_cmd="vasp",
                 copy_vasp_outputs=True,
                 db_file=None,
                 parents=None,
                 **kwargs):
        """
        Standard NonSCF Calculation Firework supporting both
        uniform and line modes.

        Args:
            structure (Structure): Input structure - used only to set the name of the FW.
            name (str): Name for the Firework.
            mode (str): "uniform" or "line" mode.
            vasp_cmd (str): Command to run vasp.
            copy_vasp_outputs (bool): Whether to copy outputs from previous
                run. Defaults to True.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        t = []
        if copy_vasp_outputs:
            t.append(
                CopyVaspOutputs(calc_loc=True, additional_files=["CHGCAR"]))
        mode = mode.lower()
        if mode == "uniform":
            t.append(
                WriteVaspNSCFFromPrev(prev_calc_dir=".",
                                      mode="uniform",
                                      reciprocal_density=1000))
        else:
            t.append(
                WriteVaspNSCFFromPrev(prev_calc_dir=".",
                                      mode="line",
                                      reciprocal_density=20))

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd,
                                  auto_npar=">>auto_npar<<"))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file,
                     additional_fields={"task_label": name + " " + mode},
                     parse_dos=(mode == "uniform"),
                     bandstructure_mode=mode))

        super(NonSCFFW, self).__init__(
            t,
            parents=parents,
            name="%s-%s %s" %
            (structure.composition.reduced_formula, name, mode),
            **kwargs)
Exemplo n.º 11
0
    def __init__(self, structure, scale_lattice=None, isif=4, override_symmetry_tolerances=None, 
                 name="structure optimization", vasp_input_set=None, job_type="normal", vasp_cmd="vasp", 
                 metadata=None, override_default_vasp_params=None, db_file=None, record_path=False, 
                 prev_calc_loc=True, parents=None, db_insert=False, tag=None,
                 run_isif2=False, pass_isif4=False, force_gamma=True, store_volumetric_data=False,
                 modify_incar=None, modify_incar_params={}, modify_kpoints_params={}, **kwargs):

        metadata = metadata or {}
        tag = tag or metadata.get('tag')
        # generate a tag with a warning
        if tag is None:
            tag = str(uuid4())
            metadata['tag'] = tag
        metadata.update({'tag': tag})

        if isinstance(store_volumetric_data, (list, tuple)):
            store_volumetric_data = store_volumetric_data
        elif isinstance(store_volumetric_data, bool):
            if store_volumetric_data:
                store_volumetric_data = STORE_VOLUMETRIC_DATA
            else:
                store_volumetric_data = ()
        else:
            raise ValueError('The store_volumetric_data should be list or bool')

        override_default_vasp_params = override_default_vasp_params or {}
        override_symmetry_tolerances = override_symmetry_tolerances or {}
        vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, force_gamma=force_gamma,
                                                       **override_default_vasp_params)
        site_properties = deepcopy(structure).site_properties

        t = []
        # Avoids delivery (prev_calc_loc == '' (instead by True))
        if type(prev_calc_loc) == str:
            t.append(CopyVaspOutputs(calc_dir=prev_calc_loc, contcar_to_poscar=True))
            t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=site_properties))
        elif parents:
            if prev_calc_loc:
                t.append(CopyVaspOutputs(calc_loc=prev_calc_loc, contcar_to_poscar=True))
            t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=site_properties))
        else:
        #vasp_input_set = vasp_input_set or RelaxSet(structure)  # ??
            t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=site_properties))
        if scale_lattice is not None:
            t.append(ScaleVolumeTransformation(scale_factor=scale_lattice, structure=structure))
        t.append(ModifyIncar(incar_update=">>incar_update<<"))
        if modify_incar != None:
             t.append(ModifyIncar(incar_update=modify_incar))
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, job_type=job_type, gzip_output=False))
        t.append(PassCalcLocs(name=name))
        if record_path:
            t.append(Record_relax_running_path(db_file = db_file, metadata = metadata, run_isif2=run_isif2, pass_isif4=pass_isif4))
        if db_insert:
            t.append(VaspToDb(db_file=db_file, additional_fields={"task_label": name, "metadata": metadata}, store_volumetric_data=store_volumetric_data))
        t.append(CheckSymmetryToDb(db_file=db_file, tag=tag, override_symmetry_tolerances=override_symmetry_tolerances, site_properties=site_properties))
        super(OptimizeFW, self).__init__(t, parents=parents, name="{}-{}".format(structure.composition.reduced_formula, name), **kwargs)
Exemplo n.º 12
0
 def __init__(self,
              structure,
              name="structure optimization",
              vasp_input_set=None,
              job_type="normal",
              vasp_cmd="vasp",
              isif=None,
              metadata=None,
              override_default_vasp_params=None,
              db_file=None,
              force_gamma=True,
              parents=None,
              **kwargs):
     """
     Optimize the given structure.
     Args:
         structure (Structure): Input structure.
         name (str): Name for the Firework.
         vasp_input_set (VaspInputSet): input set to use. Defaults to MPRelaxSet() if None.
         override_default_vasp_params (dict): If this is not None, these params are passed to
             the default vasp_input_set, i.e., MPRelaxSet. This allows one to easily override
             some settings, e.g., user_incar_settings, etc.
         isif : int
             Shortcut to override the ISIF parameter. Defaults to None.
             Will take precedent over override_default_vasp_params
         vasp_cmd (str): Command to run vasp.
         db_file (str): Path to file specifying db credentials to place output parsing.
         force_gamma (bool): Force gamma centered kpoint generation
         parents ([Firework]): Parents of this particular Firework.
         \*\*kwargs: Other kwargs that are passed to Firework.__init__.
     """
     metadata = metadata or {}
     override_default_vasp_params = override_default_vasp_params or {}
     vasp_input_set = vasp_input_set or PRLRelaxSet(
         structure, force_gamma=force_gamma, **override_default_vasp_params)
     t = []
     t.append(
         WriteVaspFromIOSet(structure=structure,
                            vasp_input_set=vasp_input_set))
     if isif:
         t.append(ModifyIncar(incar_update={'ISIF': isif}))
     t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, job_type=job_type))
     t.append(PassCalcLocs(name=name))
     t.append(
         VaspToDb(db_file=db_file,
                  additional_fields={
                      "task_label": name,
                      "metadata": metadata
                  }))
     super(OptimizeFW,
           self).__init__(t,
                          parents=parents,
                          name="{}-{}".format(
                              structure.composition.reduced_formula, name),
                          **kwargs)
Exemplo n.º 13
0
    def run_task(self, fw_spec):

        prev_checkpoint_dirs = fw_spec.get(
            "checkpoint_dirs",
            [])  # If this is the first spawn, have no prev dirs
        prev_checkpoint_dirs.append(os.getcwd(
        ))  # add the current directory to the list of checkpoints

        vasp_cmd = self["vasp_cmd"]
        wall_time = self["wall_time"]
        db_file = self.get("db_file", None)
        spawn_count = self["spawn_count"]
        production = self['production']
        num_checkpoints = production.get('num_checkpoints', 1)
        incar_update = production.get('incar_update', None)

        if spawn_count > num_checkpoints:
            logger.info(
                "LOGGER: Production run completed. Took {} spawns total".
                format(spawn_count))
            return FWAction(stored_data={'production_run_completed': True})

        else:
            name = ("ProductionRun" + str(abs(spawn_count)))

            logger.info("LOGGER: Starting spawn {} of production run".format(
                spawn_count))

            t = []

            t.append(
                CopyVaspOutputs(calc_dir=os.getcwd(), contcar_to_poscar=True))

            if incar_update:
                t.append(ModifyIncar(incar_update=incar_update))

            t.append(
                RunVaspCustodian(vasp_cmd=vasp_cmd,
                                 gamma_vasp_cmd=">>vasp_gam<<",
                                 handler_group="md",
                                 wall_time=wall_time))
            t.append(
                ProductionSpawnTask(wall_time=wall_time,
                                    vasp_cmd=vasp_cmd,
                                    db_file=db_file,
                                    spawn_count=spawn_count + 1,
                                    production=production))
            new_fw = Firework(t,
                              name=name,
                              spec={'checkpoint_dirs': prev_checkpoint_dirs})

            return FWAction(
                stored_data={'production_run_completed': False},
                update_spec={'checkpoint_dirs': prev_checkpoint_dirs},
                detours=[new_fw])
Exemplo n.º 14
0
    def __init__(self, structure, start_temp, end_temp, nsteps,
                 name="molecular dynamics",
                 vasp_input_set=None, vasp_cmd=VASP_CMD,
                 override_default_vasp_params=None,
                 wall_time=19200, db_file=DB_FILE, parents=None,
                 copy_vasp_outputs=True, **kwargs):
        """
        Standard firework for a single MD run.

        Args:
            structure (Structure): Input structure.
            start_temp (float): Start temperature of MD run.
            end_temp (float): End temperature of MD run.
            nsteps (int): Number of MD steps
            name (string): Name for the Firework.
            vasp_input_set (string): string name for the VASP input set (e.g.,
                "MITMDVaspInputSet").
            vasp_cmd (string): Command to run vasp.
            override_default_vasp_params (dict): If this is not None,
                these params are passed to the default vasp_input_set, i.e.,
                MITMDSet. This allows one to easily override some
                settings, e.g., user_incar_settings, etc. Particular to MD,
                one can control time_step and all other settings of the input set.
            wall_time (int): Total wall time in seconds before writing STOPCAR.
            copy_vasp_outputs (bool): Whether to copy outputs from previous run. Defaults to True.
            db_file (string): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        override_default_vasp_params = override_default_vasp_params or {}
        vasp_input_set = vasp_input_set or MITMDSet(structure,
                                                    start_temp=start_temp,
                                                    end_temp=end_temp,
                                                    nsteps=nsteps,
                                                    **override_default_vasp_params)

        t = []
        if copy_vasp_outputs:
            t.append(CopyVaspOutputs(calc_loc=True, additional_files=["CHGCAR"],
                                     contcar_to_poscar=True))

        t.append(WriteVaspFromIOSet(structure=structure,
                                    vasp_input_set=vasp_input_set))
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd,
                                  gamma_vasp_cmd=">>gamma_vasp_cmd<<",
                                  handler_group="md", wall_time=wall_time))
        t.append(PassCalcLocs(name=name))
        t.append(VaspToDb(db_file=db_file,
                          additional_fields={"task_label": name},
                          defuse_unsuccessful=False))
        super(MDFW, self).__init__(t, parents=parents,
                                   name="{}-{}".format(
                                       structure.composition.reduced_formula,
                                       name),
                                   **kwargs)
Exemplo n.º 15
0
    def __init__(self, structure=None, name="static", vasp_input_set=None, vasp_input_set_params=None,
                 vasp_cmd=VASP_CMD, prev_calc_loc=True, prev_calc_dir=None, db_file=DB_FILE, vasptodb_kwargs=None,
                 parents=None, **kwargs):
        """
        Standard static calculation Firework - either from a previous location or from a structure.

        Args:
            structure (Structure): Input structure. Note that for prev_calc_loc jobs, the structure
                is only used to set the name of the FW and any structure with the same composition
                can be used.
            name (str): Name for the Firework.
            vasp_input_set (VaspInputSet): input set to use (for jobs w/no parents)
                Defaults to MPStaticSet() if None.
            vasp_input_set_params (dict): Dict of vasp_input_set kwargs.
            vasp_cmd (str): Command to run vasp.
            prev_calc_loc (bool or str): If true (default), copies outputs from previous calc. If
                a str value, retrieves a previous calculation output by name. If False/None, will create
                new static calculation using the provided structure.
            prev_calc_dir (str): Path to a previous calculation to copy from
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            vasptodb_kwargs (dict): kwargs to pass to VaspToDb
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        t = []

        vasp_input_set_params = vasp_input_set_params or {}
        vasptodb_kwargs = vasptodb_kwargs or {}
        if "additional_fields" not in vasptodb_kwargs:
            vasptodb_kwargs["additional_fields"] = {}
        vasptodb_kwargs["additional_fields"]["task_label"] = name

        fw_name = "{}-{}".format(structure.composition.reduced_formula if structure else "unknown", name)

        if prev_calc_dir:
            t.append(CopyVaspOutputs(calc_dir=prev_calc_dir, contcar_to_poscar=True))
            t.append(WriteVaspStaticFromPrev(other_params=vasp_input_set_params))
        elif parents:
            if prev_calc_loc:
                t.append(CopyVaspOutputs(calc_loc=prev_calc_loc,
                                         contcar_to_poscar=True))
            t.append(WriteVaspStaticFromPrev(other_params=vasp_input_set_params))
        elif structure:
            vasp_input_set = vasp_input_set or MPStaticSet(structure, **vasp_input_set_params)
            t.append(WriteVaspFromIOSet(structure=structure,
                                        vasp_input_set=vasp_input_set))
        else:
            raise ValueError("Must specify structure or previous calculation")

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<"))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file, **vasptodb_kwargs))
        super(StaticFW, self).__init__(t, parents=parents, name=fw_name, **kwargs)
Exemplo n.º 16
0
    def __init__(self,
                 structure,
                 magmom,
                 name="spin-orbit coupling",
                 saxis=(0, 0, 1),
                 vasp_cmd="vasp_ncl",
                 copy_vasp_outputs=True,
                 db_file=None,
                 parents=None,
                 **kwargs):
        """
        Firework for spin orbit coupling calculation.

        Args:
            structure (Structure): Input structure. If copy_vasp_outputs, used only to set the 
                name of the FW.
            name (str): Name for the Firework.
            vasp_cmd (str): Command to run vasp.
            copy_vasp_outputs (bool): Whether to copy outputs from previous
                run. Defaults to True.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        t = []

        if copy_vasp_outputs:
            t.append(
                CopyVaspOutputs(calc_loc=True,
                                additional_files=["CHGCAR"],
                                contcar_to_poscar=True))
            t.append(
                WriteVaspSOCFromPrev(prev_calc_dir=".",
                                     magmom=magmom,
                                     saxis=saxis))
        else:
            vasp_input_set = MPSOCSet(structure)
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))

        t.extend([
            RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<"),
            PassCalcLocs(name=name),
            VaspToDb(db_file=db_file, additional_fields={"task_label": name})
        ])
        super(SOCFW, self).__init__(t,
                                    parents=parents,
                                    name="{}-{}".format(
                                        structure.composition.reduced_formula,
                                        name),
                                    **kwargs)
Exemplo n.º 17
0
    def __init__(self,
                 structure,
                 name="static",
                 previous_structure=False,
                 vasp_input_set=None,
                 vasp_cmd="vasp",
                 db_file=None,
                 parents=None,
                 override_default_vasp_params=None,
                 pass_structure=True,
                 prev_calc_loc=False,
                 **kwargs):
        """
        This Firework is modified from atomate.vasp.fireworks.core.StaticFW to fit the needs of mpmorph
        Standard static calculation Firework - either from a previous location or from a structure.
        Args:
            structure (Structure): Input structure. Note that for prev_calc_loc jobs, the structure
                is only used to set the name of the FW and any structure with the same composition
                can be used.
            name (str): Name for the Firework.
            vasp_input_set (VaspInputSet): input set to use (for jobs w/no parents)
                Defaults to MPStaticSet() if None.
            vasp_cmd (str): Command to run vasp.
            prev_calc_loc (bool or str): If true (default), copies outputs from previous calc. If
                a str value, grabs a previous calculation output by name. If False/None, will create
                new static calculation using the provided structure.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """

        t = []
        override_default_vasp_params = override_default_vasp_params or {}
        vasp_input_set = vasp_input_set or MPStaticSet(
            structure, **override_default_vasp_params)
        if prev_calc_loc:
            t.append(
                CopyVaspOutputs(calc_loc=prev_calc_loc,
                                contcar_to_poscar=True))
        t.append(
            WriteVaspFromIOSet(structure=structure,
                               vasp_input_set=vasp_input_set))
        if previous_structure:
            t.append(PreviousStructureTask())
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd,
                                  auto_npar=">>auto_npar<<"))
        t.append(SaveStructureTask())
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file, additional_fields={"task_label": name}))
        name = f'{structure.composition.reduced_formula}-{name}'
        super(StaticFW, self).__init__(t, parents=parents, name=name, **kwargs)
Exemplo n.º 18
0
    def __init__(self, structure, isif=7, name="structure optimization", isif4=False, level=1,
                 override_symmetry_tolerances=None, job_type="normal", vasp_input_set=None,
                 vasp_cmd="vasp", metadata=None, override_default_vasp_params=None, db_file=None,
                 prev_calc_loc=True, parents=None, db_insert=False, tag=None, modify_incar_params={},
                 modify_kpoints_params={}, energy_with_isif={}, store_volumetric_data=False, 
                 **kwargs):
        metadata = metadata or {}
        tag = tag or metadata.get('tag')
        # generate a tag with a warning
        if tag is None:
            tag = str(uuid4())
            metadata['tag'] = tag

        if isinstance(store_volumetric_data, (list, tuple)):
            store_volumetric_data = store_volumetric_data
        elif isinstance(store_volumetric_data, bool):
            if store_volumetric_data:
                store_volumetric_data = STORE_VOLUMETRIC_DATA
            else:
                store_volumetric_data = ()
        else:
            raise ValueError('The store_volumetric_data should be list or bool')

        override_default_vasp_params = override_default_vasp_params or {}
        override_symmetry_tolerances = override_symmetry_tolerances or {}
        vasp_input_set = vasp_input_set or RelaxSet(structure, isif=isif, **override_default_vasp_params)
        site_properties = deepcopy(structure).site_properties

        t = []
        if parents:
            if prev_calc_loc:
                t.append(CopyVaspOutputs(calc_loc=prev_calc_loc, contcar_to_poscar=True))
            t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=site_properties))
        else:
            t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=site_properties))
        t.append(ModifyIncar(incar_update=">>incar_update<<"))
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, job_type=job_type, gzip_output=False))
        t.append(PassCalcLocs(name=name))
        if db_insert:
            t.append(VaspToDb(db_file=">>db_file<<", additional_fields={"task_label": name, "metadata": metadata}, store_volumetric_data=store_volumetric_data))
        t.append(CheckSymmetryToDb(db_file=">>db_file<<", tag=tag, site_properties=site_properties))

        common_kwargs = {'vasp_cmd': vasp_cmd, 'db_file': ">>db_file<<", "metadata": metadata, "tag": tag,
                         'override_default_vasp_params': override_default_vasp_params}
        static_kwargs = {}
        relax_kwargs = {}
        t.append(CheckRelaxation(db_file=">>db_file<<", metadata=metadata, tag=tag, isif4=isif4, level=level, energy_with_isif=energy_with_isif,
                                 common_kwargs=common_kwargs, relax_kwargs=relax_kwargs, static_kwargs=static_kwargs, site_properties=site_properties,
                                 store_volumetric_data=store_volumetric_data, 
                                 **override_symmetry_tolerances))
        super().__init__(t, parents=parents, name="{}-{}".format(structure.composition.reduced_formula, name), **kwargs)
Exemplo n.º 19
0
    def __init__(self, spec, label, user_incar_settings=None,
                 user_kpoints_settings=None,
                 additional_cust_args=None, **kwargs):
        """
        Args:
            spec (dict): Specification of the job to run.
            label (str): "parent", "ep0" or "ep1"
            vasp_input_set (VaspInputSet): Input set to use.
            user_kpoints_settings (dict): Additional KPOINTS settings.
            additional_cust_args (dict): Other kwargs that are passed to RunVaspCustodian.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """

        # Get structure from spec
        assert label in ["parent", "ep0", "ep1"]
        structure_dict = spec[label]
        structure = Structure.from_dict(structure_dict)

        user_incar_settings = user_incar_settings or {}
        user_kpoints_settings = user_kpoints_settings or {}
        additional_cust_args = additional_cust_args or {}

        # Task 1: Write input sets
        if label == 'parent':
            vasp_input_set = MITRelaxSet(structure,
                                         user_incar_settings=user_incar_settings,
                                         user_kpoints_settings=user_kpoints_settings)
        else:  # label == "ep0" or "ep1"
            from pymatgen_diffusion.neb.io import MVLCINEBEndPointSet

            vasp_input_set = MVLCINEBEndPointSet(structure,
                                                 user_incar_settings=user_incar_settings,
                                                 user_kpoints_settings=user_kpoints_settings)

        write_ep_task = WriteVaspFromIOSet(structure=structure,
                                           vasp_input_set=vasp_input_set)

        # Task 2: Run VASP using Custodian
        cust_args = {"job_type": "normal", "gzip_output": False,
                     "handler_group": "no_handler"}
        cust_args.update(additional_cust_args)
        run_vasp = RunVaspCustodian(vasp_cmd=">>vasp_cmd<<",
                                    gamma_vasp_cmd=">>gamma_vasp_cmd<<",
                                    **cust_args)

        # Task 3, 4: Transfer and PassCalLocs
        tasks = [write_ep_task, run_vasp, TransferNEBTask(label=label),
                 PassCalcLocs(name=label)]

        super(NEBRelaxationFW, self).__init__(tasks, spec=spec, name=label,
                                              **kwargs)
Exemplo n.º 20
0
    def __init__(self, spec, neb_label, from_images=True,
                 user_incar_settings=None,
                 user_kpoints_settings=None, additional_cust_args=None,
                 **kwargs):
        """
        Args:
            spec (dict): Specification of the job to run.
            neb_label (str): "1", "2"..., label neb run.
            from_images (bool): Set True to initialize from image structures, False starting
                        from relaxed endpoint structures.
            user_incar_settings (dict): Additional INCAR settings.
            user_kpoints_settings (dict): Additional KPOINTS settings.
            additional_cust_args (dict): Other kwargs that are passed to RunVaspCustodian.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        assert neb_label.isdigit() and int(neb_label) >= 1
        label = "neb{}".format(neb_label)
        sort_tol = spec["sort_tol"]
        d_img = spec["d_img"]
        interpolation_type = spec["interpolation_type"]

        # Task 1: Write NEB input sets
        user_incar_settings = user_incar_settings or {}
        user_kpoints_settings = user_kpoints_settings or {}
        additional_cust_args = additional_cust_args or {}

        if from_images:
            write_neb_task = WriteNEBFromImages(neb_label=neb_label,
                                                user_incar_settings=user_incar_settings,
                                                user_kpoints_settings=user_kpoints_settings)

        else:  # from endpoints
            write_neb_task = WriteNEBFromEndpoints(
                user_incar_settings=user_incar_settings,
                user_kpoints_settings=user_kpoints_settings,
                sort_tol=sort_tol, d_img=d_img,
                interpolation_type=interpolation_type)

        # Task 2: Run NEB using Custodian
        cust_args = {"job_type": "neb", "gzip_output": False,
                     "handler_group": "no_handler"}
        cust_args.update(additional_cust_args)
        run_neb_task = RunVaspCustodian(vasp_cmd=">>vasp_cmd<<",
                                        gamma_vasp_cmd=">>gamma_vasp_cmd<<",
                                        **cust_args)

        # Task 3, 4: Transfer and PassCalcLocs
        tasks = [write_neb_task, run_neb_task, TransferNEBTask(label=label),
                 PassCalcLocs(name=label)]

        super(NEBFW, self).__init__(tasks, spec=spec, name=label, **kwargs)
Exemplo n.º 21
0
    def __init__(self,
                 structure,
                 name="structure optimization",
                 vasp_input_set=None,
                 job_type="normal",
                 vasp_cmd="vasp",
                 metadata=None,
                 override_default_vasp_params=None,
                 db_file=None,
                 force_gamma=True,
                 prev_calc_loc=True,
                 parents=None,
                 db_insert=False,
                 **kwargs):

        metadata = metadata or {}
        override_default_vasp_params = override_default_vasp_params or {}
        vasp_input_set = vasp_input_set or PRLRelaxSet(
            structure, force_gamma=force_gamma, **override_default_vasp_params)
        t = []
        if parents:
            if prev_calc_loc:
                t.append(
                    CopyVaspOutputs(calc_loc=prev_calc_loc,
                                    contcar_to_poscar=True))
            t.append(
                WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set))
        else:
            vasp_input_set = vasp_input_set or PRLRelaxSet(structure)
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))
        t.append(
            RunVaspCustodian(vasp_cmd=vasp_cmd,
                             job_type=job_type,
                             gzip_output=False))
        t.append(PassCalcLocs(name=name))
        if db_insert:
            t.append(
                VaspToDb(db_file=db_file,
                         additional_fields={
                             "task_label": name,
                             "metadata": metadata
                         }))
        super(PRLOptimizeFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
Exemplo n.º 22
0
    def __init__(self, structure, isif=2, scale_lattice=None, name="born charge", vasp_input_set=None,
                 vasp_cmd="vasp", metadata=None, override_default_vasp_params=None, tag=None,
                 prev_calc_loc=True, modify_incar=None, db_file=None, parents=None, **kwargs):

        metadata = metadata or {}
        tag = tag or metadata.get('tag')
        # generate a tag with a warning
        if tag is None:
            tag = str(uuid4())
            metadata['tag'] = tag

        override_default_vasp_params = override_default_vasp_params or {}

        vasp_input_set = vasp_input_set or BornChargeSet(structure, isif=isif, **override_default_vasp_params)
        site_properties = deepcopy(structure).site_properties

        # Avoids delivery (prev_calc_loc == '' (instead by True))
        t = []
        if type(prev_calc_loc) == str:
            t.append(CopyVaspOutputs(calc_dir=prev_calc_loc, contcar_to_poscar=True))
            t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=site_properties))
        elif parents:
            if prev_calc_loc:
                t.append(CopyVaspOutputs(calc_loc=prev_calc_loc, contcar_to_poscar=True))
            t.append(WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set, site_properties=site_properties))
        else:
            t.append(WriteVaspFromIOSetPrevStructure(structure=structure, vasp_input_set=vasp_input_set, site_properties=site_properties))
        if (scale_lattice is not None):
            t.append(ScaleVolumeTransformation(scale_factor=scale_lattice, structure=structure))

        #the following statement may not correct to Born effective charge calculation, so be commented.
        """
        t.append(ModifyIncar(incar_update=">>incar_update<<"))
        if modify_incar != None:
             t.append(ModifyIncar(incar_update=modify_incar))
        """
        #t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<", gzip_output=False))
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=False, gzip_output=False))
        t.append(PassCalcLocs(name=name))
        
        t.append(BornChargeToDb(db_file=">>db_file<<", tag=tag))
        #t.append(CheckSymmetryToDb(db_file=db_file, tag=tag))
        super(BornChargeFW, self).__init__(t, parents=parents, name="{}-{}".format(
            structure.composition.reduced_formula, name), **kwargs)
Exemplo n.º 23
0
    def __init__(self,
                 structure,
                 parents,
                 mode="gap",
                 name=None,
                 vasp_cmd="vasp",
                 db_file=None,
                 **kwargs):
        """
        For getting a more accurate band gap or a full band structure with HSE - requires previous
        calculation that gives VBM/CBM info or the high-symmetry kpoints.

        Args:
            structure (Structure): Input structure - used only to set the name of the FW.
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            mode (string): options:
                "line" to get a full band structure along symmetry lines or
                "uniform" for uniform mesh band structure or
                "gap" to get the energy at the CBM and VBM
            name (str): Name for the Firework.
            vasp_cmd (str): Command to run vasp.
            db_file (str): Path to file specifying db credentials.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        name = name if name else "{} {}".format("hse", mode)

        t = []
        t.append(CopyVaspOutputs(calc_loc=True, additional_files=["CHGCAR"]))
        t.append(WriteVaspHSEBSFromPrev(prev_calc_dir='.', mode=mode))
        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file, additional_fields={"task_label": name}))
        super(HSEBSFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
Exemplo n.º 24
0
    def __init__(self, structure, start, end, name="static", vasp_input_set="MPStaticSet",
                 vasp_input_set_params=None, vasp_cmd=VASP_CMD, db_file=DB_FILE,
                 parents=None, this_image=None, nimages=None, autosort_tol=0, **kwargs):
        """
        Standard static calculation Firework that interpolates structures from two previous calculations.

        Args:
            structure (Structure): Input structure used to name FireWork.
            start (str): PassCalcLoc name of StaticFW or RelaxFW run of starting structure.
            end (str): PassCalcLoc name of StaticFW or RelaxFW run of ending structure.
            name (str): Name for the Firework.
            vasp_input_set (str): Input set to use. Defaults to MPStaticSet.
            vasp_input_set_params (dict): Dict of vasp_input_set_kwargs.
            vasp_cmd (str): Command to run vasp.
            copy_vasp_outputs (bool): Whether to copy outputs from previous run. Defaults to True.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            this_image (int): which interpolation to use for this run
            nimages (int): number of interpolations
            autosort_tol (float): a distance tolerance in angstrom in which
                to automatically sort end_structure to match to the closest
                points in this particular structure.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        t = []

        vasp_input_set_params = vasp_input_set_params or {}

        t.append(WriteVaspFromIOSetFromInterpolatedPOSCAR(
            start=start, end=end, this_image=this_image, nimages=nimages,
            autosort_tol=autosort_tol, vasp_input_set=vasp_input_set,
            vasp_input_params=vasp_input_set_params))

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<"))
        t.append(PassCalcLocs(name=name))
        t.append(VaspToDb(db_file=db_file, additional_fields={"task_label": name}))

        super(StaticInterpolateFW, self).__init__(t, parents=parents, name="{}-{}".format(
            structure.composition.reduced_formula, name), **kwargs)
Exemplo n.º 25
0
    def run_task(self, fw_spec):
        vasp_cmd = self.get("vasp_cmd")
        wall_time = self.get("wall_time")
        db_file = self.get("db_file")
        max_rescales = self.get("max_rescales")
        pressure_threshold = self.get("pressure_threshold")
        spawn_count = self.get("spawn_count")
        production = self.get('production', {})
        p_v = self.get('p_v', [])

        if spawn_count > max_rescales:
            logger.info(
                "WARNING: The max number of rescales has been reached... stopping density search."
            )
            return FWAction(defuse_workflow=True)

        name = ("spawnrun" + str(spawn_count))

        current_dir = os.getcwd()

        averaging_fraction = self.get("averaging_fraction", 0.5)
        data = MD_Data()
        data.parse_md_data(current_dir)
        pressure = data.get_md_data()['pressure']
        v = data.get_volume
        p = np.mean(pressure[int(averaging_fraction * (len(pressure) - 1)):])
        p_v.append([p, v])

        logger.info("LOGGER: Current pressure is {}".format(p))
        if np.fabs(p) > pressure_threshold:
            logger.info(
                "LOGGER: Pressure is outside of threshold: Spawning another MD Task"
            )
            t = []
            t.append(
                CopyVaspOutputs(calc_dir=current_dir, contcar_to_poscar=True))
            t.append(
                RescaleVolumeTask(initial_pressure=p * 1000.0,
                                  initial_temperature=1,
                                  p_v=p_v))
            t.append(
                RunVaspCustodian(vasp_cmd=vasp_cmd,
                                 gamma_vasp_cmd=">>vasp_gam<<",
                                 handler_group="md",
                                 wall_time=wall_time))

            t.append(
                SpawnMDFWTask(pressure_threshold=pressure_threshold,
                              max_rescales=max_rescales,
                              wall_time=wall_time,
                              vasp_cmd=vasp_cmd,
                              db_file=db_file,
                              spawn_count=spawn_count + 1,
                              averaging_fraction=averaging_fraction,
                              production=production))
            new_fw = Firework(t, name=name, spec={'p_v': p_v})
            return FWAction(stored_data={'pressure': p}, detours=[new_fw])

        elif production:
            logger.info(
                "LOGGER: Pressure is within the threshold: Moving to production runs..."
            )
            t = []
            t.append(
                CopyVaspOutputs(calc_dir=current_dir, contcar_to_poscar=True))
            t.append(
                RunVaspCustodian(vasp_cmd=vasp_cmd,
                                 gamma_vasp_cmd=">>vasp_gam<<",
                                 handler_group="md",
                                 wall_time=wall_time))
            t.append(
                ProductionSpawnTask(vasp_cmd=vasp_cmd,
                                    wall_time=wall_time,
                                    db_file=db_file,
                                    spawn_count=1,
                                    production=production))
            production_fw = Firework(t, name="ProductionRun1")
            return FWAction(stored_data={
                'pressure': p,
                'density_calculated': True
            },
                            detours=[production_fw])

        else:
            return FWAction(stored_data={
                'pressure': p,
                'density_calculated': True
            })
Exemplo n.º 26
0
    def __init__(self,
                 structure,
                 transformations,
                 transformation_params=None,
                 vasp_input_set=None,
                 prev_calc_dir=None,
                 name="structure transmuter",
                 vasp_cmd=VASP_CMD,
                 copy_vasp_outputs=True,
                 db_file=DB_FILE,
                 parents=None,
                 override_default_vasp_params=None,
                 **kwargs):
        """
        Apply the transformations to the input structure, write the input set corresponding
        to the transformed structure, and run vasp on them.  Note that if a transformation yields 
        many structures from one, only the last structure in the list is used.

        Args:
            structure (Structure): Input structure.
            transformations (list): list of names of transformation classes as defined in
                the modules in pymatgen.transformations.
                eg:  transformations=['DeformStructureTransformation', 'SupercellTransformation']
            transformation_params (list): list of dicts where each dict specify the input 
                parameters to instantiate the transformation class in the transformations list.
            vasp_input_set (VaspInputSet): VASP input set, used to write the input set for the
                transmuted structure.
            name (string): Name for the Firework.
            vasp_cmd (string): Command to run vasp.
            copy_vasp_outputs (bool): Whether to copy outputs from previous run. Defaults to True.
            prev_calc_dir (str): Path to a previous calculation to copy from
            db_file (string): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            override_default_vasp_params (dict): additional user input settings for vasp_input_set.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        fw_name = "{}-{}".format(structure.composition.reduced_formula, name)
        override_default_vasp_params = override_default_vasp_params or {}
        t = []

        vasp_input_set = vasp_input_set or MPStaticSet(
            structure, force_gamma=True, **override_default_vasp_params)

        if prev_calc_dir:
            t.append(
                CopyVaspOutputs(calc_dir=prev_calc_dir,
                                contcar_to_poscar=True))
            t.append(
                WriteTransmutedStructureIOSet(
                    transformations=transformations,
                    transformation_params=transformation_params,
                    vasp_input_set=vasp_input_set,
                    override_default_vasp_params=override_default_vasp_params,
                    prev_calc_dir="."))
        elif copy_vasp_outputs:
            t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True))
            t.append(
                WriteTransmutedStructureIOSet(
                    structure=structure,
                    transformations=transformations,
                    transformation_params=transformation_params,
                    vasp_input_set=vasp_input_set,
                    override_default_vasp_params=override_default_vasp_params,
                    prev_calc_dir="."))
        elif structure:
            t.append(
                WriteTransmutedStructureIOSet(
                    structure=structure,
                    transformations=transformations,
                    transformation_params=transformation_params,
                    vasp_input_set=vasp_input_set,
                    override_default_vasp_params=override_default_vasp_params))
        else:
            raise ValueError("Must specify structure or previous calculation")

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file,
                     additional_fields={
                         "task_label": name,
                         "transmuter": {
                             "transformations": transformations,
                             "transformation_params": transformation_params
                         }
                     }))

        super(TransmuterFW, self).__init__(t,
                                           parents=parents,
                                           name=fw_name,
                                           **kwargs)
Exemplo n.º 27
0
    def __init__(self,
                 structure,
                 name="static dielectric",
                 vasp_cmd=VASP_CMD,
                 copy_vasp_outputs=True,
                 db_file=DB_FILE,
                 parents=None,
                 phonon=False,
                 mode=None,
                 displacement=None,
                 user_incar_settings=None,
                 **kwargs):
        """
        Standard static calculation Firework for dielectric constants using DFPT.

        Args:
            structure (Structure): Input structure. If copy_vasp_outputs, used only to set the
                name of the FW.
            name (str): Name for the Firework.
            vasp_cmd (str): Command to run vasp.
            copy_vasp_outputs (bool): Whether to copy outputs from previous
                run. Defaults to True.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            phonon (bool): Whether or not to extract normal modes and pass it. This argument along
                with the mode and displacement arguments must be set for the calculation of
                dielectric constant in the Raman tensor workflow.
            mode (int): normal mode index.
            displacement (float): displacement along the normal mode in Angstroms.
            user_incar_settings (dict): Parameters in INCAR to override
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        warnings.warn(
            "This firework will be removed soon. Use DFPTFW and/or RamanFW fireworks."
        )
        user_incar_settings = user_incar_settings or {}
        t = []

        if copy_vasp_outputs:
            t.append(
                CopyVaspOutputs(calc_loc=True,
                                additional_files=["CHGCAR"],
                                contcar_to_poscar=True))
            t.append(
                WriteVaspStaticFromPrev(
                    lepsilon=True,
                    other_params={'user_incar_settings': user_incar_settings}))
        else:
            vasp_input_set = MPStaticSet(
                structure,
                lepsilon=True,
                user_incar_settings=user_incar_settings)
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))

        if phonon:
            if mode is None and displacement is None:
                name = "{} {}".format("phonon", name)
                t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))
                t.append(
                    pass_vasp_result(
                        {
                            "structure": "a>>final_structure",
                            "eigenvals": "a>>normalmode_eigenvals",
                            "eigenvecs": "a>>normalmode_eigenvecs"
                        },
                        parse_eigen=True,
                        mod_spec_key="normalmodes"))
            else:
                name = "raman_{}_{} {}".format(str(mode), str(displacement),
                                               name)
                key = "{}_{}".format(mode, displacement).replace('-',
                                                                 'm').replace(
                                                                     '.', 'd')
                pass_fw = pass_vasp_result(pass_dict={
                    "mode": mode,
                    "displacement": displacement,
                    "epsilon": "a>>epsilon_static"
                },
                                           mod_spec_key="raman_epsilon->" +
                                           key,
                                           parse_eigen=True)
                t.extend([
                    WriteNormalmodeDisplacedPoscar(mode=mode,
                                                   displacement=displacement),
                    RunVaspCustodian(vasp_cmd=vasp_cmd), pass_fw
                ])
        else:
            t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))

        t.extend([
            PassCalcLocs(name=name),
            VaspToDb(db_file=db_file, additional_fields={"task_label": name})
        ])

        super(LepsFW, self).__init__(t,
                                     parents=parents,
                                     name="{}-{}".format(
                                         structure.composition.reduced_formula,
                                         name),
                                     **kwargs)
Exemplo n.º 28
0
    def __init__(self,
                 parents=None,
                 prev_calc_dir=None,
                 structure=None,
                 name="nscf",
                 mode="uniform",
                 vasp_cmd=VASP_CMD,
                 copy_vasp_outputs=True,
                 db_file=DB_FILE,
                 input_set_overrides=None,
                 **kwargs):
        """
        Standard NonSCF Calculation Firework supporting uniform and line modes.

        Args:
            structure (Structure): Input structure - used only to set the name
                of the FW.
            name (str): Name for the Firework.
            mode (str): "uniform" or "line" mode.
            vasp_cmd (str): Command to run vasp.
            copy_vasp_outputs (bool): Whether to copy outputs from previous
                run. Defaults to True.
            prev_calc_dir (str): Path to a previous calculation to copy from
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            input_set_overrides (dict): Arguments passed to the
                "from_prev_calc" method of the MPNonSCFSet. This parameter
                allows a user to modify the default values of the input set.
                For example, passing the key value pair
                    {'reciprocal_density': 1000}
                will override default k-point meshes for uniform calculations.
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        input_set_overrides = input_set_overrides or {}

        fw_name = "{}-{} {}".format(
            structure.composition.reduced_formula if structure else "unknown",
            name, mode)
        t = []

        if prev_calc_dir:
            t.append(
                CopyVaspOutputs(calc_dir=prev_calc_dir,
                                additional_files=["CHGCAR"]))
        elif parents:
            t.append(
                CopyVaspOutputs(calc_loc=True, additional_files=["CHGCAR"]))
        else:
            raise ValueError("Must specify previous calculation for NonSCFFW")

        mode = mode.lower()
        if mode == "uniform":
            t.append(
                WriteVaspNSCFFromPrev(prev_calc_dir=".",
                                      mode="uniform",
                                      **input_set_overrides))
        else:
            t.append(
                WriteVaspNSCFFromPrev(prev_calc_dir=".",
                                      mode="line",
                                      **input_set_overrides))

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd,
                                  auto_npar=">>auto_npar<<"))
        t.append(PassCalcLocs(name=name))
        t.append(
            VaspToDb(db_file=db_file,
                     additional_fields={"task_label": name + " " + mode},
                     parse_dos=(mode == "uniform"),
                     bandstructure_mode=mode))

        super(NonSCFFW, self).__init__(t,
                                       parents=parents,
                                       name=fw_name,
                                       **kwargs)
Exemplo n.º 29
0
    def __init__(self,
                 structure,
                 mode,
                 displacement,
                 name="raman",
                 vasp_cmd="vasp",
                 db_file=None,
                 parents=None,
                 user_incar_settings=None,
                 **kwargs):
        """
        Static calculation Firework that computes the DFPT dielectric constant for
        structure displaced along the given normal mode direction.

        Args:
            structure (Structure): Input structure. If copy_vasp_outputs, used only to set the
                name of the FW.
            mode (int): normal mode index.
            displacement (float): displacement along the normal mode in Angstroms.
            name (str): Name for the Firework.
            vasp_cmd (str): Command to run vasp.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            user_incar_settings (dict): Parameters in INCAR to override
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """

        name = "{}_{}_{} static dielectric".format(name, str(mode),
                                                   str(displacement))
        user_incar_settings = user_incar_settings or {}

        spec = kwargs.pop("spec", {})
        spec.update({
            "_files_in": {
                "POSCAR": "POSCAR",
                "OUTCAR": "OUTCAR",
                "vasprunxml": "vasprun.xml"
            }
        })

        t = []

        t.append(
            WriteVaspStaticFromPrev(
                lepsilon=True,
                other_params={'user_incar_settings': user_incar_settings}))

        t.append(
            WriteNormalmodeDisplacedPoscar(mode=mode,
                                           displacement=displacement))

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))

        key = "{}_{}".format(mode,
                             displacement).replace('-', 'm').replace('.', 'd')
        t.append(
            pass_vasp_result(pass_dict={
                "mode": mode,
                "displacement": displacement,
                "epsilon": "a>>epsilon_static"
            },
                             mod_spec_key="raman_epsilon->{}".format(key),
                             parse_eigen=True))

        t.append(PassCalcLocs(name=name))

        t.append(
            VaspToDb(db_file=db_file, additional_fields={"task_label": name}))

        super(RamanFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             spec=spec,
                             **kwargs)
Exemplo n.º 30
0
Arquivo: nmr.py Projeto: FilipchukB/P1
    def __init__(self,
                 structure=None,
                 mode="cs",
                 isotopes=None,
                 name="nmr tensor",
                 prev_calc_dir=None,
                 vasp_cmd="vasp",
                 copy_vasp_outputs=True,
                 db_file=None,
                 parents=None,
                 **kwargs):
        """
        Firework for NMR tensor calculations

        Args:
            structure (Structure): Input structure. If copy_vasp_outputs, used only to set the
                name of the FW.
            mode (str): the NMR calculation type: cs or efg, default is cs
            isotopes (list): list of isotopes to include, default is to include the
                             lowest mass quadrupolar isotope for all applicable elements
            name (str): Name for the Firework.
            prev_calc_dir (str): Path to a previous calculation to copy from
            vasp_cmd (str): Command to run vasp.
            copy_vasp_outputs (bool): Whether to copy outputs from previous
                run. Defaults to True.
            db_file (str): Path to file specifying db credentials.
            parents (Firework): Parents of this particular Firework.
                FW or list of FWS.
            kwargs: Other kwargs that are passed to Firework.__init__.
        """
        fw_name = "{}-{}".format(
            structure.composition.reduced_formula if structure else "unknown",
            name)

        isotopes = isotopes.split() if isinstance(isotopes, str) else isotopes
        t = []
        if prev_calc_dir:
            t.append(
                CopyVaspOutputs(calc_dir=prev_calc_dir,
                                contcar_to_poscar=True))
            t.append(
                WriteVaspNMRFromPrev(prev_calc_dir=".",
                                     mode=mode,
                                     isotopes=isotopes))
        elif parents and copy_vasp_outputs:
            t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True))
            t.append(
                WriteVaspNMRFromPrev(prev_calc_dir=".",
                                     mode=mode,
                                     isotopes=isotopes))
        elif structure:
            vasp_input_set = MPNMRSet(structure, mode=mode, isotopes=isotopes)
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))
        else:
            raise ValueError("Must specify structure or previous calculation.")

        t.extend([
            RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<"),
            PassCalcLocs(name=name),
            VaspToDb(db_file=db_file, additional_fields={"task_label": name})
        ])
        super(NMRFW, self).__init__(t, parents=parents, name=fw_name, **kwargs)