Example #1
0
    def build_parameters(cobj):
        cobj.cp_mol_liq_comp_coeff_1 = Var(
            doc="Parameter 1 for liquid phase molar heat capacity",
            units=pyunits.J * pyunits.kmol**-1 * pyunits.K**-1)
        set_param_from_config(cobj, param="cp_mol_liq_comp_coeff", index="1")

        cobj.cp_mol_liq_comp_coeff_2 = Var(
            doc="Parameter 2 for liquid phase molar heat capacity",
            units=pyunits.J * pyunits.kmol**-1 * pyunits.K**-2)
        set_param_from_config(cobj, param="cp_mol_liq_comp_coeff", index="2")

        cobj.cp_mol_liq_comp_coeff_3 = Var(
            doc="Parameter 3 for liquid phase molar heat capacity",
            units=pyunits.J * pyunits.kmol**-1 * pyunits.K**-3)
        set_param_from_config(cobj, param="cp_mol_liq_comp_coeff", index="3")

        cobj.cp_mol_liq_comp_coeff_4 = Var(
            doc="Parameter 4 for liquid phase molar heat capacity",
            units=pyunits.J * pyunits.kmol**-1 * pyunits.K**-4)
        set_param_from_config(cobj, param="cp_mol_liq_comp_coeff", index="4")

        cobj.cp_mol_liq_comp_coeff_5 = Var(
            doc="Parameter 5 for liquid phase molar heat capacity",
            units=pyunits.J * pyunits.kmol**-1 * pyunits.K**-5)
        set_param_from_config(cobj, param="cp_mol_liq_comp_coeff", index="5")
Example #2
0
    def build_parameters(cobj):
        cobj.vol_mol_liq_comp_coeff_a = Var(
            doc="Parameter a for liquid phase molar volume",
            units=pyunits.mL / pyunits.mol)
        set_param_from_config(cobj, param="vol_mol_liq_comp_coeff", index="a")

        cobj.vol_mol_liq_comp_coeff_b = Var(
            doc="Parameter b for liquid phase molar volume",
            units=pyunits.mL / pyunits.mol)
        set_param_from_config(cobj, param="vol_mol_liq_comp_coeff", index="b")

        cobj.vol_mol_liq_comp_coeff_c = Var(
            doc="Parameter c for liquid phase molar volume",
            units=pyunits.mL / pyunits.mol)
        set_param_from_config(cobj, param="vol_mol_liq_comp_coeff", index="c")

        cobj.vol_mol_liq_comp_coeff_d = Var(
            doc="Parameter d for liquid phase molar volume",
            units=pyunits.mL / pyunits.mol)
        set_param_from_config(cobj, param="vol_mol_liq_comp_coeff", index="d")

        cobj.vol_mol_liq_comp_coeff_e = Var(
            doc="Parameter e for liquid phase molar volume",
            units=pyunits.mL / pyunits.mol)
        set_param_from_config(cobj, param="vol_mol_liq_comp_coeff", index="e")
Example #3
0
    def build_parameters(cobj):
        if not hasattr(cobj, "cp_mass_liq_comp_coeff_1"):
            CpMolSolvent.build_parameters(cobj)

        cobj.dh_vap = Var(doc="Heat of absorption of component @ Tref",
                          units=pyunits.J / pyunits.mol)
        set_param_from_config(cobj, param="dh_vap")
    def build_parameters(rblock, config):
        parent = rblock.parent_block()
        units = parent.get_metadata().derived_units

        c_form = config.concentration_form
        if c_form is None:
            raise ConfigurationError(
                "{} concentration_form configuration argument was not set. "
                "Please ensure that this argument is included in your "
                "configuration dict.".format(rblock.name))
        elif not (c_form == ConcentrationForm.moleFraction
                  or c_form == ConcentrationForm.activity):
            raise ConfigurationError(
                "{} calculation of equilibrium constant based on Gibbs energy "
                "is only supported for mole fraction or activity forms. "
                "Currently selected form: {}".format(rblock.name, c_form))

        # Check that heat of reaction is constant
        if config.heat_of_reaction is not constant_dh_rxn:
            raise ConfigurationError(
                "{} calculating equilibrium constants from Gibbs energy "
                "assumes constant heat of reaction. Please ensure you are "
                "using the constant_dh_rxn method for this reaction".format(
                    rblock.name))

        rblock.ds_rxn_ref = Var(
            doc="Specific molar entropy of reaction at reference state",
            units=units["entropy_mole"])
        set_param_from_config(rblock, param="ds_rxn_ref", config=config)

        rblock.T_eq_ref = Var(
            doc="Reference temperature for equilibrium constant",
            units=units["temperature"])
        set_param_from_config(rblock, param="T_eq_ref", config=config)
