コード例 #1
0
 def test_ioset_explicit(self):
     ft = WriteVaspFromIOSet(
         dict(structure=self.struct_si,
              vasp_input_set=MPRelaxSet(self.struct_si, force_gamma=True)))
     ft = load_object(ft.to_dict())  # simulate database insertion
     ft.run_task({})
     self._verify_files()
コード例 #2
0
 def test_ioset_explicit(self):
     ft = WriteVaspFromIOSet(
         dict(structure=self.struct_si, vasp_input_set=MPRelaxSet(self.struct_si, force_gamma=True))
     )
     ft = load_object(ft.to_dict())  # simulate database insertion
     ft.run_task({})
     self._verify_files()
コード例 #3
0
ファイル: test_write_vasp.py プロジェクト: jwz360/atomate
 def test_potcar_spec(self):
     ft = WriteVaspFromIOSet(
         structure=self.struct_si,
         vasp_input_set="MPRelaxSet",
         potcar_spec=True,
     )
     ft = load_object(ft.to_dict())  # simulate database insertion
     ft.run_task({})
     self._verify_files(potcar_spec=True)
コード例 #4
0
 def test_ioset_params(self):
     ft = WriteVaspFromIOSet(
         dict(structure=self.struct_si, vasp_input_set="MPRelaxSet",
              vasp_input_params={"user_incar_settings": {"ISMEAR": 1000}}))
     ft = load_object(ft.to_dict())  # simulate database insertion
     ft.run_task({})
     incar = Incar.from_file("INCAR")
     self.assertEqual(incar["ISMEAR"], 1000)  # make sure override works
     incar['ISMEAR'] = -5  # switch back to default
     incar.write_file("INCAR")
     self._verify_files(skip_kpoints=True)
コード例 #5
0
 def test_ioset_params(self):
     ft = WriteVaspFromIOSet(
         dict(structure=self.struct_si, vasp_input_set="MPRelaxSet",
              vasp_input_params={"user_incar_settings": {"ISMEAR": 1000}}))
     ft = load_object(ft.to_dict())  # simulate database insertion
     ft.run_task({})
     incar = Incar.from_file("INCAR")
     self.assertEqual(incar["ISMEAR"], 1000)  # make sure override works
     incar['ISMEAR'] = -5  # switch back to default
     incar.write_file("INCAR")
     self._verify_files(skip_kpoints=True)
コード例 #6
0
ファイル: core.py プロジェクト: lnibbeli/atomate
    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)
コード例 #7
0
ファイル: core.py プロジェクト: uguryorulmaz/atomate
    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)
コード例 #8
0
ファイル: core.py プロジェクト: MahdiDavari/atomate
    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)
コード例 #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)
コード例 #10
0
ファイル: core.py プロジェクト: uguryorulmaz/atomate
    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)
コード例 #11
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)
コード例 #12
0
ファイル: core.py プロジェクト: uguryorulmaz/atomate
    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)
コード例 #13
0
ファイル: core.py プロジェクト: amyncarol/atomate
    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)
コード例 #14
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)
コード例 #15
0
ファイル: core.py プロジェクト: uguryorulmaz/atomate
    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)
