Ejemplo n.º 1
0
    def test_cleanupfiles_calc_dir(self):
        # will test deleting from some folder specified by calc_dir
        with ScratchDir(".", copy_from_current_on_enter=True) as d:
            current_path = os.getcwd()
            os.mkdir("to_remove.relax0")
            os.mkdir("to_remove.relax1")
            os.mkdir("dont_remove.relax0")
            os.mkdir("shouldnt_touch")

            fw1 = Firework(
                [
                    DeleteFilesPrevFolder(files=["to_remove*", "dont_remove"],
                                          calc_dir=current_path),
                    PassCalcLocs(name="fw1"),
                ],
                name="fw1",
            )
            fw2 = Firework([PassCalcLocs(name="fw2")], name="fw2", parents=fw1)

            wf = Workflow([fw1, fw2])
            self.lp.add_wf(wf)
            rapidfire(self.lp)

            self.assertTrue(
                os.path.exists(os.path.join(current_path,
                                            "dont_remove.relax0")))
            self.assertTrue(
                os.path.exists(os.path.join(current_path, "shouldnt_touch")))
            self.assertFalse(
                os.path.exists(os.path.join(current_path, "to_remove.relax0")))
            self.assertFalse(
                os.path.exists(os.path.join(current_path, "to_remove.relax1")))
Ejemplo n.º 2
0
    def test_copyfilesfromcalcloc(self):
        fw1 = Firework(
            [
                CopyVaspOutputs(calc_dir=self.plain_outdir),
                PassCalcLocs(name="fw1")
            ],
            name="fw1",
        )

        fw2 = Firework(
            [
                CopyVaspOutputs(calc_dir=self.relax2_outdir),
                PassCalcLocs(name="fw2")
            ],
            name="fw2",
        )

        fw3 = Firework(
            [
                CopyFilesFromCalcLoc(
                    calc_loc="fw1",
                    filenames=["POSCAR"],
                    name_prepend="",
                    name_append="_0",
                ),
                CopyFilesFromCalcLoc(
                    calc_loc="fw2",
                    filenames=["POSCAR"],
                    name_prepend="",
                    name_append="_1",
                ),
                PassCalcLocs(name="fw3"),
            ],
            name="fw3",
            parents=[fw1, fw2],
        )
        fw4 = Firework([PassCalcLocs(name="fw4")], name="fw4", parents=fw3)

        wf = Workflow([fw1, fw2, fw3, fw4])
        self.lp.add_wf(wf)
        rapidfire(self.lp)

        fw4 = self.lp.get_fw_by_id(self.lp.get_fw_ids({"name": "fw4"})[0])

        calc_locs = fw4.spec["calc_locs"]
        self.assertTrue(
            os.path.exists(
                get_calc_loc("fw3", calc_locs)["path"] + "/POSCAR_0"))
        self.assertTrue(
            os.path.exists(
                get_calc_loc("fw3", calc_locs)["path"] + "/POSCAR_1"))