Example #5
0
    def build_parameters(rblock, config):
        parent = rblock.parent_block()
        units = parent.get_metadata().derived_units

        rbasis = parent.config.reaction_basis
        if rbasis == MaterialFlowBasis.molar:
            r_base = units["amount"]
        elif rbasis == MaterialFlowBasis.mass:
            r_base = units["mass"]
        else:
            raise BurntToast(
                "{} for unexpected reaction basis {}. This should not happen "
                "so please contact the IDAES developers with this bug."
                .format(rblock.name, rbasis))

        c_form = config.concentration_form
        if c_form is None:
            raise ConfigurationError(
                "{} concentration_form configuration argument was not set. "
                "Please ensure that this argument is included in your "
                "configuration dict.".format(rblock.name))
        elif (c_form == ConcentrationForm.moleFraction or
              c_form == ConcentrationForm.massFraction):
            r_units = r_base*units["volume"]**-1*units["time"]**-1
        else:
            order = 0
            for p, j in parent.config.property_package._phase_component_set:
                order += -rblock.reaction_order[p, j].value

            if (c_form == ConcentrationForm.molarity or
                    c_form == ConcentrationForm.activity):
                c_units = units["density_mole"]
            elif c_form == ConcentrationForm.molality:
                c_units = units["amount"]*units["mass"]**-1
            elif c_form == ConcentrationForm.partialPressure:
                c_units = units["pressure"]
            else:
                raise BurntToast(
                    "{} get_concentration_term received unrecognised "
                    "ConcentrationForm ({}). This should not happen - please "
                    "contact the IDAES developers with this bug."
                    .format(rblock.name, c_form))

            r_units = (r_base *
                       units["length"]**-3 *
                       units["time"]**-1 *
                       c_units**order)

        rblock.arrhenius_const = Var(
                doc="Arrhenius constant (pre-exponential factor)",
                units=r_units)
        set_param_from_config(rblock, param="arrhenius_const", config=config)

        rblock.energy_activation = Var(
                doc="Activation energy",
                units=units["energy_mole"])

        set_param_from_config(rblock, param="energy_activation", config=config)
Example #6
0
    def build_parameters(cobj):
        if not hasattr(cobj, "cp_mol_ig_comp_coeff_a0"):
            cp_mol_ig_comp.build_parameters(cobj)

        units = cobj.parent_block().get_metadata().derived_units

        cobj.entr_mol_form_vap_comp_ref = Var(
            doc="Vapor phase molar entropy of formation @ Tref",
            units=units["entropy_mole"])
        set_param_from_config(cobj, param="entr_mol_form_vap_comp_ref")
Example #7
0
        def build_parameters(cobj):
            if not hasattr(cobj, "cp_mol_liq_comp_coeff"):
                Constant.cp_mol_liq_comp.build_parameters(cobj)

            units = cobj.parent_block().get_metadata().derived_units

            cobj.entr_mol_form_liq_comp_ref = Var(
                doc="Liquid phase molar entropy of formation @ Tref",
                units=units["entropy_mole"])
            set_param_from_config(cobj, param="entr_mol_form_liq_comp_ref")
Example #8
0
    def build_parameters(rblock, config):
        parent = rblock.parent_block()
        units = parent.get_metadata().derived_units

        c_form = config.concentration_form
        if c_form is None:
            raise ConfigurationError(
                "{} concentration_form configuration argument was not set. "
                "Please ensure that this argument is included in your "
                "configuration dict.".format(rblock.name))
        elif (c_form == ConcentrationForm.moleFraction
              or c_form == ConcentrationForm.massFraction
              or c_form == ConcentrationForm.activity):
            e_units = pyunits.dimensionless
        else:
            order = 0

            try:
                # This will work for Reaction Packages
                pc_set = parent.config.property_package._phase_component_set
            except AttributeError:
                # Need to allow for inherent reactions in Property Packages
                if not parent._electrolyte:
                    # In most cases ,should have _phase_component_set
                    pc_set = parent._phase_component_set
                else:
                    # However, for electrolytes need true species set
                    pc_set = parent.true_phase_component_set

            for p, j in pc_set:
                order += rblock.reaction_order[p, j].value

            if c_form == ConcentrationForm.molarity:
                c_units = units["density_mole"]
            elif c_form == ConcentrationForm.molality:
                c_units = units["amount"] * units["mass"]**-1
            elif c_form == ConcentrationForm.partialPressure:
                c_units = units["pressure"]
            else:
                raise BurntToast(
                    "{} get_concentration_term received unrecognised "
                    "ConcentrationForm ({}). This should not happen - please "
                    "contact the IDAES developers with this bug.".format(
                        rblock.name, c_form))

            e_units = c_units**order

        rblock.k_eq_ref = Var(doc="Equilibrium constant at reference state",
                              units=e_units)
        set_param_from_config(rblock, param="k_eq_ref", config=config)

        rblock.T_eq_ref = Var(
            doc="Reference temperature for equilibrium constant",
            units=units["temperature"])
        set_param_from_config(rblock, param="T_eq_ref", config=config)