コード例 #16
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)
コード例 #17
0
ファイル: approx_neb.py プロジェクト: samblau/atomate
    def __init__(self,
                 structure,
                 approx_neb_wf_uuid,
                 db_file=DB_FILE,
                 vasp_input_set=None,
                 vasp_cmd=VASP_CMD,
                 override_default_vasp_params=None,
                 job_type="double_relaxation_run",
                 additional_fields=None,
                 tags=None,
                 **kwargs):
        """
        Launches a VASP calculation for the provided empty host structure
        and adds task doc fields for approx_neb workflow record keeping.
        Initializes a doc in the approx_neb collection and stores relevant
        outputs from the host.

        Args:
            structure (Structure): structure of empty host
            approx_neb_wf_uuid (str): unique id for approx neb
                workflow record keeping
            db_file (str): path to file containing the database
                credentials.
            vasp_input_set (VaspInputSet class): can use to
                define VASP input parameters.
                See pymatgen.io.vasp.sets module for more
                information. MPRelaxSet() and
                override_default_vasp_params are used if
                vasp_input_set = None.
            vasp_cmd (str): the name of the full executable for running
                VASP.
            override_default_vasp_params (dict): if provided,
                vasp_input_set is disregarded and the Vasp Input
                Set is created by passing
                override_default_vasp_params to MPRelaxSet().
                Allows for easy modification of MPRelaxSet().
                For example, to set ISIF=2 in the INCAR use:
                {"user_incar_settings":{"ISIF":2}}
            job_type (str): custodian job type
            additional_fields (dict): specifies more information
                to be stored in the approx_neb collection to
                assist user record keeping.
            tags (list): list of strings to be stored in the
                approx_neb collection under the "tags" field to
                assist user record keeping.

            \*\*kwargs: Other kwargs that are passed to Firework.__init__.
            parents ([Firework]): Parents of this particular Firework.
        """
        # set additional_fields to be added to task doc by VaspToDb
        # initiates the information stored in the tasks collection to aid record keeping
        fw_name = "{} {}".format(structure.composition.reduced_formula, "host")
        fw_spec = {
            "tags": ["approx_neb", approx_neb_wf_uuid, "host", "relaxation"]
        }
        task_doc_additional_fields = {
            "approx_neb": {
                "wf_uuids": [],
                "_source_wf_uuid": approx_neb_wf_uuid,
                "calc_type": "host",
                "task_label": "relaxation",
            }
        }

        override_default_vasp_params = override_default_vasp_params or {}
        vasp_input_set = vasp_input_set or MPRelaxSet(
            structure, **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))
        t.append(PassCalcLocs(name="host"))
        t.append(
            VaspToDb(
                db_file=db_file,
                additional_fields=task_doc_additional_fields,
                parse_chgcar=True,
                task_fields_to_push={"host_task_id": "task_id"},
            ))
        t.append(
            HostToDb(
                db_file=db_file,
                approx_neb_wf_uuid=approx_neb_wf_uuid,
                additional_fields=additional_fields,
                tags=tags,
            ))
        super().__init__(tasks=t, spec=fw_spec, name=fw_name, **kwargs)
