Пример #1
0
    def __init__(self, data_dict):

        super().__init__(data_dict)

        self.name = "liquid_density"
        tmp = {
            "min_density_fraction": (1.0 / 300000.0),
            "density_increment": 10.0,
            "max_volume_increment": 1.0e-4,
        }
        if "density_opts" in self.thermodict:
            tmp.update(self.thermodict["density_opts"])
        self.thermodict["density_opts"] = tmp

        if self.thermodict["calculation_type"] == None:
            self.thermodict["calculation_type"] = "liquid_properties"

        if "xi" in data_dict:
            self.thermodict["xilist"] = data_dict["xi"]
            del data_dict["xi"]
        if "T" in data_dict:
            self.thermodict["Tlist"] = data_dict["T"]
            del data_dict["T"]
        if "P" in data_dict:
            self.thermodict["Plist"] = data_dict["P"]
            del data_dict["P"]

        self.thermodict.update(data_dict)

        thermo_keys = ["Plist", "xilist", "Tlist"]
        self.result_keys = ["rhol", "phil"]

        key_list = list(set(thermo_keys + self.result_keys))
        self.thermodict.update(gtb.check_length_dict(self.thermodict,
                                                     key_list))
        self.npoints = np.size(self.thermodict["Tlist"])

        if "xilist" not in self.thermodict and self.Eos.number_of_components > 1:
            raise ValueError("Ambiguous mixture composition. Define xi")
        thermo_defaults = [
            constants.standard_pressure,
            np.array([[1.0] for x in range(self.npoints)]),
            constants.standard_temperature,
        ]
        self.thermodict.update(
            gtb.set_defaults(self.thermodict,
                             thermo_keys,
                             thermo_defaults,
                             lx=self.npoints))

        self.weights.update(
            gtb.check_length_dict(self.weights,
                                  self.result_keys,
                                  lx=self.npoints))
        self.weights.update(
            gtb.set_defaults(self.weights, self.result_keys, 1.0))

        if "Tlist" not in self.thermodict and "rhol" not in self.thermodict:
            raise ImportError(
                "Given liquid property data, values for T, xi, and rhol should have been provided."
            )

        logger.info(
            "Data type 'liquid_properties' initiated with calculation_type, {}, and data types: {}.\nWeight data by: {}"
            .format(
                self.thermodict["calculation_type"],
                ", ".join(self.result_keys),
                self.weights,
            ))
Пример #2
0
    def __init__(self, data_dict):

        data_dict = data_dict.copy()

        super().__init__(data_dict)

        self.name = "flash"
        if self.thermodict["calculation_type"] == None:
            logger.warning("No calculation type has been provided.")
            self.thermodict["calculation_type"] = "flash"

        tmp = {
            "min_density_fraction": (1.0 / 300000.0),
            "density_increment": 10.0,
            "max_volume_increment": 1.0e-4,
        }
        if "density_opts" in self.thermodict:
            tmp.update(self.thermodict["density_opts"])
        self.thermodict["density_opts"] = tmp

        if "xi" in data_dict:
            self.thermodict["xilist"] = data_dict["xi"]
            del data_dict["xi"]
            if "xi" in self.weights:
                self.weights["xilist"] = self.weights.pop("xi")
        if "yi" in data_dict:
            self.thermodict["yilist"] = data_dict["yi"]
            del data_dict["yi"]
            if "yi" in self.weights:
                self.weights["yilist"] = self.weights.pop("yi")
        if "T" in data_dict:
            self.thermodict["Tlist"] = data_dict["T"]
            del data_dict["T"]
        if "P" in data_dict:
            self.thermodict["Plist"] = data_dict["P"]
            del data_dict["P"]

        self.thermodict.update(data_dict)

        thermo_keys = ["Plist", "Tlist"]
        self.result_keys = ["xilist", "yilist"]

        key_list = list(set(thermo_keys + self.result_keys))
        self.thermodict.update(gtb.check_length_dict(self.thermodict,
                                                     key_list))
        self.npoints = np.size(self.thermodict["Tlist"])

        thermo_defaults = [
            constants.standard_pressure, constants.standard_temperature
        ]
        self.thermodict.update(
            gtb.set_defaults(self.thermodict,
                             thermo_keys,
                             thermo_defaults,
                             lx=self.npoints))

        self.weights.update(
            gtb.check_length_dict(self.weights,
                                  self.result_keys,
                                  lx=self.npoints))
        self.weights.update(
            gtb.set_defaults(self.weights, self.result_keys, 1.0))

        if "Plist" not in self.thermodict and "Tlist" not in self.thermodict:
            raise ImportError(
                "Given flash data, values for P and T should have been provided."
            )

        if "xilist" not in self.thermodict or "yilist" not in self.thermodict:
            raise ImportError(
                "Given flash data, mole fractions should have been provided.")

        logger.info(
            "Data type 'flash' initiated with calculation_type, {}, and data types: {}.\nWeight data by: {}"
            .format(
                self.thermodict["calculation_type"],
                ", ".join(self.result_keys),
                self.weights,
            ))