Example #9
0
    def test_indexed(self):
        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {"test_param": {"1": 42}}

        m.b.test_param_1 = Var(initialize=1)

        set_param_from_config(m.b, "test_param", index="1")

        assert m.b.test_param_1.value == 42
Example #10
0
    def test_no_param(self):
        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {"test_param": 42}

        with pytest.raises(AttributeError,
                           match="b - set_param_from_config method was "
                           "provided with param argument test_param, but no "
                           "attribute of that name exists."):
            set_param_from_config(m.b, "test_param")
Example #11
0
    def build_parameters(cobj):
        if not hasattr(cobj, "cp_mol_ig_comp_coeff_A"):
            cp_mol_ig_comp.build_parameters(cobj)

        base_units = cobj.parent_block().get_metadata().default_units
        h_units = (base_units["mass"] * base_units["length"]**2 *
                   base_units["time"]**-2 * base_units["amount"]**-1)

        cobj.enth_mol_form_vap_comp_ref = Var(
            doc="Vapor phase molar heat of formation @ Tref", units=h_units)
        set_param_from_config(cobj, param="enth_mol_form_vap_comp_ref")
Example #12
0
    def test_invalid_config(self):
        m = ConcreteModel()
        m.b = Block()
        m.b.config = "foo"

        m.b.test_param = Var(initialize=1)

        with pytest.raises(TypeError,
                           match="b - set_param_from_config - config argument "
                           "provided is not an instance of a Config Block."):
            set_param_from_config(m.b, "test_param")
Example #13
0
        def build_parameters(cobj):
            if not hasattr(cobj, "cp_mol_ig_comp_coeff"):
                Constant.cp_mol_ig_comp.build_parameters(cobj)

            if cobj.parent_block().config.include_enthalpy_of_formation:
                units = cobj.parent_block().get_metadata().derived_units

                cobj.enth_mol_form_ig_comp_ref = Var(
                    doc="Ideal gas molar heat of formation @ Tref",
                    units=units["energy_mole"])
                set_param_from_config(cobj, param="enth_mol_form_ig_comp_ref")
Example #14
0
    def test_specified_config(self):
        m = ConcreteModel()
        m.b = Block()
        m.b.config2 = ConfigBlock(implicit=True)
        m.b.config2.parameter_data = {"test_param": 42}

        m.b.test_param = Var(initialize=1)

        set_param_from_config(m.b, "test_param", config=m.b.config2)

        assert m.b.test_param.value == 42
Example #15
0
    def build_parameters(rblock, config):
        parent = rblock.parent_block()
        units = parent.get_metadata().derived_units

        c_form = config.concentration_form
        if c_form is None:
            raise ConfigurationError(
                "{} concentration_form configuration argument was not set. "
                "Please ensure that this argument is included in your "
                "configuration dict.".format(rblock.name))
        elif (c_form == ConcentrationForm.molarity
              or c_form == ConcentrationForm.activity):

            order = 0
            try:
                # This will work for Reaction Packages
                pc_set = parent.config.property_package._phase_component_set
            except AttributeError:
                # Need to allow for inherent reactions in Property Packages
                if not parent._electrolyte:
                    # In most cases ,should have _phase_component_set
                    pc_set = parent._phase_component_set
                else:
                    # However, for electrolytes need true species set
                    pc_set = parent.true_phase_component_set

            for p, j in pc_set:
                order += rblock.reaction_order[p, j].value

            rblock._keq_units = (pyunits.convert(1 * pyunits.mol / pyunits.L,
                                                 units["density_mole"]))**order
        else:
            raise ConfigurationError(
                "{} calculation of equilibrium constant based on Gibbs energy "
                "is only supported for molarity or activity forms. "
                "Currently selected form: {}".format(rblock.name, c_form))

        # Check that heat of reaction is constant
        if config.heat_of_reaction is not constant_dh_rxn:
            raise ConfigurationError(
                "{} calculating equilibrium constants from Gibbs energy "
                "assumes constant heat of reaction. Please ensure you are "
                "using the constant_dh_rxn method for this reaction".format(
                    rblock.name))

        rblock.ds_rxn_ref = Var(
            doc="Specific molar entropy of reaction at reference state",
            units=units["entropy_mole"])
        set_param_from_config(rblock, param="ds_rxn_ref", config=config)

        rblock.T_eq_ref = Var(
            doc="Reference temperature for equilibrium constant",
            units=units["temperature"])
        set_param_from_config(rblock, param="T_eq_ref", config=config)
