How to use the fireworks.Firework function in FireWorks

To help you get started, we’ve selected a few FireWorks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hackingmaterials / rocketsled / rocketsled / tests.py View on Github external
spec = {'_x_opt': x}
    dims = [(1, 10), (10.0, 20.0), ['blue', 'green', 'red', 'orange']]
    fw0 = Firework(AdditionTask(), spec={"input_array": [1, 2]}, name='Parent')
    fw1 = Firework(AdditionTask(), spec={"input_array": [2, 3]}, name='Child A')
    fw2 = Firework(AdditionTask(), spec={"input_array": [3, 4]}, name='Child B')

    bt = BasicTestTask()
    ot = OptTask(wf_creator='rocketsled.tests.wf_creator_complex',
                 dimensions=dims,
                 lpad=launchpad,
                 wf_creator_args=[launchpad],
                 opt_label='test_complex')
    fw3 = Firework([bt, ot], spec=spec, name="Optimization")

    fw4 = Firework(AdditionTask(), spec={"input_array": [5, 6]}, name='After 1')
    fw5 = Firework(ScriptTask.from_str('echo "ScriptTask: Finished complex workflow w/ optimization."'), name='After 2')

    return Workflow([fw0, fw1, fw2, fw3, fw4, fw5],
                    {fw0: [fw1, fw2], fw1: [fw3], fw2: [fw3], fw3: [fw4], fw4: [fw5], fw5: []})
github hackingmaterials / automatminer / automatminer_dev / workflows.py View on Github external
foldspec["fold"] = fold
        foldspec["save_dir"] = save_dir

        if fold == 0 and cache:
            pipename = "{}fold {} + featurization ({})".format(dataset_name,
                                                               fold,
                                                               benchmark_hash)
        else:
            pipename = "{}fold {} ({})".format(dataset_name, fold,
                                               benchmark_hash)

        fws_all_folds.append(Firework([RunPipe(), StorePipeResults()],
                                      spec=foldspec,
                                      name=pipename))

    fw_consolidate = Firework(ConsolidatePipesToBenchmark(),
                              spec=common_spec,
                              name="bench merge ({})".format(benchmark_hash))

    if cache:
        fw_fold0 = fws_all_folds[0]
        fws_folds = fws_all_folds[1:]
        links = {fw: [fw_consolidate] for fw in fws_folds}
        links[fw_fold0] = fws_folds
        links[fw_consolidate] = []
    else:
        links = {fw: [fw_consolidate] for fw in fws_all_folds}
        links[fw_consolidate] = []
        fw_fold0 = fws_all_folds

    if return_fireworks:
        connected_to_top_wf = [fw_fold0] if cache else fw_fold0
github SUNCAT-Center / CatalysisHubBackend / apps / fireworks / __init__.py View on Github external
atoms = calculation[dft_code][dft_functional]['gas'][gp_name]

                with StringIO.StringIO() as outfile:
                    ase.io.write(outfile, atoms, format='py')
                    atoms_string = outfile.getvalue()

                firetask = fw.ScriptTask(
                    shell_exe='/home/vossj/suncat/bin/python',
                    script=string.Template(SCRIPT_TEMPLATE).safe_substitute(
                        keys=keys,
                        atoms=atoms_string,
                        calculator_import='from espresso import espresso',
                        calculator_constructor='espresso',
                    )
                )
                firework = fw.Firework(firetask, name=gp_name)
                tasks.append(firework)
    return tasks
github materialsproject / mpmorph / mpmorph / workflow / old_temp_mdtasks.py View on Github external
if final_run or snaps:
                if diffusion_bool:
                    _steps = 40000
                    _name = "diffusion_run"
                else:
                    _steps = 10000
                    _name = "longrun"
                fw_list = self.get_final_run_fws(_poscar.structure, name=_name, copy_calcs=copy_calcs,
                                                 calc_home=calc_home, target_steps=_steps, temperature=temperature,
                                                 priority_spec=priority_spec)
            if snaps:
                t = []
                t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR"]))
                t.append(StructureSamplerTask(copy_calcs=copy_calcs, calc_home=calc_home, n_snapshots=1, priority_spec=priority_spec))
                if len(fw_list) > 0:
                    new_fw = Firework(t, name=name + "structure_sampler", parents=fw_list[len(fw_list)-1], spec=priority_spec)
                else:
                    new_fw = Firework(t, name=name + "structure_sampler", spec=priority_spec)
                fw_list.append(new_fw)
            if snaps or final_run:
                wf = Workflow(fw_list, name=name + "_" + str(temperature) + "_longruns")
                return FWAction(stored_data={'pressure':p, 'density_calculated': True}, additions=wf)
            return FWAction(stored_data={'pressure':p, 'density_calculated': True})
github materialsproject / mpmorph / mpmorph / workflow / old_temp_workflows.py View on Github external
t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR", "OSZICAR", "DOSCAR"]))
    t.append(WriteSetTask(start_temp=start_temp, end_temp=end_temp, nsteps=nsteps))
    t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, gamma_vasp_cmd=">>gamma_vasp_cmd<<",
                              handler_group="md", wall_time=wall_time, gzip_output=False))
    t.append(PassCalcLocs(name=name + "_cool_" + str(end_temp)))
    if copy_calcs:
        t.append(
            CopyCalsHome(calc_home=os.path.join(calc_home, name), run_name="cool_" + str(end_temp)))

    if relax:
        t.append(RelaxStaticTask(copy_calcs=copy_calcs, calc_home=calc_home, db_file=db_file, snap_num=snap_num,
                                 priority_spec=priority_spec))
        if diffusion:
            t.append(DiffusionTask(copy_calcs=copy_calcs, calc_home=calc_home, db_file=db_file, snap_num=snap_num,
                                   priority_spec=priority_spec))
    return Firework(t, name=name + "_cool_" + str(end_temp), parents=parents, spec=priority_spec)
