def run_dos_full(self): """Run the PwBaseWorkChain in bands mode along the path of high-symmetry determined by seekpath.""" inputs = AttributeDict(self.exposed_inputs(DosCalc, namespace='dos_full')) inputs.metadata.call_link_label = 'dos_full' inputs.parent_folder = self.ctx.current_folder inputs = prepare_process_inputs(DosCalc, inputs) running = self.submit(DosCalc, **inputs) self.report('launching DosCalculation<{}> in {} mode for the FULL - CROP grid'.format(running.pk, 'dos')) return ToContext(workchain_dos_full=running)
def run_bands(self): """Run the `PwBandsWorkChain` to compute the band structure.""" def get_common_inputs(): """Return the dictionary of inputs to be used as the basis for each `PwBaseWorkChain`.""" protocol, protocol_modifiers = self._get_protocol() checked_pseudos = protocol.check_pseudos( modifier_name=protocol_modifiers.get('pseudo', None), pseudo_data=protocol_modifiers.get('pseudo_data', None)) known_pseudos = checked_pseudos['found'] inputs = AttributeDict({ 'pw': { 'code': self.inputs.code, 'pseudos': get_pseudos_from_dict(self.inputs.structure, known_pseudos), 'parameters': self.ctx.parameters, 'metadata': {}, } }) if 'options' in self.inputs: inputs.pw.metadata.options = self.inputs.options.get_dict() else: inputs.pw.metadata.options = get_default_options(with_mpi=True) return inputs inputs = AttributeDict({ 'structure': self.inputs.structure, 'relax': { 'base': get_common_inputs(), 'relaxation_scheme': orm.Str('vc-relax'), 'meta_convergence': orm.Bool(self.ctx.protocol['meta_convergence']), 'volume_convergence': orm.Float(self.ctx.protocol['volume_convergence']), }, 'scf': get_common_inputs(), 'bands': get_common_inputs(), }) inputs.relax.base.kpoints_distance = orm.Float(self.ctx.protocol['kpoints_mesh_density']) inputs.scf.kpoints_distance = orm.Float(self.ctx.protocol['kpoints_mesh_density']) inputs.bands.kpoints_distance = orm.Float(self.ctx.protocol['kpoints_distance_for_bands']) num_bands_factor = self.ctx.protocol.get('num_bands_factor', None) if num_bands_factor is not None: inputs.nbands_factor = orm.Float(num_bands_factor) running = self.submit(PwBandsWorkChain, **inputs) self.report('launching PwBandsWorkChain<{}>'.format(running.pk)) return ToContext(workchain_bands=running)
def scf_next_workchain(self): """Initialize and Run the next workchain""" self.ctx.iteration += 1 parameters = self.update_builder_parameters() self.ctx.inputs.parameters = orm.Dict(dict=parameters) self.ctx.inputs.parameters.store() running = self.submit(self.ctx.inputs) #running = self.submit(self.ctx.restart_builder) self.report( 'running PwBaseWorkChain<{}> calculation for equiv. {} with position {}' .format(running.pk, self.ctx.label, self.ctx.mupos)) #return self.to_context(workchain_equiv=append_(running)) return ToContext(workchain_equiv=append_(running))
def start_children(self): child_1 = self.submit(ChildExposeWorkChain, a=self.exposed_inputs(ChildExposeWorkChain)['a'], **self.exposed_inputs(ChildExposeWorkChain, namespace='sub_1', agglomerate=False)) child_2 = self.submit( ChildExposeWorkChain, **self.exposed_inputs( ChildExposeWorkChain, namespace='sub_2.sub_3', )) return ToContext(child_1=child_1, child_2=child_2)
def run_cp2kddec(self): """Pass the Cp2kMultistageWorkChain outputs as inputs for Cp2kDdecWorkChain: cp2k_base (metadata), cp2k_params, structure and WFN. """ cp2k_ddec_inputs = AttributeDict(self.exposed_inputs(Cp2kDdecWorkChain)) cp2k_ddec_inputs['cp2k_base'] = self.exposed_inputs(Cp2kMultistageWorkChain)['cp2k_base'] cp2k_ddec_inputs['cp2k_base']['cp2k']['parameters'] = self.ctx.ms_wc.outputs.last_input_parameters cp2k_ddec_inputs['cp2k_base']['cp2k']['structure'] = self.ctx.ms_wc.outputs.output_structure cp2k_ddec_inputs['cp2k_base']['cp2k']['parent_calc_folder'] = self.ctx.ms_wc.outputs.remote_folder cp2k_ddec_inputs['metadata']['call_link_label'] = 'call_cp2kddec' running = self.submit(Cp2kDdecWorkChain, **cp2k_ddec_inputs) return ToContext(cp2k_ddec_wc=running)
def run_scf_diag(self): self.report("Running CP2K diagonalization SCF") inputs = self.build_cp2k_inputs(self.inputs.structure, self.inputs.cell, self.inputs.cp2k_code, self.inputs.mgrid_cutoff, self.inputs.wfn_file_path.value, self.inputs.elpa_switch) self.report("inputs: "+str(inputs)) future = self.submit(Cp2kCalculation, **inputs) return ToContext(scf_diag=future)
def run_zeopp_after(self): """Run Zeo++ for the starting structure""" #Merging all inputs zeopp_inp = AttributeDict( self.exposed_inputs(ZeoppCalculation, 'zeopp')) zeopp_inp['parameters'] = self.inputs.zeopp.parameters zeopp_inp['structure'] = self.ctx.cp2k_ddec_wc.outputs.structure_ddec zeopp_inp['metadata']['label'] = "zeopp_after_opt" zeopp_inp['metadata']['call_link_label'] = "call_zeopp_after_opt" running_zeopp = self.submit(ZeoppCalculation, **zeopp_inp) self.report("Running Zeo++ calculation <{}>".format(running_zeopp.pk)) return ToContext(zeopp_after=running_zeopp)
def run_scf(self): """Run the `scf` calculation.""" inputs = AttributeDict( self.exposed_inputs(PwBaseWorkChain, namespace='scf')) inputs.pw.structure = self.inputs.structure inputs.pw.code = self.inputs.pw_code running = self.submit(PwBaseWorkChain, **inputs) self.report('launching PwBaseWorkChain<{}> for starting scf'.format( running.pk)) return ToContext(workchain_scf=running)
def run_init(self): """ Run an initialization HpCalculatio that will only perform the symmetry analysis and determine which kinds are to be perturbed. This information is parsed and can be used to determine exactly how many HpBaseWorkChains have to be launched """ inputs = AttributeDict(self.exposed_inputs(HpBaseWorkChain)) inputs.only_initialization = Bool(True) running = self.submit(HpBaseWorkChain, **inputs) self.report('launching initialization HpBaseWorkChain<{}>'.format(running.pk)) return ToContext(initialization=running)
def run_pw_scf(self): """Run the SCF with pw.x.""" # A fixed value, for testing ecutwfc = 30. self.ctx.scf_parameters = { 'CONTROL': { 'calculation': 'scf', }, 'SYSTEM': { 'ecutwfc': ecutwfc, 'ecutrho': ecutwfc * 8., } } inputs = { 'code': self.inputs.pw_code, 'structure': self.inputs.structure, 'pseudos': get_pseudos_from_structure( self.inputs.structure, self.inputs.pseudo_family.value ), 'parameters': orm.Dict(dict=self.ctx.scf_parameters), 'kpoints': self.inputs.kpoints_scf, 'metadata': { 'options': { # int is used to convert from AiiDA nodes to python ints 'resources': { 'num_machines': int(self.inputs.num_machines) }, 'max_wallclock_seconds': int(self.inputs.max_wallclock_seconds), 'withmpi': True, } } } running = self.submit( CalculationFactory('quantumespresso.pw'), **inputs ) self.report( 'launching PwCalculation<{}> (SCF step)'.format(running.pk) ) return ToContext(pw_scf=running)
def run_relax(self): """Run the PwRelaxWorkChain to run a relax PwCalculation.""" inputs = AttributeDict( self.exposed_inputs(PwRelaxWorkChain, namespace='relax')) inputs.structure = self.ctx.current_structure inputs.base.pw.pseudos = self.inputs.pseudos inputs.base.pw.code = self.inputs.code inputs.clean_workdir = self.inputs.clean_workdir running = self.submit(PwRelaxWorkChain, **inputs) self.report('launching PwRelaxWorkChain<{}>'.format(running.pk)) return ToContext(workchain_relax=running)
def do_precalc(self): self.report('doing the preliminary calculation') calc = {} self.ctx.precalc_inputs = self.exposed_inputs(YamboWorkflow, 'precalc') set_parent(self.ctx.precalc_inputs, self.ctx.calc_inputs.parent_folder) calc['PRE_CALC'] = self.submit( YamboWorkflow, **self.ctx.precalc_inputs) #################run self.report('Submitted preliminary YamboWorkflow, pk = {}'.format( calc['PRE_CALC'].pk)) self.ctx.PRE = calc['PRE_CALC'] self.report('setting label "precalc _on YC"') load_node(calc['PRE_CALC'].pk).label = 'precalc _on YC' return ToContext(calc)
def run_fleur(self): """ run a FLEUR calculation """ fleurin = self.ctx.fleurinp1 remote = self.inputs.remote_data code = self.inputs.fleur options = self.ctx.options inputs = get_inputs_fleur(code, remote, fleurin, options, add_comp_para=self.ctx.wf_dict['add_comp_para']) future = submit(FleurCalculation, **inputs) return ToContext(last_calc=future) # calcs.append(future),
def run_scf(self): """Run the PwBaseWorkChain in scf mode on the primitive cell of (optionally relaxed) input structure.""" inputs = AttributeDict(self.exposed_inputs(PwBaseWorkChain, namespace='scf')) inputs.metadata.call_link_label = 'scf' inputs.pw.structure = self.ctx.current_structure inputs.pw.parameters = inputs.pw.parameters.get_dict() inputs.pw.parameters.setdefault('CONTROL', {})['calculation'] = 'scf' inputs = prepare_process_inputs(PwBaseWorkChain, inputs) running = self.submit(PwBaseWorkChain, **inputs) self.report(f'launching PwBaseWorkChain<{running.pk}> in scf mode') return ToContext(workchain_scf=running)
def run_bands(self): """Run the band calculation.""" self.ctx.iteration += 1 inputs = self.ctx.inputs inputs.kpoints = self.ctx.current_kpoints inputs = prepare_process_inputs(PwBaseWorkChain, inputs) running = self.submit(PwBaseWorkChain, **inputs) self.report( 'launching PwBaseWorkChain<{}> in {} mode, iteration {}'.format( running.pk, 'bands', self.ctx.iteration)) return ToContext(workchain_bands=append_(running))
def run_scf_diag(self): self.report("Running CP2K diagonalization SCF") n_lumo = int(self.inputs.stm_params.get_dict()['--n_lumo']) inputs = self.build_cp2k_inputs(self.inputs.structure, self.inputs.cp2k_code, self.inputs.dft_params.get_dict(), self.inputs.wfn_file_path.value, n_lumo) self.report("inputs: " + str(inputs)) future = self.submit(Cp2kCalculation, **inputs) return ToContext(scf_diag=future)
def run_dosmain(self): """Run the DosmainCalculation subprocess.""" inputs = AttributeDict( self.exposed_inputs(DosmainCalculation, namespace='dosmain')) openmx_calculation = self.ctx.openmx_calculation inputs.openmx_output_folder = openmx_calculation.outputs.remote_folder inputs.openmx_input_structure = openmx_calculation.inputs.structure inputs.openmx_orbital_configurations = openmx_calculation.inputs.orbital_configurations inputs.metadata.call_link_label = 'dosmain' running = self.submit(DosmainCalculation, **inputs) self.report(f'launching DosmainCalculation<{running.pk}>') return ToContext(dosmain_calculation=running)
def run_nscf_crop(self): """Run the PwBaseWorkChain in nscf mode along the path of high-symmetry determined by seekpath.""" inputs = AttributeDict(self.exposed_inputs(PwBaseWorkChain, namespace='nscf_crop')) inputs.metadata.call_link_label = 'nscf_crop' # inputs.pw.metadata.options.max_wallclock_seconds *= 4 # inputs.kpoints_distance = self.inputs.kpoints_distance inputs.pw.structure = self.ctx.current_structure inputs.pw.parent_folder = self.ctx.current_folder inputs.pw.parameters = inputs.pw.parameters.get_dict() inputs.pw.parameters.setdefault('CONTROL', {}) inputs.pw.parameters.setdefault('SYSTEM', {}) inputs.pw.parameters.setdefault('ELECTRONS', {}) # The following flags always have to be set in the parameters, regardless of what caller specified in the inputs inputs.pw.parameters['CONTROL']['calculation'] = 'nscf' inputs.pop('kpoints_distance', None) inputs.kpoints = self.ctx.kpoint_crop # Only set the following parameters if not directly explicitly defined in the inputs # inputs.pw.parameters['ELECTRONS'].setdefault('diagonalization', 'cg') # inputs.pw.parameters['ELECTRONS'].setdefault('diago_full_acc', True) # If `nbands_factor` is defined in the inputs we set the `nbnd` parameter if 'nbands_factor_crop' in self.inputs: factor = self.inputs.nbands_factor_crop.value parameters = self.ctx.workchain_scf.outputs.output_parameters.get_dict() if int(parameters['number_of_spin_components']) > 1: nspin_factor = 2 else: nspin_factor = 1 nbands = int(parameters['number_of_bands']) nelectron = int(parameters['number_of_electrons']) nbnd = max( int(0.5 * nelectron * nspin_factor * factor), int(0.5 * nelectron * nspin_factor) + 4 * nspin_factor, nbands) inputs.pw.parameters['SYSTEM']['nbnd'] = nbnd # Otherwise set the current number of bands, unless explicitly set in the inputs else: inputs.pw.parameters['SYSTEM'].setdefault('nbnd', self.ctx.current_number_of_bands) inputs = prepare_process_inputs(PwBaseWorkChain, inputs) running = self.submit(PwBaseWorkChain, **inputs) self.report('launching PwBaseWorkChain<{}> in {} mode for CROP grid'.format(running.pk, 'nscf')) return ToContext(workchain_nscf_crop=running)
def run_calc(self): """ Run the QE calculation. """ self.report("Submitting pw.x bands calculation.") pw_inputs = self.exposed_inputs(PwCalculation, namespace='pw') pw_inputs['parameters'] = merge_nested_dict( orm.Dict(dict={'CONTROL': { 'calculation': 'bands' }}), pw_inputs.get('parameters', orm.Dict()) ) return ToContext(pw_calc=self.submit(PwCalculation, **pw_inputs))
def optimize(self): print('start optimize') future = submit( OptimizeStructure, structure=self.inputs.structure, es_settings=self.inputs.es_settings, pressure=self.inputs.pressure, ) if __testing__: self.ctx._content['optimize'] = load_node(9357) return print('optimize workchain: {}'.format(future.pid)) return ToContext(optimized=future)
def fp_run(self): """ Runs the first-principles calculation workflow. """ self.report("Starting DFT workflows.") return ToContext( fp_run=self.submit( load_object(self.inputs.fp_run_workflow), **ChainMap( self.inputs.fp_run, self. exposed_inputs(FirstPrinciplesRunBase, namespace='fp_run'), ) ) )
def run_scf(self): """ Run the SCF calculation step. """ self.report('Launching SCF calculation.') inputs = self.exposed_inputs(PwCalculation, namespace='scf') inputs['parameters'] = merge_nested_dict( orm.Dict(dict={'CONTROL': { 'calculation': 'scf' }}), inputs.get('parameters', orm.Dict())) return ToContext(scf=self.submit(PwCalculation, structure=self.inputs.structure, kpoints=self.inputs.kpoints_mesh, **inputs))
def run_final_scf(self): """Run the `PwBaseWorkChain` to run a final scf `PwCalculation` for the relaxed structure.""" inputs = self.ctx.final_scf_inputs inputs.pw.structure = self.ctx.current_structure if self.ctx.current_number_of_bands is not None: inputs.pw.parameters.setdefault( 'SYSTEM', {})['nbnd'] = self.ctx.current_number_of_bands inputs = prepare_process_inputs(PwBaseWorkChain, inputs) running = self.submit(PwBaseWorkChain, **inputs) self.report(f'launching PwBaseWorkChain<{running.pk}> for final scf') return ToContext(workchain_scf=running)
def run_scf_diag(self): self.report("Running CP2K diagonalization SCF") emax = float(self.inputs.stm_params.get_dict()['--energy_range'][1]) self.ctx.n_atoms = len(self.inputs.structure.sites) inputs = self.build_cp2k_inputs(self.inputs.structure, self.inputs.cp2k_code, self.inputs.dft_params.get_dict(), self.inputs.wfn_file_path.value, emax) self.report("inputs: "+str(inputs)) future = self.submit(Cp2kCalculation, **inputs) return ToContext(scf_diag=future)
def formchk_step(self): self.report("Running FormChk") builder = FormchkCalculation.get_builder() builder.parent_calc_folder = self.inputs.gaussian_calc_folder builder.code = self.inputs.formchk_code builder.metadata.options.resources = self._set_resources() builder.metadata.options.max_wallclock_seconds = 1 * 20 * 60 future = self.submit(builder) return ToContext(formchk_node=future)
def evaluate_bands(self): """ Add the tight-binding model to the outputs and run the evaluation workflow. """ self.report("Adding tight-binding model to output.") tb_model = self.ctx.tbextraction_calc.outputs.tb_model self.out('tb_model', tb_model) self.report("Running model evaluation.") return ToContext(model_evaluation_wf=self.submit( load_object(self.inputs.model_evaluation_workflow), tb_model=tb_model, **ChainMap( self.inputs.model_evaluation, self.exposed_inputs(ModelEvaluationBase), )))
def run_optimize_dft_tb(self): """ Run the tight-binding optimization for each strained structure. """ apply_strains_outputs = get_outputs_dict(self.ctx.apply_strains) tocontext_kwargs = {} for strain in self.inputs.strain_strengths: key = 'tbextraction' + get_suffix(strain) structure_key = get_structure_key(strain) symmetries_key = get_symmetries_key(strain) tocontext_kwargs[key] = self.submit( OptimizeFirstPrinciplesTightBinding, structure=apply_strains_outputs[structure_key], symmetries=apply_strains_outputs[symmetries_key], **self.exposed_inputs(OptimizeFirstPrinciplesTightBinding)) return ToContext(**tocontext_kwargs)
def run_block_zeopp(self): # pylint: disable=protected-access """This is the main function that will perform a zeo++ block pocket calculation.""" # pylint: disable=protected-access inputs = { 'code': self.inputs.zeopp_code, 'structure': self.inputs.structure, 'parameters': get_zeopp_block_parameters(self.inputs.probe_radius), '_options': self.inputs._options, '_label': "run_block_zeopp", } # Create the calculation process and launch it future = self.submit(ZeoppCalculation.process(), **inputs) self.report("pk: {} | Running zeo++ block volume calculation".format( future.pid)) return ToContext(zeopp_block=future)
def submit_calculation(self): """ Run the Vasp2w90 calculation. """ self.report("Submitting VASP2W90 calculation.") return ToContext(vasp_calc=self.submit( CalculationFactory('vasp.vasp2w90'), structure=self.inputs.structure, potential={(kind, ): pot for kind, pot in self.inputs.potentials.items()}, kpoints=self.inputs.kpoints_mesh, parameters=self.inputs.parameters, code=self.inputs.code, wannier_parameters=self.inputs.get('wannier_parameters', None), wannier_projections=self.inputs.get('wannier_projections', None), **self.inputs.get('calculation_kwargs', {})))
def run_scf(self): """Run an SCF calculation, to generate the wavefunction.""" inputs = AttributeDict(self.exposed_inputs(PwBaseWorkChain, 'scf')) inputs.pw.structure = self.inputs.structure inputs.metadata.call_link_label = 'scf' inputs = prepare_process_inputs(PwBaseWorkChain, inputs) if self.ctx.dry_run: return inputs future = self.submit(PwBaseWorkChain, **inputs) self.report(f'launching SCF PwBaseWorkChain<{future.pk}>') return ToContext(workchain_scf=future)