Example #16
0
    def test_no_config(self):
        m = ConcreteModel()
        m.b = Block()

        m.b.test_param = Var(initialize=1)

        with pytest.raises(AttributeError,
                           match="b - set_param_from_config method was "
                           "not provided with a config argument, but no "
                           "default Config block exists. Please specify the "
                           "Config block to use via the config argument."):
            set_param_from_config(m.b, "test_param")
Example #17
0
    def test_consistent_units(self, caplog):
        caplog.set_level(idaeslog.DEBUG, logger=("idaes.core.util.misc"))

        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {"test_param": (42, units.m)}

        m.b.test_param = Var(initialize=1, units=units.m)

        set_param_from_config(m.b, "test_param")

        assert m.b.test_param.value == 42
Example #18
0
    def test_no_parameter_data(self):
        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {}

        m.b.test_param = Var(initialize=1)

        with pytest.raises(KeyError,
                           match="b - set_param_from_config method was "
                           "provided with param argument test_param, but the "
                           "config block does not contain a value for this "
                           "parameter."):
            set_param_from_config(m.b, "test_param")
Example #19
0
    def test_no_parameter_data_indexed(self):
        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {"test_param": {"2": 42}}

        m.b.test_param_1 = Var(initialize=1)

        with pytest.raises(KeyError,
                           match="b - set_param_from_config method was "
                           "provided with param and index arguments "
                           "test_param 1, but the config block does not "
                           "contain a value for this parameter and index."):
            set_param_from_config(m.b, "test_param", index="1")
Example #20
0
    def build_parameters(rblock, config):
        units = rblock.parent_block().get_metadata().derived_units

        rbasis = rblock.parent_block().config.reaction_basis
        if rbasis == MaterialFlowBasis.molar:
            basis = "mole"
        elif rbasis == MaterialFlowBasis.mass:
            basis = "mass"

        rblock.dh_rxn_ref = Var(
            doc="Specific heat of reaction at reference state",
            units=units["energy_" + basis])

        set_param_from_config(rblock, param="dh_rxn_ref", config=config)
Example #21
0
    def test_inconsistent_units_none_2(self, caplog):
        caplog.set_level(idaeslog.DEBUG, logger=("idaes.core.util.misc"))

        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {"test_param": (42, units.s)}

        m.b.test_param = Var(initialize=1, units=None)

        with pytest.raises(UnitsError,
                           match="Cannot convert s to None. Units "
                           "are not compatible."):
            set_param_from_config(m.b, "test_param")
Example #22
0
    def test_no_param_indexed(self):
        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {"test_param": {"1": 42}}

        m.b.test_param = Var(initialize=1)

        with pytest.raises(AttributeError,
                           match="b - set_param_from_config method was "
                           "provided with param and index arguments "
                           "test_param 1, but no attribute with that "
                           "combination \(test_param_1\) exists."):
            set_param_from_config(m.b, "test_param", index="1")
Example #23
0
    def test_unitted_default(self, caplog):
        caplog.set_level(idaeslog.DEBUG, logger=("idaes.core.util.misc"))

        m = ConcreteModel()
        m.b = Block()
        m.b.config = ConfigBlock(implicit=True)
        m.b.config.parameter_data = {"test_param": 42}

        m.b.test_param = Var(initialize=1, units=units.m)

        set_param_from_config(m.b, "test_param")

        assert m.b.test_param.value == 42

        assert ("b no units provided for parameter test_param - assuming "
                "default units" in caplog.text)
