def snl_to_wf_elastic(snl, parameters): # parameters["user_vasp_settings"] specifies user defined incar/kpoints parameters fws = [] connections = defaultdict(list) parameters = parameters if parameters else {} snl_priority = parameters.get('priority', 1) priority = snl_priority * 2 # once we start a job, keep going! f = Composition(snl.structure.composition.reduced_formula).alphabetical_formula # add the SNL to the SNL DB and figure out duplicate group tasks = [AddSNLTask()] spec = {'task_type': 'Add to SNL database', 'snl': snl.as_dict(), '_queueadapter': QA_DB, '_priority': snl_priority} if 'snlgroup_id' in parameters and isinstance(snl, MPStructureNL): spec['force_mpsnl'] = snl.as_dict() spec['force_snlgroup_id'] = parameters['snlgroup_id'] del spec['snl'] fws.append(Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=0)) connections[0] = [1] parameters["exact_structure"] = True # run GGA structure optimization for force convergence spec = snl_to_wf._snl_to_spec(snl, parameters=parameters) user_vasp_settings = parameters.get("user_vasp_settings") spec = update_spec_force_convergence(spec, user_vasp_settings) spec['run_tags'].append("origin") spec['_priority'] = priority spec['_queueadapter'] = QA_VASP del spec['_dupefinder'] spec['task_type'] = "Vasp force convergence optimize structure (2x)" tasks = [VaspWriterTask(), get_custodian_task(spec)] fws.append(Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=1)) # insert into DB - GGA structure optimization spec = {'task_type': 'VASP db insertion', '_priority': priority, '_allow_fizzled_parents': True, '_queueadapter': QA_DB, 'clean_task_doc':True, 'elastic_constant':"force_convergence"} fws.append(Firework([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=2)) connections[1] = [2] spec = {'task_type': 'Setup Deformed Struct Task', '_priority': priority, '_queueadapter': QA_CONTROL} fws.append(Firework([SetupDeformedStructTask()], spec, name=get_slug(f + '--' + spec['task_type']),fw_id=3)) connections[2] = [3] wf_meta = get_meta_from_structure(snl.structure) wf_meta['run_version'] = 'May 2013 (1)' if '_materialsproject' in snl.data and 'submission_id' in snl.data['_materialsproject']: wf_meta['submission_id'] = snl.data['_materialsproject']['submission_id'] return Workflow(fws, connections, name=Composition( snl.structure.composition.reduced_formula).alphabetical_formula, metadata=wf_meta)
def run_task(self, fw_spec): # Read structure from previous relaxation relaxed_struct = fw_spec['output']['crystal'] # Generate deformed structures d_struct_set = DeformedStructureSet(relaxed_struct, ns=0.06) wf=[] for i, d_struct in enumerate(d_struct_set.def_structs): fws=[] connections={} f = Composition(d_struct.formula).alphabetical_formula snl = StructureNL(d_struct, 'Joseph Montoya <*****@*****.**>', projects=["Elasticity"]) tasks = [AddSNLTask()] snl_priority = fw_spec.get('priority', 1) spec = {'task_type': 'Add Deformed Struct to SNL database', 'snl': snl.as_dict(), '_queueadapter': QA_DB, '_priority': snl_priority} if 'snlgroup_id' in fw_spec and isinstance(snl, MPStructureNL): spec['force_mpsnl'] = snl.as_dict() spec['force_snlgroup_id'] = fw_spec['snlgroup_id'] del spec['snl'] fws.append(Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=-1000+i*10)) connections[-1000+i*10] = [-999+i*10] spec = snl_to_wf._snl_to_spec(snl, parameters={'exact_structure':True}) spec = update_spec_force_convergence(spec) spec['deformation_matrix'] = d_struct_set.deformations[i].tolist() spec['original_task_id'] = fw_spec["task_id"] spec['_priority'] = fw_spec['_priority']*2 #Turn off dupefinder for deformed structure del spec['_dupefinder'] spec['task_type'] = "Optimize deformed structure" fws.append(Firework([VaspWriterTask(), SetupElastConstTask(), get_custodian_task(spec)], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=-999+i*10)) priority = fw_spec['_priority']*3 spec = {'task_type': 'VASP db insertion', '_priority': priority, '_allow_fizzled_parents': True, '_queueadapter': QA_DB, 'elastic_constant':"deformed_structure", 'clean_task_doc':True, 'deformation_matrix':d_struct_set.deformations[i].tolist(), 'original_task_id':fw_spec["task_id"]} fws.append(Firework([VaspToDBTask(), AddElasticDataToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=-998+i*10)) connections[-999+i*10] = [-998+i*10] wf.append(Workflow(fws, connections)) return FWAction(additions=wf)
def snl_to_wf(snl, parameters=None): fws = [] connections = defaultdict(list) parameters = parameters if parameters else {} snl_priority = parameters.get('priority', 1) priority = snl_priority * 2 # once we start a job, keep going! f = Composition( snl.structure.composition.reduced_formula).alphabetical_formula snl_spec = {} if 'snlgroup_id' in parameters: if 'mpsnl' in parameters: snl_spec['mpsnl'] = parameters['mpsnl'] elif isinstance(snl, MPStructureNL): snl_spec['mpsnl'] = snl.as_dict() else: raise ValueError("improper use of force SNL") snl_spec['snlgroup_id'] = parameters['snlgroup_id'] else: # add the SNL to the SNL DB and figure out duplicate group tasks = [AddSNLTask()] spec = { 'task_type': 'Add to SNL database', 'snl': snl.as_dict(), '_queueadapter': QA_DB, '_priority': snl_priority } fws.append( Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=0)) connections[0] = [1] trackers = [ Tracker('FW_job.out'), Tracker('FW_job.error'), Tracker('vasp.out'), Tracker('OUTCAR'), Tracker('OSZICAR'), Tracker('OUTCAR.relax1'), Tracker('OUTCAR.relax2') ] trackers_db = [Tracker('FW_job.out'), Tracker('FW_job.error')] # run GGA structure optimization spec = _snl_to_spec(snl, enforce_gga=True, parameters=parameters) spec.update(snl_spec) spec['_priority'] = priority spec['_queueadapter'] = QA_VASP spec['_trackers'] = trackers tasks = [VaspWriterTask(), get_custodian_task(spec)] fws.append( Firework(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=1)) # insert into DB - GGA structure optimization spec = { 'task_type': 'VASP db insertion', '_priority': priority * 2, '_allow_fizzled_parents': True, '_queueadapter': QA_DB, "_dupefinder": DupeFinderDB().to_dict(), '_trackers': trackers_db } fws.append( Firework([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=2)) connections[1] = [2] # determine if GGA+U FW is needed incar = MPVaspInputSet().get_incar(snl.structure).as_dict() ggau_compound = ('LDAU' in incar and incar['LDAU']) if not parameters.get('skip_bandstructure', False) and ( not ggau_compound or parameters.get('force_gga_bandstructure', False)): spec = { 'task_type': 'Controller: add Electronic Structure v2', '_priority': priority, '_queueadapter': QA_CONTROL } fws.append( Firework([AddEStructureTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=3)) connections[2] = [3] if ggau_compound: spec = _snl_to_spec(snl, enforce_gga=False, parameters=parameters) del spec[ 'vasp'] # we are stealing all VASP params and such from previous run spec['_priority'] = priority spec['_queueadapter'] = QA_VASP spec['_trackers'] = trackers fws.append( Firework( [VaspCopyTask(), SetupGGAUTask(), get_custodian_task(spec)], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=10)) connections[2].append(10) spec = { 'task_type': 'VASP db insertion', '_queueadapter': QA_DB, '_allow_fizzled_parents': True, '_priority': priority, "_dupefinder": DupeFinderDB().to_dict(), '_trackers': trackers_db } fws.append( Firework([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=11)) connections[10] = [11] if not parameters.get('skip_bandstructure', False): spec = { 'task_type': 'Controller: add Electronic Structure v2', '_priority': priority, '_queueadapter': QA_CONTROL } fws.append( Firework([AddEStructureTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=12)) connections[11] = [12] wf_meta = get_meta_from_structure(snl.structure) wf_meta['run_version'] = 'May 2013 (1)' if '_materialsproject' in snl.data and 'submission_id' in snl.data[ '_materialsproject']: wf_meta['submission_id'] = snl.data['_materialsproject'][ 'submission_id'] return Workflow( fws, connections, name=Composition( snl.structure.composition.reduced_formula).alphabetical_formula, metadata=wf_meta)
def snl_to_wf(snl, parameters=None): fws = [] connections = {} parameters = parameters if parameters else {} snl_priority = parameters.get('priority', 1) priority = snl_priority * 2 # once we start a job, keep going! f = Composition.from_formula( snl.structure.composition.reduced_formula).alphabetical_formula # add the SNL to the SNL DB and figure out duplicate group tasks = [AddSNLTask()] spec = { 'task_type': 'Add to SNL database', 'snl': snl.to_dict, '_queueadapter': QA_DB, '_priority': snl_priority } if 'snlgroup_id' in parameters and isinstance(snl, MPStructureNL): spec['force_mpsnl'] = snl.to_dict spec['force_snlgroup_id'] = parameters['snlgroup_id'] del spec['snl'] fws.append( FireWork(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=0)) connections[0] = [1] # run GGA structure optimization spec = _snl_to_spec(snl, enforce_gga=True) spec['_priority'] = priority spec['_queueadapter'] = QA_VASP tasks = [VaspWriterTask(), get_custodian_task(spec)] fws.append( FireWork(tasks, spec, name=get_slug(f + '--' + spec['task_type']), fw_id=1)) # insert into DB - GGA structure optimization spec = { 'task_type': 'VASP db insertion', '_priority': priority, '_allow_fizzled_parents': True, '_queueadapter': QA_DB } fws.append( FireWork([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=2)) connections[1] = [2] if not parameters.get('skip_bandstructure', False): spec = { 'task_type': 'Controller: add Electronic Structure v2', '_priority': priority, '_queueadapter': QA_CONTROL } fws.append( FireWork([AddEStructureTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=3)) connections[2] = [3] # determine if GGA+U FW is needed incar = MPVaspInputSet().get_incar(snl.structure).to_dict if 'LDAU' in incar and incar['LDAU']: spec = _snl_to_spec(snl, enforce_gga=False) del spec[ 'vasp'] # we are stealing all VASP params and such from previous run spec['_priority'] = priority spec['_queueadapter'] = QA_VASP fws.append( FireWork( [VaspCopyTask(), SetupGGAUTask(), get_custodian_task(spec)], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=10)) connections[2].append(10) spec = { 'task_type': 'VASP db insertion', '_queueadapter': QA_DB, '_allow_fizzled_parents': True, '_priority': priority } fws.append( FireWork([VaspToDBTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=11)) connections[10] = [11] if not parameters.get('skip_bandstructure', False): spec = { 'task_type': 'Controller: add Electronic Structure v2', '_priority': priority, '_queueadapter': QA_CONTROL } fws.append( FireWork([AddEStructureTask()], spec, name=get_slug(f + '--' + spec['task_type']), fw_id=12)) connections[11] = [12] wf_meta = get_meta_from_structure(snl.structure) wf_meta['run_version'] = 'May 2013 (1)' if '_materialsproject' in snl.data and 'submission_id' in snl.data[ '_materialsproject']: wf_meta['submission_id'] = snl.data['_materialsproject'][ 'submission_id'] return Workflow( fws, connections, name=Composition.from_formula( snl.structure.composition.reduced_formula).alphabetical_formula, metadata=wf_meta)