コード例 #18
0
ファイル: fworks.py プロジェクト: ghifi37/dfttk
    def __init__(self,
                 structure,
                 scale_lattice=None,
                 symmetry_tolerance=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,
                 modify_incar=None,
                 force_gamma=True,
                 prev_calc_loc=True,
                 parents=None,
                 db_insert=False,
                 Pos_Shape_relax=False,
                 modify_incar_params={},
                 modify_kpoints_params={},
                 **kwargs):

        metadata = metadata or {}
        override_default_vasp_params = override_default_vasp_params or {}
        vasp_input_set = vasp_input_set or RelaxSet(
            structure, 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(
                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<<"))
        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,
                                          Pos_Shape_relax=Pos_Shape_relax))
        if db_insert:
            t.append(
                VaspToDb(db_file=db_file,
                         additional_fields={
                             "task_label": name,
                             "metadata": metadata
                         }))
        # This has to happen at the end because dynamically adding Fireworks if the symmetry breaks skips the rest of the tasks in the Firework.
        if symmetry_tolerance is not None:
            t.append(
                CheckSymmetry(tolerance=symmetry_tolerance,
                              vasp_cmd=vasp_cmd,
                              db_file=db_file,
                              structure=structure,
                              metadata=metadata,
                              name=name,
                              modify_incar_params=modify_incar_params,
                              modify_kpoints_params=modify_kpoints_params,
                              Pos_Shape_relax=Pos_Shape_relax))
        super(OptimizeFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
コード例 #19
0
 def test_ioset_implicit(self):
     ft = WriteVaspFromIOSet(dict(structure=self.struct_si, vasp_input_set="MPRelaxSet"))
     ft = load_object(ft.to_dict())  # simulate database insertion
     ft.run_task({})
     self._verify_files(skip_kpoints=True)
コード例 #20
0
ファイル: core.py プロジェクト: MahdiDavari/atomate
    def __init__(self,
                 structure,
                 name="static dielectric",
                 vasp_cmd="vasp",
                 copy_vasp_outputs=True,
                 db_file=None,
                 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__.
        """
        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:
                # TODO: @matk86 - I really don't understand the point of setting phonon=True w/o
                # the mode or displacement. It seems to simply be running a regular static run and
                # doing nothing else than changing the name of the Firework and perhaps passing
                # normal modes data (but it's unclear how that data is generated. Why would anyone
                # want to do this? -computron
                name = "{} {}".format("phonon", name)

                # TODO: @matk86 - not sure why this line is here. I understand you are trying to
                # keep the code short but the logic is very confusing. The RunVaspCustodian is
                # common to all 3 situations (phonon=F, phonon=T/mode=F, phonon=T/mode=T) yet is
                # duplicated in each place. Instead, for better clarity construct the Firework
                # sequentially (write inputs, run vasp, parse output data, pass output data) and
                # add if/else for phonons where it is needed. Any name overrides can go near the
                # top of the Firework. -computron
                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:
                # TODO: @matk86 - Why is this second calculation being tacked on to the first one?
                # It looks like it will overwrite INCAR/CHGCAR/etc of the first calculation and
                # thus completely remove access to the original output files. Shouldn't this be a
                # new Firework rather than a second calculation in the same Firework? -computron
                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)
コード例 #21
0
    def __init__(self,
                 structure,
                 isif=4,
                 name="structure optimization",
                 override_symmetry_tolerances=None,
                 job_type="normal",
                 vasp_cmd="vasp_std",
                 metadata=None,
                 override_default_vasp_params=None,
                 db_file=None,
                 prev_calc_loc=True,
                 parents=None,
                 db_insert=False,
                 tag=None,
                 **kwargs):

        metadata = metadata or {}
        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 {}
        override_symmetry_tolerances = override_symmetry_tolerances or {}
        vasp_input_set = 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(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))
        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
                         }))
        common_kwargs = {
            'vasp_cmd': vasp_cmd,
            'db_file': db_file,
            "metadata": metadata,
            "tag": tag
        }
        relax_kwargs = {}
        static_kwargs = {}
        t.append(
            CheckRelaxation(db_file=db_file,
                            metadata=metadata,
                            tag=tag,
                            common_kwargs=common_kwargs,
                            relax_kwargs=relax_kwargs,
                            static_kwargs=static_kwargs,
                            **override_symmetry_tolerances))
        super().__init__(t,
                         parents=parents,
                         name="{}-{}".format(
                             structure.composition.reduced_formula, name),
                         **kwargs)
コード例 #22
0
    def __init__(self,
                 structure,
                 start_temp,
                 end_temp,
                 nsteps,
                 name="molecular dynamics",
                 vasp_input_set=None,
                 vasp_cmd="vasp",
                 override_default_vasp_params=None,
                 wall_time=None,
                 db_file=None,
                 parents=None,
                 copy_vasp_outputs=False,
                 previous_structure=False,
                 insert_db=False,
                 save_structure=True,
                 **kwargs):
        """
        This Firework is modified from atomate.vasp.fireworks.core.MDFW to fit the needs of mpmorph
        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 MPMDSet(
            structure,
            start_temp=start_temp,
            end_temp=end_temp,
            nsteps=nsteps,
            **override_default_vasp_params)

        t = []

        t.append(
            WriteVaspFromIOSet(structure=structure,
                               vasp_input_set=vasp_input_set))
        if previous_structure:
            t.append(PreviousStructureTask())
        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))
        if save_structure:
            t.append(SaveStructureTask())
        name = f'{structure.composition.reduced_formula}-{name}'
        if insert_db:
            t.append(
                VaspMDToDb(db_file=db_file,
                           additional_fields={"task_label": name},
                           defuse_unsuccessful=False,
                           md_structures=True))
        super(MDFW, self).__init__(t, parents=parents, name=name, **kwargs)
コード例 #23
0
ファイル: nmr.py プロジェクト: 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)
コード例 #24
0
    def __init__(self,
                 structure,
                 name="structure optimization",
                 vasp_input_set=None,
                 insert_db=True,
                 vasp_cmd="vasp",
                 override_default_vasp_params=None,
                 ediffg=None,
                 db_file=None,
                 force_gamma=True,
                 job_type="double_relaxation_run",
                 max_force_threshold=None,
                 previous_structure=False,
                 auto_npar=">>auto_npar<<",
                 half_kpts_first_relax=False,
                 parents=None,
                 handler_group="default",
                 prev_calc_loc=False,
                 **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 = []
        if prev_calc_loc:
            additional_files = kwargs.get("additional_files", [])
            if "additional_files" in kwargs.keys():
                del kwargs["additional_files"]
            t.append(
                CopyVaspOutputs(calc_loc=prev_calc_loc,
                                contcar_to_poscar=True,
                                additional_files=additional_files))
        t.append(
            WriteVaspFromIOSet(structure=structure,
                               vasp_input_set=vasp_input_set))
        if previous_structure:
            t.append(PreviousStructureTask())
        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,
                             handler_group=handler_group))
        t.append(PassCalcLocs(name=name))
        t.append(SaveStructureTask())

        if insert_db:
            t.append(
                VaspToDb(db_file=db_file,
                         additional_fields={"task_label": name}))
        name = f'{structure.composition.reduced_formula}-{name}'
        super(OptimizeFW, self).__init__(t,
                                         parents=parents,
                                         name=name,
                                         **kwargs)