Пример #3
0
    def __init__(self, data_dict):

        super().__init__(data_dict)

        self.name = "TLVE"
        self.thermodict["density_opts"] = {}
        if "density_opts" in self.thermodict:
            self.thermodict["density_opts"].update(
                self.thermodict["density_opts"])

        if "T" in data_dict:
            self.thermodict["Tlist"] = data_dict["T"]
            del data_dict["T"]
        if "xi" in data_dict:
            self.thermodict["xilist"] = data_dict["xi"]
            del data_dict["xi"]
            if "xi" in self.weights:
                self.weights["xilist"] = self.weights.pop("xi")
        if "yi" in data_dict:
            self.thermodict["yilist"] = data_dict["yi"]
            del data_dict["yi"]
            if "yi" in self.weights:
                self.weights["yilist"] = self.weights.pop("yi")
        if "P" in data_dict:
            self.thermodict["Plist"] = data_dict["P"]
            self.thermodict["Pguess"] = data_dict["P"]
            del data_dict["P"]
            if "P" in self.weights:
                self.weights["Plist"] = self.weights.pop("P")

        self.thermodict.update(data_dict)

        thermo_keys = ["Plist", "xilist", "Tlist"]
        self.result_keys = ["Plist", "xilist", "yilist"]

        key_list = list(set(thermo_keys + self.result_keys))
        self.thermodict.update(gtb.check_length_dict(self.thermodict,
                                                     key_list))
        self.npoints = np.size(self.thermodict["Tlist"])

        self.thermodict.update(
            gtb.set_defaults(
                self.thermodict,
                "Tlist",
                constants.standard_temperature,
                lx=self.npoints,
            ))

        self.weights.update(
            gtb.check_length_dict(self.weights,
                                  self.result_keys,
                                  lx=self.npoints))
        self.weights.update(
            gtb.set_defaults(self.weights, self.result_keys, 1.0))

        if "Tlist" not in self.thermodict:
            raise ImportError(
                "Given TLVE data, values for T should have been provided.")

        thermo_keys = ["xilist", "yilist", "Plist"]
        if not any([key in self.thermodict for key in thermo_keys]):
            raise ImportError(
                "Given TLVE data, mole fractions and/or pressure should have been provided."
            )

        if self.thermodict["calculation_type"] == None:
            if self.thermodict["xilist"]:
                self.thermodict["calculation_type"] = "bubble_pressure"
                logger.warning(
                    "No calculation type has been provided. Assume a calculation type of bubble_pressure"
                )
            elif self.thermodict["yilist"]:
                self.thermodict["calculation_type"] = "dew_pressure"
                logger.warning(
                    "No calculation type has been provided. Assume a calculation type of dew_pressure"
                )
            else:
                raise ValueError("Unknown calculation instructions")

        if self.thermodict["calculation_type"] == "bubble_pressure":
            self.result_keys.remove("xilist")
            del self.weights["xilist"]
        elif self.thermodict["calculation_type"] == "dew_pressure":
            self.result_keys.remove("yilist")
            del self.weights["yilist"]

        logger.info(
            "Data type 'TLVE' initiated with calculation_type, {}, and data types: {}.\nWeight data by: {}"
            .format(
                self.thermodict["calculation_type"],
                ", ".join(self.result_keys),
                self.weights,
            ))
