예제 #1
0
파일: core.py 프로젝트: shyamd/MatMethods
    def __init__(self, structure=None, prev_calc_dir=None, name="static dielectric", vasp_cmd="vasp",
                 copy_vasp_outputs=True, lepsilon=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.
            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)
예제 #2
0
    def __init__(self, structure=None, prev_calc_dir=None, name="static dielectric", vasp_cmd=VASP_CMD,
                 copy_vasp_outputs=True, lepsilon=True,
                 db_file=DB_FILE, parents=None, user_incar_settings=None,
                 pass_nm_results=False, **kwargs):
        """
         Static DFPT calculation Firework

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

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

        user_incar_settings = user_incar_settings or {}
        t = []

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

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))

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

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

        super(DFPTFW, self).__init__(t, parents=parents, name=fw_name, **kwargs)
예제 #3
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)
예제 #4
0
파일: core.py 프로젝트: shyamd/MatMethods
    def __init__(self, mode, displacement, prev_calc_dir=None, structure=None, name="raman",
                 vasp_cmd="vasp", db_file=None,
                 parents=None, user_incar_settings=None, **kwargs):
        """
        Static calculation Firework that computes the DFPT dielectric constant for
        structure displaced along the given normal mode direction.

        Args:
            structure (Structure): Input structure. If copy_vasp_outputs, used only to set the
                name of the FW.
            mode (int): normal mode index.
            displacement (float): displacement along the normal mode in Angstroms.
            name (str): Name for the Firework.
            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)
예제 #5
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)
예제 #6
0
def get_wf_elastic_constant(structure,
                            metadata,
                            strain_states=None,
                            stencils=None,
                            db_file=None,
                            conventional=False,
                            order=2,
                            vasp_input_set=None,
                            analysis=True,
                            sym_reduce=False,
                            tag='elastic',
                            copy_vasp_outputs=False,
                            **kwargs):
    """
    Returns a workflow to calculate elastic constants.

    Firework 1 : write vasp input set for structural relaxation,
                 run vasp,
                 pass run location,
                 database insertion.

    Firework 2 - number of total deformations: Static runs on the deformed structures

    last Firework : Analyze Stress/Strain data and fit the elastic tensor

    Args:
        structure (Structure): input structure to be optimized and run.
        strain_states (list of Voigt-notation strains): list of ratios of nonzero elements
            of Voigt-notation strain, e. g. [(1, 0, 0, 0, 0, 0), (0, 1, 0, 0, 0, 0), etc.].
        stencils (list of floats, or list of list of floats): values of strain to multiply
            by for each strain state, i. e. stencil for the perturbation along the strain
            state direction, e. g. [-0.01, -0.005, 0.005, 0.01].  If a list of lists,
            stencils must correspond to each strain state provided.
        db_file (str): path to file containing the database credentials.
        conventional (bool): flag to convert input structure to conventional structure,
            defaults to False.
        order (int): order of the tensor expansion to be determined.  Defaults to 2 and
            currently supports up to 3.
        vasp_input_set (VaspInputSet): vasp input set to be used.  Defaults to static
            set with ionic relaxation parameters set.  Take care if replacing this,
            default ensures that ionic relaxation is done and that stress is calculated
            for each vasp run.
        analysis (bool): flag to indicate whether analysis task should be added
            and stresses and strains passed to that task
        sym_reduce (bool): Whether or not to apply symmetry reductions
        tag (str):
        copy_vasp_outputs (bool): whether or not to copy previous vasp outputs.
        kwargs (keyword arguments): additional kwargs to be passed to get_wf_deformations

    Returns:
        Workflow
    """
    # Convert to conventional if specified
    if conventional:
        structure = SpacegroupAnalyzer(
            structure).get_conventional_standard_structure()

    uis_elastic = {
        "IBRION": 2,
        "NSW": 99,
        "ISIF": 2,
        "ISTART": 1,
        "PREC": "High"
    }
    vis = vasp_input_set or MPStaticSet(structure,
                                        user_incar_settings=uis_elastic)

    strains = []
    if strain_states is None:
        strain_states = get_default_strain_states(order)
    if stencils is None:
        stencils = [np.linspace(-0.01, 0.01, 5 +
                                (order - 2) * 2)] * len(strain_states)
    if np.array(stencils).ndim == 1:
        stencils = [stencils] * len(strain_states)
    for state, stencil in zip(strain_states, stencils):
        strains.extend(
            [Strain.from_voigt(s * np.array(state)) for s in stencil])

    # Remove zero strains
    strains = [strain for strain in strains if not (abs(strain) < 1e-10).all()]
    # Adding the zero strains for the purpose of calculating at finite pressure or thermal expansion
    _strains = [Strain.from_deformation([[1, 0, 0], [0, 1, 0], [0, 0, 1]])]
    strains.extend(_strains)
    """
    """
    vstrains = [strain.voigt for strain in strains]
    if np.linalg.matrix_rank(vstrains) < 6:
        # TODO: check for sufficiency of input for nth order
        raise ValueError(
            "Strain list is insufficient to fit an elastic tensor")

    deformations = [s.get_deformation_matrix() for s in strains]
    """
    print(strains)
    print(deformations)
    """

    if sym_reduce:
        # Note this casts deformations to a TensorMapping
        # with unique deformations as keys to symmops
        deformations = symmetry_reduce(deformations, structure)

    wf_elastic = get_wf_deformations(structure,
                                     deformations,
                                     tag=tag,
                                     db_file=db_file,
                                     vasp_input_set=vis,
                                     copy_vasp_outputs=copy_vasp_outputs,
                                     **kwargs)
    if analysis:
        defo_fws_and_tasks = get_fws_and_tasks(
            wf_elastic,
            fw_name_constraint="deformation",
            task_name_constraint="Transmuted")
        for idx_fw, idx_t in defo_fws_and_tasks:
            defo = \
            wf_elastic.fws[idx_fw].tasks[idx_t]['transformation_params'][0][
                'deformation']
            pass_dict = {
                'strain': Deformation(defo).green_lagrange_strain.tolist(),
                'stress': '>>output.ionic_steps.-1.stress',
                'deformation_matrix': defo
            }
            if sym_reduce:
                pass_dict.update({'symmops': deformations[defo]})

            mod_spec_key = "deformation_tasks->{}".format(idx_fw)
            pass_task = pass_vasp_result(pass_dict=pass_dict,
                                         mod_spec_key=mod_spec_key)
            wf_elastic.fws[idx_fw].tasks.append(pass_task)

        fw_analysis = Firework(ElasticTensorToDb(structure=structure,
                                                 db_file=db_file,
                                                 order=order,
                                                 fw_spec_field='tags',
                                                 metadata=metadata,
                                                 vasp_input_set=vis),
                               name="Analyze Elastic Data",
                               spec={"_allow_fizzled_parents": True})
        wf_elastic.append_wf(Workflow.from_Firework(fw_analysis),
                             wf_elastic.leaf_fw_ids)

    wf_elastic.name = "{}:{}".format(structure.composition.reduced_formula,
                                     "elastic constants")

    return wf_elastic
