Beispiel #1
0
    def parse(self, **kwargs):
        """
        Parses the datafolder, stores results.
        """
        self.logger.info("Parsing start.")

        # select the folder object
        # Check that the retrieved folder is there
        try:
            output_folder = self.retrieved
        except NotExistent:
            return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER

        # check what is inside the folder
        list_of_files = output_folder.list_object_names()

        # OUTPUT file should exist
        # if not self._calc._OUTPUT_FILE_NAME in list_of_files:
        #    successful = False
        #    self.logger.error("Output file not found")
        #    return successful, ()

        # Get files and do the parsing

        fc_filename = self.node.inputs.force_constants_filename.value
        if fc_filename in list_of_files:
            with output_folder.open(fc_filename) as f:
                fname = f.name
            self.out('force_constants', parse_FORCE_CONSTANTS(fname))

        projected_dos_filename = self.node.inputs.projected_dos_filename.value
        if projected_dos_filename in list_of_files:
            with output_folder.open(projected_dos_filename) as f:
                fname = f.name
            self.out('pdos', parse_projected_dos(fname))

        total_dos_filename = self.node.inputs.projected_dos_filename.value
        if total_dos_filename in list_of_files:
            with output_folder.open(total_dos_filename) as f:
                fname = f.name
            self.out('dos', parse_total_dos(fname))

        tp_filename = self.node.inputs.thermal_properties_filename.value
        if tp_filename in list_of_files:
            with output_folder.open(tp_filename) as f:
                fname = f.name
            self.out('thermal_properties', parse_thermal_properties(fname))

        band_filename = self.node.inputs.band_structure_filename.value
        if band_filename in list_of_files:
            if 'symmetry' in self.node.inputs.settings.attributes:
                sym_dataset = self.node.inputs.settings['symmetry']
                label = "%s (%d)" % (sym_dataset['international'],
                                     sym_dataset['number'])
            else:
                label = None
            with output_folder.open(band_filename) as f:
                fname = f.name
            self.out('band_structure', parse_band_structure(fname,
                                                            label=label))

        self.logger.info("Parsing done.")
        return ExitCode(0)
Beispiel #2
0
    def parse_with_retrieved(self, retrieved):
        """
        Parses the datafolder, stores results.
        """

        # suppose at the start that the job is successful
        successful = True

        # select the folder object
        # Check that the retrieved folder is there
        try:
            out_folder = retrieved[self._calc._get_linkname_retrieved()]
        except KeyError:
            self.logger.error("No retrieved folder found")
            return False, ()

        # check what is inside the folder
        list_of_files = out_folder.get_folder_list()

        # OUTPUT file should exist
        #if not self._calc._OUTPUT_FILE_NAME in list_of_files:
        #    successful = False
        #    self.logger.error("Output file not found")
        #    return successful, ()

        # Get file and do the parsing
        outfile = out_folder.get_abs_path(self._calc._OUTPUT_FILE_NAME)
        force_constants_file = out_folder.get_abs_path(
            self._calc._OUTPUT_FORCE_CONSTANTS)
        qp_file = out_folder.get_abs_path(self._calc._OUTPUT_QUASIPARTICLES)

        try:
            thermal_properties = parse_dynaphopy_output(outfile)
            quasiparticle_data = parse_quasiparticle_data(qp_file)
        except ValueError:
            pass

        try:
            force_constants = parse_FORCE_CONSTANTS(force_constants_file)
        except:
            pass

        # look at warnings
        warnings = []
        with open(out_folder.get_abs_path(self._calc._SCHED_ERROR_FILE)) as f:
            errors = f.read()
        if errors:
            warnings = [errors]

        # ====================== prepare the output node ======================

        # save the outputs
        new_nodes_list = []

        # save phonon data into node
        try:
            new_nodes_list.append(
                ('quasiparticle_data', ParameterData(dict=quasiparticle_data)))
        except KeyError:  # keys not
            pass

        try:
            new_nodes_list.append(
                ('thermal_properties', ParameterData(dict=thermal_properties)))
        except KeyError:  # keys not
            pass

        try:
            new_nodes_list.append(('force_constants', force_constants))
        except KeyError:  # keys not
            pass

        # add the dictionary with warnings
        new_nodes_list.append((self.get_linkname_outparams(),
                               ParameterData(dict={'warnings': warnings})))

        return successful, new_nodes_list
Beispiel #3
0
    def parse_with_retrieved(self, retrieved):
        """
        Parses the datafolder, stores results.
        """

        # suppose at the start that the job is successful
        successful = True

        # select the folder object
        # Check that the retrieved folder is there
        try:
            out_folder = retrieved[self._calc._get_linkname_retrieved()]
        except KeyError:
            self.logger.error("No retrieved folder found")
            return False, ()

        # check what is inside the folder
        list_of_files = out_folder.get_folder_list()

        # OUTPUT file should exist
        # if not self._calc._OUTPUT_FILE_NAME in list_of_files:
        #    successful = False
        #    self.logger.error("Output file not found")
        #    return successful, ()

        # Get files and do the parsing

        # save the outputs
        new_nodes_list = []

        if self._calc._INOUT_FORCE_CONSTANTS in list_of_files:
            outfile = out_folder.get_abs_path(
                self._calc._INOUT_FORCE_CONSTANTS)
            object_force_constants = parse_FORCE_CONSTANTS(outfile)
            new_nodes_list.append(('force_constants', object_force_constants))

        if self._calc._OUTPUT_DOS in list_of_files:
            outfile = out_folder.get_abs_path(self._calc._OUTPUT_DOS)
            dos_object = parse_partial_DOS(outfile, self._calc.inp.structure,
                                           self._calc.inp.parameters)
            new_nodes_list.append(('dos', dos_object))

        if self._calc._OUTPUT_THERMAL_PROPERTIES in list_of_files:
            outfile = out_folder.get_abs_path(
                self._calc._OUTPUT_THERMAL_PROPERTIES)
            tp_object = parse_thermal_properties(outfile)
            new_nodes_list.append(('thermal_properties', tp_object))

        if self._calc._OUTPUT_BAND_STRUCTURE in list_of_files:
            outfile = out_folder.get_abs_path(
                self._calc._OUTPUT_BAND_STRUCTURE)
            bs_object = parse_band_structure(outfile, self._calc.inp.bands)
            new_nodes_list.append(('band_structure', bs_object))

        # look at warnings
        with open(out_folder.get_abs_path(self._calc._SCHED_ERROR_FILE)) as f:
            errors = f.readlines()
        if errors:
            for error in errors:
                self.logger.warning(error)
                successful = False

        return successful, new_nodes_list