コード例 #25
0
ファイル: test_write_vasp.py プロジェクト: jwz360/atomate
 def test_ioset_implicit(self):
     ft = WriteVaspFromIOSet(structure=self.struct_si,
                             vasp_input_set="MPRelaxSet")
     ft = load_object(ft.to_dict())  # simulate database insertion
     ft.run_task({})
     self._verify_files(skip_kpoints=True)
コード例 #26
0
ファイル: core.py プロジェクト: amyncarol/atomate
    def __init__(self,
                 structure,
                 name="static dielectric",
                 vasp_cmd="vasp",
                 copy_vasp_outputs=True,
                 db_file=None,
                 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.
            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.
            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 = "{} {}".format("phonon", name)

        user_incar_settings = user_incar_settings or {}
        t = []

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

        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(
            VaspToDb(db_file=db_file, additional_fields={"task_label": name}))

        spec = kwargs.pop("spec", {})
        spec.update({
            "_files_out": {
                "POSCAR": "CONTCAR",
                "OUTCAR": "OUTCAR*",
                'vasprunxml': "vasprun.xml*"
            }
        })

        super(DFPTFW, self).__init__(t,
                                     parents=parents,
                                     name="{}-{}".format(
                                         structure.composition.reduced_formula,
                                         name),
                                     spec=spec,
                                     **kwargs)
コード例 #27
0
ファイル: core.py プロジェクト: samblau/atomate
    def __init__(
        self,
        structure=None,
        name="SCAN structure optimization",
        vasp_input_set=None,
        vasp_input_set_params=None,
        vasp_cmd=VASP_CMD,
        vdw_kernel_dir=VDW_KERNEL_DIR,
        prev_calc_loc=None,
        prev_calc_dir=None,
        db_file=DB_FILE,
        vasptodb_kwargs=None,
        parents=None,
        **kwargs,
    ):
        """
        Structure optimization using the SCAN metaGGA functional. If this Firework is
        initialized with no parents, it will perform a GGA optimization of the provided
        structure using the PBESol functional. This GGA-relaxed structure is intended
        to be passed to a second instance of this Firework for optimization with SCAN.
        (see workflow definition in SCAN_optimization.yaml)

        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 MpScanRelaxSet() if None.
            vasp_input_set_params (dict): Dict of vasp_input_set kwargs.
            vasp_cmd (str): Command to run vasp.
            vdw_kernel_dir (str): Directory containing the pre-compiled VdW
                kernel. Supports env_chk.
            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 SCAN 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)

        has_previous_calc = False

        # Raise a warning if the InputSet is not MPScanRelaxSet, because the
        # kspacing calculation from bandgap is only supported in MPScanRelaxSet.
        if vasp_input_set and not isinstance(vasp_input_set, MPScanRelaxSet):
            raise UserWarning("You have specified a vasp_input_set other than \
                 MPScanRelaxSet. Automatic adjustment of kspacing\
                 is not supported by this InputSet.")

        if prev_calc_dir:
            has_previous_calc = True
            # Copy the CHGCAR from previous calc directory (usually PBE)
            t.append(
                CopyVaspOutputs(
                    calc_dir=prev_calc_dir,
                    contcar_to_poscar=True,
                    additional_files=["CHGCAR"],
                ))
        elif parents:
            if prev_calc_loc:
                has_previous_calc = True
                # Copy the CHGCAR from previous calc location (usually PBE)
                t.append(
                    CopyVaspOutputs(
                        calc_loc=prev_calc_loc,
                        contcar_to_poscar=True,
                        additional_files=["CHGCAR"],
                    ))
            else:
                raise UserWarning(
                    "You specified parent Firework but did not provide its location. Set "
                    "prev_calc_dir or prev_calc_loc and try again.")
        elif prev_calc_loc:
            raise UserWarning(
                "You specified prev_calc_loc but did not provide a parent Firework. Set "
                "parents and try again.")

        if has_previous_calc:
            # Update the InputSet with the bandgap from the previous calc
            t.append(
                WriteScanRelaxFromPrev(
                    vasp_input_set_params=vasp_input_set_params))

            # Set ICHARG to 1 to utilize the pre-existing CHGCAR
            settings = {"_set": {"ICHARG": 1}}

            if vasp_input_set_params.get("vdw"):
                # Copy the pre-compiled VdW kernel for VASP
                t.append(
                    CopyFiles(files_to_copy=["vdw_kernel.bindat"],
                              from_dir=vdw_kernel_dir))

                # Enable vdW for the SCAN step
                settings["_set"]["LUSE_VDW"] = True
                settings["_set"]["BPARAM"] = 15.7

            t.append(ModifyIncar(incar_dictmod=settings))

            # use the 'scan' custodian handler group
            handler_group = "scan"

        elif structure:
            vasp_input_set = vasp_input_set or MPScanRelaxSet(
                structure, **vasp_input_set_params)
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))
            # Update the INCAR for the PBESol GGA preconditioning step
            pre_opt_settings = {
                "_set": {
                    "GGA": "Ps",
                    "METAGGA": None,
                    "EDIFFG": -0.05
                }
            }

            # Disable vdW for the precondition step
            if vasp_input_set_params.get("vdw"):
                pre_opt_settings.update(
                    {"_unset": {
                        "LUSE_VDW": True,
                        "BPARAM": 15.7
                    }})

            t.append(ModifyIncar(incar_dictmod=pre_opt_settings))

            # use the 'default' custodian handler group
            handler_group = "default"
        else:
            raise ValueError("Must specify structure or previous calculation")

        # Run VASP
        t.append(
            RunVaspCustodian(
                vasp_cmd=vasp_cmd,
                auto_npar=">>auto_npar<<",
                handler_group=handler_group,
                gzip_output=False,
            ))
        t.append(PassCalcLocs(name=name))
        # Parse
        t.append(VaspToDb(db_file=db_file, **vasptodb_kwargs))
        # Delete the VdW kernel
        t.append(DeleteFiles(files=["vdw_kernel.bindat"]))
        # zip the output (don't rely on custodian to do it)
        t.append(GzipDir())

        super().__init__(t, parents=parents, name=fw_name, **kwargs)
コード例 #28
0
    def __init__(self,
                 structure,
                 supercell_matrix,
                 t_min=5,
                 t_max=2000,
                 t_step=5,
                 name="phonon",
                 vasp_input_set=None,
                 vasp_cmd="vasp",
                 metadata=None,
                 tag=None,
                 prev_calc_loc=True,
                 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())
            warnings.warn(
                'No ``tag`` was passed explicitly or in ``metadata`` to PRLPhononFW. In order to find this Firework later, you should assign one. This was assigned: {}'
                .format(tag))
            metadata['tag'] = tag

        vasp_input_set = vasp_input_set or PRLForceConstantsSet(structure)

        t = []

        # We need to get the POSCAR from the previous run or from the passed Structure
        # so it can be transformed to a supercell in the next step
        if parents:
            if prev_calc_loc:
                t.append(
                    CopyVaspOutputs(calc_loc=prev_calc_loc,
                                    contcar_to_poscar=True))
        else:
            # write the input set first, just to get the POSCAR file in the directory
            # the other inputs will get overridden by WriteVaspFromIOSetPrevStructure
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))

        t.append(SupercellTransformation(supercell_matrix=supercell_matrix))
        t.append(
            WriteVaspFromIOSetPrevStructure(vasp_input_set=vasp_input_set))
        t.append(
            RunVaspCustodian(vasp_cmd=vasp_cmd,
                             auto_npar=">>auto_npar<<",
                             gzip_output=False))
        t.append(PassCalcLocs(name=name))
        t.append(
            CalculatePhononThermalProperties(supercell_matrix=supercell_matrix,
                                             t_min=t_min,
                                             t_max=t_max,
                                             t_step=t_step,
                                             db_file=db_file,
                                             tag=tag,
                                             metadata=metadata))

        super(PRLPhononFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
コード例 #29
0
    def __init__(self,
                 structure,
                 symmetry_tolerance=None,
                 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 RelaxSet(
            structure, force_gamma=force_gamma, **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:
            vasp_input_set = vasp_input_set or RelaxSet(structure)
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))
        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
                         }))
        # This has to happen at the end because dynamically adding Fireworks if the symmetry breaks skips the rest of the tasks in the Firework.
        if symmetry_tolerance is not None:
            t.append(
                CheckSymmetry(tolerance=symmetry_tolerance,
                              vasp_cmd=vasp_cmd,
                              db_file=db_file,
                              structure=structure,
                              metadata=metadata,
                              name=name))
        super(OptimizeFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             **kwargs)
コード例 #30
0
ファイル: myfireworks.py プロジェクト: Baijianlu/AICON2
    def __init__(self,
                 structure=None,
                 prev_calc_dir=None,
                 name="phonon band",
                 vasp_cmd=VASP_CMD,
                 prev_calc_loc=True,
                 db_file=DB_FILE,
                 parents=None,
                 user_incar_settings=None,
                 user_kpoints_settings=None,
                 supercell=None,
                 **kwargs):
        """
        Phonon calculation Firework using finite difference method

        Args:
            structure (Structure): Input structure. If prev_calc_loc, used only to set the
                name of the FW.
            name (str): Name for the Firework.
            vasp_cmd (str): Command to run vasp.
            prev_calc_loc (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
            user_kpoints_settings (Kpoint): Kpoint set to use.
            supercell (list) size of supercell: 
            \*\*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))
            t.append(
                WriteVaspStaticFromPrev(
                    user_incar_settings=user_incar_settings,
                    standardize=False,
                    supercell=supercell))
        elif parents and prev_calc_loc:
            t.append(
                CopyVaspOutputs(calc_loc=prev_calc_loc,
                                contcar_to_poscar=True))
            t.append(
                WriteVaspStaticFromPrev(
                    user_incar_settings=user_incar_settings,
                    standardize=False,
                    supercell=supercell))
        elif structure:
            vasp_input_set = MPStaticSet(
                structure,
                user_kpoints_settings=user_kpoints_settings,
                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(WriteSupercellWithDisp(supercell=supercell))
        t.append(PassCalcLocs(name=name))

        super(MyPhononFiniteDiffFW, self).__init__(t,
                                                   parents=parents,
                                                   name=fw_name,
                                                   **kwargs)
コード例 #31
0
ファイル: core.py プロジェクト: lnibbeli/atomate
    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)