github hackingmaterials / atomate / matmethods / vasp / workflows / base / thermal_expansion.py View on Github external
Workflow
    """
    try:
        from phonopy import Phonopy
    except ImportError:
        logger.warn("'phonopy' package NOT installed. Required for the final analysis step.")

    tag = datetime.utcnow().strftime('%Y-%m-%d-%H-%M-%S-%f')

    deformations = [Deformation(defo_mat) for defo_mat in deformations]
    wf_alpha = get_wf_deformations(structure, deformations, name="thermal_expansion deformation",
                                   vasp_input_set=vasp_input_set, lepsilon=True, vasp_cmd=vasp_cmd,
                                   db_file=db_file, user_kpoints_settings=user_kpoints_settings,
                                   tag=tag)

    fw_analysis = Firework(ThermalExpansionCoeffTask(tag=tag, db_file=db_file, t_step=t_step,
                                                     t_min=t_min, t_max=t_max, mesh=mesh, eos=eos,
                                                     pressure=pressure),
                           name="Thermal expansion")

    append_fw_wf(wf_alpha, fw_analysis)

    wf_alpha.name = "{}:{}".format(structure.composition.reduced_formula, "thermal expansion")

    return wf_alpha
github materialsproject / mpmorph / mpmorph / workflow / old_temp_mdtasks.py View on Github external
_steps = 40000
                    _name = "diffusion_run"
                else:
                    _steps = 10000
                    _name = "longrun"
                fw_list = self.get_final_run_fws(_poscar.structure, name=_name, copy_calcs=copy_calcs,
                                                 calc_home=calc_home, target_steps=_steps, temperature=temperature,
                                                 priority_spec=priority_spec)
            if snaps:
                t = []
                t.append(CopyVaspOutputs(calc_loc=True, contcar_to_poscar=True, additional_files=["XDATCAR"]))
                t.append(StructureSamplerTask(copy_calcs=copy_calcs, calc_home=calc_home, n_snapshots=1, priority_spec=priority_spec))
                if len(fw_list) > 0:
                    new_fw = Firework(t, name=name + "structure_sampler", parents=fw_list[len(fw_list)-1], spec=priority_spec)
                else:
                    new_fw = Firework(t, name=name + "structure_sampler", spec=priority_spec)
                fw_list.append(new_fw)
            if snaps or final_run:
                wf = Workflow(fw_list, name=name + "_" + str(temperature) + "_longruns")
                return FWAction(stored_data={'pressure':p, 'density_calculated': True}, additions=wf)
            return FWAction(stored_data={'pressure':p, 'density_calculated': True})
github hackingmaterials / atomate / atomate / vasp / fireworks / core.py View on Github external
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)


class NEBFW(Firework):
    """
    CI-NEB Firework in NEB Workflow.

    Task 1) Read in image structures from spec and generates input sets.
            The group of structures are labeled with neb_label (1, 2...)
    Task 2) Run NEB VASP using Custodian
    Task 3) Update structure to spec
    Task 4) Pass CalcLocs named "neb_{}".format(neb_label)
    """

    def __init__(self, spec, neb_label, from_images=True,
                 user_incar_settings=None,
                 user_kpoints_settings=None, additional_cust_args=None,
                 **kwargs):
        """
        Args:
github materialsproject / fireworks / fireworks / flask_site / app.py View on Github external
from fireworks.flask_site.util import jsonify

app = Flask(__name__)
app.use_reloader = True
app.secret_key = os.environ.get(
    "FWAPP_SECRET_KEY",
    os.urandom(24))

hello = __name__
app.BASE_Q = {}
app.BASE_Q_WF = {}

logger = get_fw_logger('app')

PER_PAGE = 20
STATES = sorted(Firework.STATE_RANKS, key=Firework.STATE_RANKS.get)


def check_auth(username, password):
    """
    This function is called to check if a username /
    password combination is valid.
    """
    AUTH_USER = app.config.get("WEBGUI_USERNAME")
    AUTH_PASSWD = app.config.get("WEBGUI_PASSWORD")

    if (AUTH_USER is None) or (AUTH_PASSWD is None):
        return True
    return username == AUTH_USER and password == AUTH_PASSWD


def authenticate():
github materialsproject / mpmorph / mpmorph / fireworks / core.py View on Github external
from atomate.vasp.fireworks.core import StaticFW
from fireworks import Firework
from mpmorph.firetasks.dbtasks import VaspMDToDb
from mpmorph.firetasks.glue_tasks import PreviousStructureTask, SaveStructureTask
from pymatgen.io.vasp.sets import MPMDSet, MPStaticSet, MPRelaxSet

"""
These fireworks were adapted from atomate.vasp.fireworks.core specifically for this package. 
Slight modifications were made to each.
"""

__maintainer__ = "Eric Sivonxay"
__email__ = "esivonxay@lbl.gov"


class MDFW(Firework):
    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.