def results(self): """Attach the output parameters and structure of the last workchain to the outputs.""" if self.ctx.is_converged and self.ctx.iteration <= self.inputs.max_meta_convergence_iterations.value: self.report('workchain completed after {} iterations'.format( self.ctx.iteration)) else: self.report( 'maximum number of meta convergence iterations exceeded') # Get the latest workchain, which is either the workchain_scf if it ran or otherwise the last regular workchain try: workchain = self.ctx.workchain_scf structure = workchain.inp.structure except AttributeError: workchain = self.ctx.workchains[-1] structure = workchain.out.output_structure if 'group' in self.inputs: # Retrieve the final successful PwCalculation through the output_parameters of the PwBaseWorkChain try: calculation = workchain.out.output_parameters.get_inputs( node_type=PwCalculation)[0] except (AttributeError, IndexError): self.report( 'could not retrieve the last run PwCalculation to add to the result group' ) else: group, _ = Group.get_or_create(name=self.inputs.group.value) group.add_nodes(calculation) self.report( "storing the final PwCalculation<{}> in the group '{}'". format(calculation.pk, self.inputs.group.value)) self.out_many(self.exposed_outputs(workchain, PwBaseWorkChain)) self.out('output_structure', structure)
def results(self): """Attach the desired output nodes directly as outputs of the workchain.""" self.report('workchain succesfully completed') self.out('scf_parameters', self.ctx.workchain_scf.out.output_parameters) self.out('band_parameters', self.ctx.workchain_bands.out.output_parameters) self.out('band_structure', self.ctx.workchain_bands.out.output_band) if 'group' in self.inputs: output_band = self.ctx.workchain_bands.out.output_band group, _ = Group.get_or_create(name=self.inputs.group.value) group.add_nodes(output_band) self.report("storing the output_band<{}> in the group '{}'".format( output_band.pk, self.inputs.group.value))