コード例 #32
0
ファイル: myfireworks.py プロジェクト: Baijianlu/AICON2
    def __init__(self,
                 structure,
                 name="structure optimization",
                 vasp_input_set=None,
                 vasp_input_set_params=None,
                 count=1,
                 vasp_cmd=VASP_CMD,
                 ediffg=None,
                 db_file=DB_FILE,
                 prev_calc_loc=False,
                 strain=0.0,
                 force_gamma=True,
                 job_type="normal",
                 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. 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. Defaults to MPRelaxSet() if None.
            vasp_input_set_params (dict): Parameters in INCAR to override.
            count (int): A counter to record round of structure optimization.
            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.
            prev_calc_loc (bool or str): If true, 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.
            strain (float): strain executed on structure in each direction of lattice. 
            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 = []
        if parents and prev_calc_loc:
            t.append(
                CopyVaspOutputs(calc_loc=prev_calc_loc,
                                contcar_to_poscar=True))
            t.append(
                WriteVaspForDeformedCrystal(
                    strain=strain, user_incar_settings=vasp_input_set_params))
        else:
            t.append(
                WriteVaspFromIOSet(structure=structure,
                                   vasp_input_set=vasp_input_set))
        t.append(
            RunVaspCustodian(vasp_cmd=vasp_cmd,
                             job_type=job_type,
                             auto_npar=auto_npar,
                             gzip_output=False))
        t.append(
            CheckOptimization(vasp_input_set=vasp_input_set,
                              vasp_input_set_params=vasp_input_set_params,
                              vasp_cmd=vasp_cmd,
                              db_file=db_file,
                              name=name,
                              count=count,
                              kwargs=kwargs))

        super(MyOptimizeFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}-{}".format(
                                 structure.composition.reduced_formula, name,
                                 str(count)),
                             **kwargs)