def perturb_wf_setup(perovskite, structure_type='111', Nstruct=100, perturbamnt=None, max_strain=0.06, nimages=8, tags=[]): if perturbamnt is None: perturbamnt = perovskite.lattconst * 0.04 print( "Setting up {} different perturbation polarization approaches\nMax strain = {}, " "Perturbation amount = {}".format(Nstruct, max_strain, perturbamnt)) allowed_struct_type = ['111', '211', 's2s21', 's2s22'] if structure_type not in allowed_struct_type: raise ValueError("{} not in {}".format(structure_type, allowed_struct_type)) fws = [] pert_N_structs = [ perovskite.get_struct_from_structure_type(structure_type).as_dict() ] user_incar_settings = {"ADDGRID": True, 'EDIFF': 1e-8, "NELMIN": 6} for nind in range(Nstruct): sclass = PerfectPerovskite(Asite=perovskite.eltA, Bsite=perovskite.eltB, Osite=perovskite.eltC, lattconst=perovskite.lattconst) strain_class = StrainedPerovskite.generate_random_strain( sclass, structure_type=structure_type, max_strain=max_strain, perturb_amnt=perturbamnt) tmp_wf = polarization_wf(strain_class.structure, strain_class.base, submit=False, nimages=nimages, user_incar_settings=user_incar_settings, tags=tags) fws.extend(tmp_wf.fws) pert_N_structs.append(strain_class.structure.as_dict()) print("Submitting Polarization workflow with {} fireworks".format( len(fws))) wf = Workflow(fws) lp = LaunchPad().from_file(lpad_file_path) lp.add_wf(wf)
def born(): fw = Firework( [ Cry(), Eat(), Sleep(), Poop(), ], spec={"name": "BabyJain"} ) launchpad = LaunchPad() launchpad.add_wf(Workflow([fw]))
def polarization_wf(polar_structure, nonpolar_structure, submit=False, nimages=8, user_incar_settings={}, tags=[]): """ :param polar_structure: structure of polar structure :param nonpolar_structure: structure of nonpolar structure :param submit: boolean for submitting :param tags: list of string tags :return: """ if polar_structure.species != nonpolar_structure.species: raise ValueError("WRONG ORDER OF SPECIES: {} vs {}".format( polar_structure.species, nonpolar_structure.species)) vasp_input_set_params = {'user_incar_settings': user_incar_settings} wf = get_wf_ferroelectric( polar_structure, nonpolar_structure, vasp_cmd=">>vasp_cmd<<", db_file='>>db_file<<', vasp_input_set_polar="MPStaticSet", vasp_input_set_nonpolar="MPStaticSet", relax=False, vasp_relax_input_set_polar=vasp_input_set_params, vasp_relax_input_set_nonpolar=vasp_input_set_params, nimages=nimages, hse=False, add_analysis_task=True, tags=tags) print('workflow created with {} fws'.format(len(wf.fws))) if submit: print("\tSubmitting Polarization workflow") lp = LaunchPad().from_file(lpad_file_path) lp.add_wf(wf) else: return wf
def generate_lattconst_wf(list_elt_sets, functional='PBE', vasp_cmd='>>vasp_cmd<<', db_file='>>db_file<<', submit=False, scan_smart_lattice=None): """Generates a workflow which calculates lattice constants through optimization fireworks for a given functional type NOTE: that the SCAN functionality might be reliant on some Custodian features from Danny's Custodian """ if functional in ['PBE', 'LDA']: job_type = 'double_relaxation_run' potcar_type = functional incar_settings = {"ADDGRID": True, 'EDIFF': 1e-8} elif functional in ['SCAN']: job_type = 'metagga_opt_run' potcar_type = 'PBE' #this is the POTCAR that needs to be used for SCAN... incar_settings = {'EDIFF': 1e-8, 'ISIF': 7} if scan_smart_lattice is None: raise ValueError("Need to provide a smarter starting point " "for SCAN lattice constants...") fws = [] for elt_set in list_elt_sets: if functional == 'SCAN': compkey = Composition({ elt_set[0]: 1, elt_set[1]: 1, elt_set[2]: 3 }) lattconst = scan_smart_lattice[compkey] else: lattconst = None pp = PerfectPerovskite(Asite=elt_set[0], Bsite=elt_set[1], Osite=elt_set[2], lattconst=lattconst) s = pp.get_111_struct() vis = MPRelaxSet(s, user_incar_settings=incar_settings, potcar_functional=potcar_type) fw = OptimizeFW(s, name="{} {} structure optimization".format( s.composition.reduced_formula, functional), vasp_input_set=vis, vasp_cmd=vasp_cmd, db_file=db_file, job_type=job_type, auto_npar=">>auto_npar<<") fws.append(fw) wf = Workflow(fws, name='{} latt const workflow'.format(functional)) if submit: print('Submitting workflow with {} fws for {}'.format( len(list_elt_sets), functional)) lpad = LaunchPad().from_file(lpad_file_path) lpad.add_wf(wf) else: print('Workflow created with {} fws for {}'.format( len(list_elt_sets), functional)) return wf
""" This code is described in the Dynamic Workflow tutorial, https://materialsproject.github.io/fireworks/dynamic_wf_tutorial.html """ from fireworks import ScriptTask from fireworks.core.firework import Firework, Workflow from fireworks.core.launchpad import LaunchPad from fireworks.core.rocket_launcher import rapidfire from fw_tutorials.dynamic_wf.printjob_task import PrintJobTask if __name__ == "__main__": # set up the LaunchPad and reset it launchpad = LaunchPad() # launchpad.reset('', require_password=False) # create the Workflow that passes job info fw1 = Firework([ScriptTask.from_str('echo "This is the first FireWork"')], spec={"_pass_job_info": True}, fw_id=1) fw2 = Firework([PrintJobTask()], parents=[fw1], fw_id=2) wf = Workflow([fw1, fw2]) # store workflow and launch it locally launchpad.add_wf(wf) rapidfire(launchpad)
elif args.command == 'detect_fizzled': # TODO: report when fixed print lp.detect_fizzled(args.time, args.fix) elif args.command == 'detect_unreserved': # TODO: report when fixed print lp.detect_unreserved(args.time, args.fix) elif args.command == 'add': # TODO: make this cleaner, e.g. make TAR option explicit # fwf = Workflow.from_FireWork(FireWork.from_file(args.wf_file)) # lp.add_wf(fwf) try: fwf = Workflow.from_FireWork(FireWork.from_file(args.wf_file)) lp.add_wf(fwf) except: try: if '.tar' in args.wf_file: fwf = Workflow.from_tarfile(args.wf_file) else: fwf = Workflow.from_file(args.wf_file) lp.add_wf(fwf) except: print 'Error reading FireWork/Workflow file.' traceback.print_exc() elif args.command == 'get_fw': fw = lp.get_fw_by_id(args.fw_id) fw_dict = fw.to_dict() if args.filename:
elif args.command == 'detect_fizzled': # TODO: report when fixed print lp.detect_fizzled(args.time, args.fix) elif args.command == 'detect_unreserved': # TODO: report when fixed print lp.detect_unreserved(args.time, args.fix) elif args.command == 'add': # TODO: make this cleaner, e.g. make TAR option explicit # fwf = Workflow.from_FireWork(FireWork.from_file(args.wf_file)) # lp.add_wf(fwf) try: fwf = Workflow.from_FireWork(FireWork.from_file(args.wf_file)) lp.add_wf(fwf) except: try: if '.tar' in args.wf_file: fwf = Workflow.from_tarfile(args.wf_file) else: fwf = Workflow.from_file(args.wf_file) lp.add_wf(fwf) except: print 'Error reading FireWork/Workflow file.' traceback.print_exc() elif args.command == 'get_fw': fw = lp.get_fw_by_id(args.fw_id) fw_dict = fw.to_dict() if args.filename:
""" This code is described in the Dynamic Workflow tutorial, https://materialsproject.github.io/fireworks/dynamic_wf_tutorial.html """ from fireworks import ScriptTask from fireworks.core.firework import Firework, Workflow from fireworks.core.launchpad import LaunchPad from fireworks.core.rocket_launcher import rapidfire from fw_tutorials.dynamic_wf.printjob_task import PrintJobTask if __name__ == "__main__": # set up the LaunchPad and reset it launchpad = LaunchPad() # launchpad.reset('', require_password=False) # create the Workflow that passes job info fw1 = Firework([ScriptTask.from_str('echo "This is the first FireWork"')], spec={"_pass_job_info": True}, fw_id=1) fw2 = Firework([PrintJobTask()], parents=[fw1], fw_id=2) wf = Workflow([fw1, fw2]) # store workflow and launch it locally launchpad.add_wf(wf) rapidfire(launchpad)