Пример #4
0
    def __init__(self, data_dict):

        data_dict = data_dict.copy()

        super().__init__(data_dict)

        self.name = "solubility_parameter"
        if self.thermodict["calculation_type"] == None:
            self.thermodict["calculation_type"] = "solubility_parameter"

        if "density_opts" not in self.thermodict:
            self.thermodict["density_opts"] = {}

        if "xi" in data_dict:
            self.thermodict["xilist"] = data_dict["xi"]
            del data_dict["xi"]
        if "yi" in data_dict:
            self.thermodict["xilist"] = data_dict["yi"]
            del data_dict["yi"]
            logger.info("Vapor mole fraction recorded as 'xi'")
        if "T" in data_dict:
            self.thermodict["Tlist"] = data_dict["T"]
            del data_dict["T"]
        if "P" in data_dict:
            self.thermodict["Plist"] = data_dict["P"]
            del data_dict["P"]
            if "P" in self.weights:
                self.weights["Plist"] = self.weights.pop("P")

        self.thermodict.update(data_dict)

        thermo_keys = ["Plist", "xilist", "Tlist"]
        self.result_keys = ["rhol", "delta"]

        key_list = list(set(thermo_keys + self.result_keys))
        self.thermodict.update(gtb.check_length_dict(self.thermodict, key_list))
        self.npoints = np.size(self.thermodict["delta"])

        if "xilist" not in self.thermodict and self.Eos.number_of_components > 1:
            raise ValueError("Ambiguous mixture composition. Define xi")
        thermo_defaults = [
            constants.standard_pressure,
            np.array([[1.0] for x in range(self.npoints)]),
            constants.standard_temperature,
        ]
        self.thermodict.update(
            gtb.set_defaults(
                self.thermodict, thermo_keys, thermo_defaults, lx=self.npoints
            )
        )

        self.weights.update(
            gtb.check_length_dict(self.weights, self.result_keys, lx=self.npoints)
        )
        self.weights.update(gtb.set_defaults(self.weights, self.result_keys, 1.0))

        if "Tlist" not in self.thermodict and "delta" not in self.thermodict:
            raise ImportError(
                "Given solubility data, value(s) for T and delta should have been provided."
            )

        logger.info(
            "Data type 'solubility parameter' initiated with calculation_type, {}, and data types: {}.\nWeight data by: {}".format(
                self.thermodict["calculation_type"],
                ", ".join(self.result_keys),
                self.weights,
            )
        )
Пример #5
0
    def __init__(self, data_dict):

        super().__init__(data_dict)

        # If required items weren't defined, set defaults
        self.name = "saturation_properties"
        if self.thermodict["calculation_type"] == None:
            self.thermodict["calculation_type"] = "saturation_properties"

        tmp = {
            "min_density_fraction": (1.0 / 80000.0),
            "density_increment": 10.0,
            "max_volume_increment": 1.0e-4,
        }
        if "density_opts" in self.thermodict:
            tmp.update(self.thermodict["density_opts"])
        self.thermodict["density_opts"] = tmp

        # Extract system data
        if "xi" in data_dict:
            self.thermodict["xilist"] = data_dict["xi"]
            del data_dict["xi"]
        if "yi" in data_dict:
            self.thermodict["xilist"] = data_dict["yi"]
            logger.info("Vapor mole fraction recorded as 'xi'")
            del data_dict["yi"]
        if "T" in data_dict:
            self.thermodict["Tlist"] = data_dict["T"]
            del data_dict["T"]
        if "P" in data_dict:
            self.thermodict["Psat"] = data_dict["P"]
            del data_dict["P"]
            if "P" in self.weights:
                if gtb.isiterable(self.weights["P"]) and len(
                        self.weights["P"]) != len(self.thermodict["Psat"]):
                    raise ValueError(
                        "Array of weights for '{}' values not equal to number of experimental values given."
                        .format("P"))
                else:
                    self.weights["Psat"] = self.weights.pop("P")

        self.thermodict.update(data_dict)

        thermo_keys = ["xilist", "Tlist"]
        self.result_keys = ["rhol", "rhov", "Psat"]

        key_list = list(set(thermo_keys + self.result_keys))
        self.thermodict.update(gtb.check_length_dict(self.thermodict,
                                                     key_list))
        for key in self.result_keys:
            if key in self.thermodict:
                self.npoints = np.size(self.thermodict[key])
                break

        if "xilist" not in self.thermodict and self.Eos.number_of_components > 1:
            raise ValueError(
                "Ambiguous instructions. Include xi to define intended component to obtain saturation properties"
            )
        thermo_defaults = [
            np.array([[1.0] for x in range(self.npoints)]),
            constants.standard_temperature,
        ]
        self.thermodict.update(
            gtb.set_defaults(self.thermodict,
                             thermo_keys,
                             thermo_defaults,
                             lx=self.npoints))

        self.weights.update(
            gtb.check_length_dict(self.weights,
                                  self.result_keys,
                                  lx=self.npoints))
        self.weights.update(
            gtb.set_defaults(self.weights, self.result_keys, 1.0))

        if "Tlist" not in self.thermodict:
            raise ImportError(
                "Given saturation data, value(s) for T should have been provided."
            )

        tmp = ["Psat", "rhol", "rhov"]
        if not any([x in self.thermodict for x in tmp]):
            raise ImportError(
                "Given saturation data, values for Psat, rhol, and/or rhov should have been provided."
            )

        logger.info(
            "Data type 'saturation_properties' initiated with calculation_type, {}, and data types: {}.\nWeight data by: {}"
            .format(
                self.thermodict["calculation_type"],
                ", ".join(self.result_keys),
                self.weights,
            ))