Example #24
0
    def build(self):
        super(ComponentData, self).build()

        # If the component_list does not exist, add reference to new Component
        # The IF is mostly for backwards compatability, to allow for old-style
        # property packages where the component_list already exists but we
        # need to add new Component objects
        if not self.config._component_list_exists:
            if not self.config._electrolyte:
                self.__add_to_component_list()
            else:
                self._add_to_electrolyte_component_list()

        base_units = self.parent_block().get_metadata().default_units
        if isinstance(base_units["mass"], _PyomoUnit):
            # Backwards compatability check
            p_units = (base_units["mass"] / base_units["length"] /
                       base_units["time"]**2)
        else:
            # Backwards compatability check
            p_units = None

        # Create Param for molecular weight if provided
        if "mw" in self.config.parameter_data:
            if isinstance(self.config.parameter_data["mw"], tuple):
                mw_init = pyunits.convert_value(
                    self.config.parameter_data["mw"][0],
                    from_units=self.config.parameter_data["mw"][1],
                    to_units=base_units["mass"] / base_units["amount"])
            else:
                _log.debug("{} no units provided for parameter mw - assuming "
                           "default units".format(self.name))
                mw_init = self.config.parameter_data["mw"]
            self.mw = Param(initialize=mw_init,
                            units=base_units["mass"] / base_units["amount"])

        # Create Vars for common parameters
        param_dict = {
            "pressure_crit": p_units,
            "temperature_crit": base_units["temperature"],
            "omega": None
        }
        for p, u in param_dict.items():
            if p in self.config.parameter_data:
                self.add_component(p, Var(units=u))
                set_param_from_config(self, p)
    def build_parameters(rblock, config):
        parent = rblock.parent_block()
        units = parent.get_metadata().derived_units

        c_form = config.concentration_form
        if c_form is None:
            raise ConfigurationError(
                "{} concentration_form configuration argument was not set. "
                "Please ensure that this argument is included in your "
                "configuration dict.".format(rblock.name))
        elif (c_form == ConcentrationForm.moleFraction or
              c_form == ConcentrationForm.massFraction):
            e_units = None
        else:
            order = 0
            for p, j in parent.config.property_package._phase_component_set:
                order += rblock.reaction_order[p, j].value

            if (c_form == ConcentrationForm.molarity or
                    c_form == ConcentrationForm.activity):
                c_units = units["density_mole"]
            elif c_form == ConcentrationForm.molality:
                c_units = units["amount"]*units["mass"]**-1
            elif c_form == ConcentrationForm.partialPressure:
                c_units = units["pressure"]
            else:
                raise BurntToast(
                    "{} get_concentration_term received unrecognised "
                    "ConcentrationForm ({}). This should not happen - please "
                    "contact the IDAES developers with this bug."
                    .format(rblock.name, c_form))

            e_units = c_units**order

        rblock.k_eq_ref = Var(
                doc="Equilibrium constant at reference state",
                units=e_units)
        set_param_from_config(rblock, param="k_eq_ref", config=config)

        rblock.T_eq_ref = Var(
                doc="Reference temperature for equilibrium constant",
                units=units["temperature"])
        set_param_from_config(rblock, param="T_eq_ref", config=config)
Example #26
0
 def build_parameters(cobj, phase):
     cobj.diffus_phase_comp_coeff_1 = Var(
         doc="Parameter 1 for liquid phase diffusivity model",
         units=pyunits.m**2 / pyunits.s)
     set_param_from_config(cobj, param="diffus_phase_comp_coeff", index="1")
     cobj.diffus_phase_comp_coeff_2 = Var(
         doc="Parameter 2 for liquid phase diffusivity model",
         units=pyunits.m**5 / pyunits.kmol / pyunits.s)
     set_param_from_config(cobj, param="diffus_phase_comp_coeff", index="2")
     cobj.diffus_phase_comp_coeff_3 = Var(
         doc="Parameter 3 for liquid phase diffusivity model",
         units=pyunits.m**8 / pyunits.kmol**2 / pyunits.s)
     set_param_from_config(cobj, param="diffus_phase_comp_coeff", index="3")
     cobj.diffus_phase_comp_coeff_4 = Var(
         doc="Parameter 4 for liquid phase diffusivity model",
         units=pyunits.K)
     set_param_from_config(cobj, param="diffus_phase_comp_coeff", index="4")
     cobj.diffus_phase_comp_coeff_5 = Var(
         doc="Parameter 5 for liquid phase diffusivity model",
         units=(pyunits.m**3) * pyunits.K / pyunits.kmol)
     set_param_from_config(cobj, param="diffus_phase_comp_coeff", index="5")