예제 #7
0
def get_wf_elastic_constant(structure, strain_states=None, stencils=None,
                            db_file=None,
                            conventional=False, order=2, vasp_input_set=None,
                            analysis=True,
                            sym_reduce=False, tag='elastic',
                            copy_vasp_outputs=False, **kwargs):
    """
    Returns a workflow to calculate elastic constants.

    Firework 1 : write vasp input set for structural relaxation,
                 run vasp,
                 pass run location,
                 database insertion.

    Firework 2 - number of total deformations: Static runs on the deformed structures

    last Firework : Analyze Stress/Strain data and fit the elastic tensor

    Args:
        structure (Structure): input structure to be optimized and run.
        strain_states (list of Voigt-notation strains): list of ratios of nonzero elements
            of Voigt-notation strain, e. g. [(1, 0, 0, 0, 0, 0), (0, 1, 0, 0, 0, 0), etc.].
        stencils (list of floats, or list of list of floats): values of strain to multiply
            by for each strain state, i. e. stencil for the perturbation along the strain
            state direction, e. g. [-0.01, -0.005, 0.005, 0.01].  If a list of lists,
            stencils must correspond to each strain state provided.
        db_file (str): path to file containing the database credentials.
        conventional (bool): flag to convert input structure to conventional structure,
            defaults to False.
        order (int): order of the tensor expansion to be determined.  Defaults to 2 and
            currently supports up to 3.
        vasp_input_set (VaspInputSet): vasp input set to be used.  Defaults to static
            set with ionic relaxation parameters set.  Take care if replacing this,
            default ensures that ionic relaxation is done and that stress is calculated
            for each vasp run.
        analysis (bool): flag to indicate whether analysis task should be added
            and stresses and strains passed to that task
        sym_reduce (bool): Whether or not to apply symmetry reductions
        tag (str):
        copy_vasp_outputs (bool): whether or not to copy previous vasp outputs.
        kwargs (keyword arguments): additional kwargs to be passed to get_wf_deformations

    Returns:
        Workflow
    """
    # Convert to conventional if specified
    if conventional:
        structure = SpacegroupAnalyzer(
            structure).get_conventional_standard_structure()

    uis_elastic = {"IBRION": 2, "NSW": 99, "ISIF": 2, "ISTART": 1,
                   "PREC": "High"}
    vis = vasp_input_set or MPStaticSet(structure,
                                        user_incar_settings=uis_elastic)
    strains = []
    if strain_states is None:
        strain_states = get_default_strain_states(order)
    if stencils is None:
        stencils = [np.linspace(-0.01, 0.01, 5 + (order - 2) * 2)] * len(
            strain_states)
    if np.array(stencils).ndim == 1:
        stencils = [stencils] * len(strain_states)
    for state, stencil in zip(strain_states, stencils):
        strains.extend(
            [Strain.from_voigt(s * np.array(state)) for s in stencil])

    # Remove zero strains
    strains = [strain for strain in strains if not (abs(strain) < 1e-10).all()]
    vstrains = [strain.voigt for strain in strains]
    if np.linalg.matrix_rank(vstrains) < 6:
        # TODO: check for sufficiency of input for nth order
        raise ValueError("Strain list is insufficient to fit an elastic tensor")

    deformations = [s.get_deformation_matrix() for s in strains]

    if sym_reduce:
        # Note this casts deformations to a TensorMapping
        # with unique deformations as keys to symmops
        deformations = symmetry_reduce(deformations, structure)

    wf_elastic = get_wf_deformations(structure, deformations, tag=tag,
                                     db_file=db_file,
                                     vasp_input_set=vis,
                                     copy_vasp_outputs=copy_vasp_outputs,
                                     **kwargs)
    if analysis:
        defo_fws_and_tasks = get_fws_and_tasks(wf_elastic,
                                               fw_name_constraint="deformation",
                                               task_name_constraint="Transmuted")
        for idx_fw, idx_t in defo_fws_and_tasks:
            defo = \
            wf_elastic.fws[idx_fw].tasks[idx_t]['transformation_params'][0][
                'deformation']
            pass_dict = {
                'strain': Deformation(defo).green_lagrange_strain.tolist(),
                'stress': '>>output.ionic_steps.-1.stress',
                'deformation_matrix': defo}
            if sym_reduce:
                pass_dict.update({'symmops': deformations[defo]})

            mod_spec_key = "deformation_tasks->{}".format(idx_fw)
            pass_task = pass_vasp_result(pass_dict=pass_dict,
                                         mod_spec_key=mod_spec_key)
            wf_elastic.fws[idx_fw].tasks.append(pass_task)

        fw_analysis = Firework(
            ElasticTensorToDb(structure=structure, db_file=db_file,
                              order=order, fw_spec_field='tags'),
            name="Analyze Elastic Data", spec={"_allow_fizzled_parents": True})
        wf_elastic.append_wf(Workflow.from_Firework(fw_analysis),
                             wf_elastic.leaf_fw_ids)

    wf_elastic.name = "{}:{}".format(structure.composition.reduced_formula,
                                     "elastic constants")

    return wf_elastic
예제 #8
0
파일: core.py 프로젝트: shyamd/MatMethods
    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__.
        """
        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)
예제 #9
0
파일: core.py 프로젝트: amyncarol/atomate
    def __init__(self,
                 structure,
                 mode,
                 displacement,
                 name="raman",
                 vasp_cmd="vasp",
                 db_file=None,
                 parents=None,
                 user_incar_settings=None,
                 **kwargs):
        """
        Static calculation Firework that computes the DFPT dielectric constant for
        structure displaced along the given normal mode direction.

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

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

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

        t = []

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

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

        t.append(RunVaspCustodian(vasp_cmd=vasp_cmd))

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

        t.append(PassCalcLocs(name=name))

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

        super(RamanFW,
              self).__init__(t,
                             parents=parents,
                             name="{}-{}".format(
                                 structure.composition.reduced_formula, name),
                             spec=spec,
                             **kwargs)
예제 #10
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)
예제 #11
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)