Ejemplo n.º 3
0
    def test_cleanupfiles_calc_loc(self):
        # will test deleting files from previous folder
        fw1 = Firework(
            [
                CreateFolder(folder_name="to_remove.relax0"),
                CreateFolder(folder_name="to_remove.relax1"),
                CreateFolder(folder_name="dont_remove.relax0"),
                CreateFolder(folder_name="shouldnt_touch"),
                PassCalcLocs(name="fw1"),
            ],
            name="fw1",
        )
        fw2 = Firework(
            [
                DeleteFilesPrevFolder(files=["to_remove*", "dont_remove"],
                                      calc_loc=True),
                PassCalcLocs(name="fw2"),
            ],
            name="fw2",
            parents=fw1,
        )

        wf = Workflow([fw1, fw2])
        self.lp.add_wf(wf)
        rapidfire(self.lp)

        fw2 = self.lp.get_fw_by_id(self.lp.get_fw_ids({"name": "fw2"})[0])
        calc_locs = fw2.spec["calc_locs"]

        self.assertTrue(
            os.path.exists(
                os.path.join(
                    get_calc_loc("fw1", calc_locs)["path"],
                    "dont_remove.relax0")))
        self.assertTrue(
            os.path.exists(
                os.path.join(
                    get_calc_loc("fw1", calc_locs)["path"], "shouldnt_touch")))
        self.assertFalse(
            os.path.exists(
                os.path.join(
                    get_calc_loc("fw1", calc_locs)["path"],
                    "to_remove.relax0")))
        self.assertFalse(
            os.path.exists(
                os.path.join(
                    get_calc_loc("fw1", calc_locs)["path"],
                    "to_remove.relax1")))
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def __init__(
        self,
        parents=None,
        structure=None,
        name="vasp2trace",
        db_file=None,
        prev_calc_dir=None,
        vasp2trace_out=None,
        vasp_cmd=None,
        **kwargs
    ):
        """
        Run Vasp2Trace on a spin-polarized calculation and parse the output data. 
        Assumes you have a previous FW with the calc_locs passed into the current FW.

        Args:
            structure (Structure): - only used for setting name of FW
            name (str): name of this FW
            db_file (str): path to the db file
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            prev_calc_dir (str): Path to a previous calculation to copy from
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        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", "WAVECAR", "PROCAR"],
                    contcar_to_poscar=True,
                )
            )
        elif parents:
            t.append(
                CopyVaspOutputs(
                    calc_loc=True,
                    additional_files=["CHGCAR", "WAVECAR", "PROCAR"],
                    contcar_to_poscar=True,
                )
            )
        else:
            raise ValueError("Must specify structure or previous calculation")

        t.extend(
            [
                RunVasp2TraceMagnetic(),
                PassCalcLocs(name=name),
                Vasp2TraceToDb(db_file=db_file, vasp2trace_out=vasp2trace_out),
            ]
        )

        super(Vasp2TraceMagneticFW, self).__init__(
            t, parents=parents, name=fw_name, **kwargs
        )
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
    def test_createfolder(self):

        folder_name = "test_folder"
        fw1 = Firework([
            CreateFolder(folder_name=folder_name, change_dir=False),
            PassCalcLocs(name="fw1")
        ],
                       name="fw3")
        fw2 = Firework([PassCalcLocs(name="fw2")], name="fw2", parents=fw1)
        wf = Workflow([fw1, fw2])
        self.lp.add_wf(wf)
        rapidfire(self.lp)

        fw2 = self.lp.get_fw_by_id(self.lp.get_fw_ids({"name": "fw2"})[0])
        calc_locs = fw2.spec["calc_locs"]

        self.assertTrue(
            os.path.exists(
                get_calc_loc("fw1", calc_locs)["path"] + "/" + folder_name))
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 18
0
    def __init__(
        self,
        parents=None,
        structure=None,
        name="standardize",
        db_file=None,
        prev_calc_dir=None,
        vasp_cmd=None,
        **kwargs
    ):
        """
        Standardize the structure with spglib.

        Args:
            structure (Structure): pmg structure.
            name (str): name of this FW
            db_file (str): path to the db file
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            prev_calc_dir (str): Path to a previous calculation to copy from
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        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,
                    contcar_to_poscar=True,
                )
            )
        elif parents:
            t.append(
                CopyVaspOutputs(
                    calc_loc=True,
                    contcar_to_poscar=True,
                )
            )
        else:
            raise ValueError("Must specify structure or previous calculation")

        t.extend(
            [
                StandardizeCell(),
                PassCalcLocs(name=name),
            ]
        )

        super(StandardizeFW, self).__init__(t, parents=parents, name=fw_name, **kwargs)
Ejemplo n.º 19
0
    def __init__(self,
                 molecules,
                 packing_config,
                 tolerance=2.0,
                 filetype="xyz",
                 control_params=None,
                 output_file="packed.xyz",
                 copy_to_current_on_exit=False,
                 site_property=None,
                 parents=None,
                 name="PackmolFW",
                 packmol_cmd="packmol",
                 **kwargs):
        """

        Args:
            molecules (list): list of constituent molecules(Molecule objects)
            packing_config (list): list of dict config settings for each molecule in the
                molecules list. eg: config settings for a single molecule
                [{"number": 1, "inside box":[0,0,0,100,100,100]}]
            tolerance (float): packmol tolerance
            filetype (string): input/output structure file type
            control_params (dict): packmol control parameters dictionary. Basically all parameters
                other than structure/atoms.
            output_file (str): output file name. The extension will be adjusted according to the filetype.
            copy_to_current_on_exit (bool): whether or not to copy the packed molecule output file
                to the current directory.
            site_property (str): the specified site property will be restored for the final Molecule object.
            parents ([Firework]): parent fireworks
            name (str): firework name
            packmol_cmd (str): path to packmol bin
            **kwargs:
        """
        control_params = control_params or {'maxit': 20, 'nloop': 600}

        tasks = [
            RunPackmol(molecules=molecules,
                       packing_config=packing_config,
                       tolerance=tolerance,
                       filetype=filetype,
                       control_params=control_params,
                       output_file=output_file,
                       copy_to_current_on_exit=copy_to_current_on_exit,
                       site_property=site_property,
                       packmol_cmd=packmol_cmd),
            PassCalcLocs(name=name)
        ]

        super(PackmolFW, self).__init__(tasks,
                                        parents=parents,
                                        name=name,
                                        **kwargs)