Example #27
0
    def build_parameters(cobj):
        cobj.dens_mol_liq_comp_coeff_eqn_type = Param(
            mutable=True, doc="Liquid molar density equation form")

        try:
            set_param_from_config(cobj,
                                  param="dens_mol_liq_comp_coeff",
                                  index="eqn_type")
        except KeyError:
            _log.warning("DEPRECATED - {} dens_mol_liq_comp_coeff index "
                         "'eqn_type' should be specified, defaulting to "
                         "equation form 1.".format(cobj))
            # default to equation form 1 if not specified
            cobj.dens_mol_liq_comp_coeff_eqn_type.value = 1

        if cobj.dens_mol_liq_comp_coeff_eqn_type.value == 1:
            dens_mol_liq_comp_eqn_1.build_parameters(cobj)
        elif cobj.dens_mol_liq_comp_coeff_eqn_type.value == 2:
            dens_mol_liq_comp_eqn_2.build_parameters(cobj)
        else:
            raise ConfigurationError(
                f"{cobj.name} unrecognized value for "
                f"dens_mol_liq_comp equation type: "
                f"{cobj.dens_mol_liq_comp_coeff_eqn_type}")
Example #28
0
    def build_parameters(cobj):
        cobj.cp_mol_ig_comp_coeff_a0 = Var(
            doc="Parameter a0 for ideal gas molar heat capacity", units=None)
        set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="a0")

        cobj.cp_mol_ig_comp_coeff_a1 = Var(
            doc="Parameter a1 for ideal gas molar heat capacity",
            units=pyunits.K**-1)
        set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="a1")

        cobj.cp_mol_ig_comp_coeff_a2 = Var(
            doc="Parameter a2 for ideal gas molar heat capacity",
            units=pyunits.K**-2)
        set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="a2")

        cobj.cp_mol_ig_comp_coeff_a3 = Var(
            doc="Parameter a3 for ideal gas molar heat capacity",
            units=pyunits.K**-3)
        set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="a3")

        cobj.cp_mol_ig_comp_coeff_a4 = Var(
            doc="Parameter a4 for ideal gas molar heat capacity",
            units=pyunits.K**-4)
        set_param_from_config(cobj, param="cp_mol_ig_comp_coeff", index="a4")
Example #29
0
    def build(self):
        super().build()

        # If the component_list does not exist, add reference to new Component
        # The IF is mostly for backwards compatability, to allow for old-style
        # property packages where the component_list already exists but we
        # need to add new Component objects
        if not self.config._component_list_exists:
            if not self.config._electrolyte:
                self._add_to_component_list()
            else:
                self._add_to_electrolyte_component_list()

        base_units = self.parent_block().get_metadata().default_units
        der_units = self.parent_block().get_metadata().derived_units
        p_units = (base_units["mass"] / base_units["length"] /
                   base_units["time"]**2)

        # Create Param for molecular weight if provided
        param_dict = {"mw": base_units["mass"] / base_units["amount"]}
        for p, u in param_dict.items():
            if p in self.config.parameter_data:
                self.add_component(p, Param(mutable=True, units=u))
                set_param_from_config(self, p)

        # Create Vars for common parameters
        var_dict = {
            "dens_mol_crit": der_units["density_mole"],
            "omega": pyunits.dimensionless,
            "pressure_crit": p_units,
            "temperature_crit": base_units["temperature"]
        }
        for p, u in var_dict.items():
            if p in self.config.parameter_data:
                self.add_component(p, Var(units=u))
                set_param_from_config(self, p)
Example #30
0
    def build_parameters(cobj):
        cobj.pressure_sat_comp_coeff_1 = Var(
            doc="Coefficient 1 for calculating Psat",
            units=pyunits.dimensionless)
        set_param_from_config(cobj, param="pressure_sat_comp_coeff", index="1")

        cobj.pressure_sat_comp_coeff_2 = Var(
            doc="Coefficient 2 for calculating Psat", units=pyunits.K)
        set_param_from_config(cobj, param="pressure_sat_comp_coeff", index="2")

        cobj.pressure_sat_comp_coeff_3 = Var(
            doc="Coefficient 3 for calculating Psat",
            units=pyunits.dimensionless)
        set_param_from_config(cobj, param="pressure_sat_comp_coeff", index="3")

        cobj.pressure_sat_comp_coeff_4 = Var(
            doc="Coefficient 4 for calculating Psat", units=pyunits.K**-2)
        set_param_from_config(cobj, param="pressure_sat_comp_coeff", index="4")