Ejemplo n.º 1
0
    def objective(self):
        """
        Generate objective function value from this dataset

        Returns
        -------
        obj_val : float
            A value for the objective function
        """

        phase_list = self._thermo_wrapper()

        # Reformat array of results
        phase_list, len_list = ff.reformat_output(phase_list)
        phase_list = np.transpose(np.array(phase_list))

        # objective function
        obj_value = ff.obj_function_form(phase_list,
                                         self.thermodict["rhol"],
                                         weights=self.weights["rhol"],
                                         **self.obj_opts)

        logger.info("Obj. breakdown for {}: rhol {}".format(
            self.name, obj_value))

        if np.isnan(obj_value) or obj_value == 0.0:
            obj_value = np.inf

        return obj_value
Ejemplo n.º 2
0
    def objective(self):
        """
        Generate objective function value from this dataset

        Returns
        -------
        obj_val : float
            A value for the objective function
        """

        # objective function
        phase_list = self._thermo_wrapper()
        phase_list, len_cluster = ff.reformat_output(phase_list)
        phase_list = np.transpose(np.array(phase_list))

        obj_value = np.zeros(2)

        if "Plist" in self.thermodict:
            obj_value[0] = ff.obj_function_form(phase_list[0],
                                                self.thermodict["Plist"],
                                                weights=self.weights["Plist"],
                                                **self.obj_opts)

        if self.thermodict["calculation_type"] == "bubble_pressure":
            if "yilist" in self.thermodict:
                yi = np.transpose(self.thermodict["yilist"])
                obj_value[1] = 0
                for i in range(len(yi)):
                    obj_value[1] += ff.obj_function_form(
                        phase_list[1 + i],
                        yi[i],
                        weights=self.weights["yilist"],
                        **self.obj_opts)
        elif self.thermodict["calculation_type"] == "dew_pressure":
            if "xilist" in self.thermodict:
                xi = np.transpose(self.thermodict["xilist"])
                obj_value[1] = 0
                for i in range(len(xi)):
                    obj_value[1] += ff.obj_function_form(
                        phase_list[1 + i],
                        xi[i],
                        weights=self.weights["xilist"],
                        **self.obj_opts)

        logger.info("Obj. breakdown for {}: P {}, zi {}".format(
            self.name, obj_value[0], obj_value[1]))

        if all([(np.isnan(x) or x == 0.0) for x in obj_value]):
            obj_total = np.inf
        else:
            obj_total = np.nansum(obj_value)

        return obj_total
Ejemplo n.º 3
0
    def objective(self):

        """
        Generate objective function value from this dataset

        Returns
        -------
        obj_val : float
            A value for the objective function
        """

        phase_list = self._thermo_wrapper()

        ## Reformat array of results
        phase_list, len_list = ff.reformat_output(phase_list)
        phase_list = np.transpose(np.array(phase_list))

        # objective function
        obj_value = np.zeros(2)
        if "delta" in self.thermodict:
            obj_value[0] = ff.obj_function_form(
                phase_list[0],
                self.thermodict["delta"],
                weights=self.weights["delta"],
                **self.obj_opts
            )
        if "rhol" in self.thermodict:
            obj_value[1] = ff.obj_function_form(
                phase_list[1],
                self.thermodict["rhol"],
                weights=self.weights["rhol"],
                **self.obj_opts
            )

        logger.info(
            "Obj. breakdown for {}: delta {}, rhol {}".format(
                self.name, obj_value[0], obj_value[1]
            )
        )

        if all([(np.isnan(x) or x == 0.0) for x in obj_value]):
            obj_total = np.inf
        else:
            obj_total = np.nansum(obj_value)

        return obj_total