Ejemplo n.º 20
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)
Ejemplo n.º 21
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)
Ejemplo n.º 22
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)
Ejemplo n.º 23
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)
Ejemplo n.º 24
0
    def test_passcalclocs(self):
        fw1 = Firework([PassCalcLocs(name="fw1")], name="fw1")
        fw2 = Firework([PassCalcLocs(name="fw2")], name="fw2", parents=fw1)
        fw3 = Firework([PassCalcLocs(name="fw3")], name="fw3", parents=fw2)

        wf = Workflow([fw1, fw2, fw3])
        self.lp.add_wf(wf)
        rapidfire(self.lp)

        fw2 = self.lp.get_fw_by_id(self.lp.get_fw_ids({"name": "fw2"})[0])
        fw3 = self.lp.get_fw_by_id(self.lp.get_fw_ids({"name": "fw3"})[0])

        self.assertEqual(len(fw2.spec["calc_locs"]), 1)
        self.assertEqual(len(fw3.spec["calc_locs"]), 2)
        self.assertEqual(fw3.spec["calc_locs"][0]["name"], "fw1")
        self.assertEqual(fw3.spec["calc_locs"][1]["name"], "fw2")
        self.assertNotEqual(fw3.spec["calc_locs"][0]["path"],
                            fw3.spec["calc_locs"][1]["path"])

        calc_locs = fw3.spec["calc_locs"]
        self.assertEqual(get_calc_loc("fw1", calc_locs), calc_locs[0])
        self.assertEqual(get_calc_loc("fw2", calc_locs), calc_locs[1])
        self.assertEqual(get_calc_loc(True, calc_locs), calc_locs[1])
Ejemplo n.º 25
0
    def __init__(self,
                 structure,
                 name="boltztrap",
                 db_file=None,
                 parents=None,
                 scissor=0.0,
                 doping=None,
                 tmax=1300,
                 tgrid=50,
                 soc=False,
                 additional_fields=None,
                 **kwargs):
        """
        Run Boltztrap (which includes writing bolztrap input files and parsing outputs). Assumes 
        you have a previous FW with the calc_locs passed into the current FW.

        Args:
            structure (Structure): - only used for setting name of FW
            name (str): name of this FW
            db_file (str): path to the db file
            parents (Firework): Parents of this particular Firework. FW or list of FWS.
            scissor (float): if scissor > 0, apply scissor on the band structure so that new
                band gap = scissor (in eV)
            doping: ([float]) doping levels you want to compute
            tmax: (float) max temperature to evaluate
            tgrid: (float) temperature interval
            soc (bool): whether the band structure is calculated with spin-orbit coupling
            additional_fields (dict): fields added to the document such as user-defined tags or name, ids, etc
            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
        """
        additional_fields = additional_fields or {}
        t = [
            CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True),
            RunBoltztrap(scissor=scissor,
                         soc=soc,
                         doping=doping,
                         tmax=tmax,
                         tgrid=tgrid),
            BoltztrapToDb(db_file=db_file,
                          additional_fields=additional_fields),
            PassCalcLocs(name=name)
        ]
        super(BoltztrapFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
Ejemplo n.º 26
0
    def __init__(self,
                 control,
                 structure,
                 name="TDDFT",
                 aims_cmd='mpirun aims',
                 job_type="tddft",
                 max_force_threshold=0.01,
                 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__.
        """

        t = list()
        t.append(WriteAimsFromIOSet(control=control, structure=structure))
        t.append(
            RunAimsCustodian(aims_cmd=aims_cmd,
                             job_type=job_type,
                             max_force_threshold=max_force_threshold))
        t.append(PassCalcLocs(name=name))

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

        super(TDDFTFW, self).__init__(
            t,
            parents=parents,
            name="{}-{}".format(
                '-'.join(structure.composition.reduced_formula), name),
            **kwargs)