Example #1
0
def test_validate_parameter_block_invalid_phase_object():
    m = ConcreteModel()
    m.p = ParameterBlock()

    m.meta_object = PropertyClassMetadata()
    m.meta_object.add_default_units({
        'time': pyunits.s,
        'length': pyunits.m,
        'mass': pyunits.kg,
        'amount': pyunits.mol,
        'temperature': pyunits.K
    })

    def get_metadata(self):
        return m.meta_object

    m.p.get_metadata = types.MethodType(get_metadata, m.p)

    m.p.c1 = Component()
    m.p.c2 = Component()

    m.p.phase_list = Set(initialize=["foo"])
    m.p.foo = object()

    with pytest.raises(TypeError,
                       match="Property package p has an object foo whose "
                       "name appears in phase_list but is not an "
                       "instance of Phase"):
        m.p._validate_parameter_block()
Example #2
0
    def m(self):
        m = ConcreteModel()

        m.meta_object = PropertyClassMetadata()

        def get_metadata(self):
            return m.meta_object

        m.get_metadata = types.MethodType(get_metadata, m)

        m.comp = Component()
        m.comp2 = Component()

        return m
Example #3
0
def test_get_component():
    m = ConcreteModel()
    m.p = ParameterBlock()

    m.meta_object = PropertyClassMetadata()

    def get_metadata(self):
        return m.meta_object

    m.p.get_metadata = types.MethodType(get_metadata, m.p)

    with pytest.raises(AttributeError):
        m.p.get_component("foo")

    m.p.comp = Component()

    assert m.p.get_component("comp") is m.p.comp

    m.p.a = object()

    with pytest.raises(
            PropertyPackageError,
            match="p get_component found an attribute a, but it does not "
            "appear to be an instance of a Component object."):
        m.p.get_component("a")
Example #4
0
def test_get_component():
    m = ConcreteModel()
    m.p = ParameterBlock()

    m.meta_object = PropertyClassMetadata()
    m.meta_object.add_default_units({
        'time': pyunits.s,
        'length': pyunits.m,
        'mass': pyunits.kg,
        'amount': pyunits.mol,
        'temperature': pyunits.K
    })

    def get_metadata(self):
        return m.meta_object

    m.p.get_metadata = types.MethodType(get_metadata, m.p)

    with pytest.raises(AttributeError):
        m.p.get_component("foo")

    m.p.comp = Component()

    assert m.p.get_component("comp") is m.p.comp

    m.p.a = object()

    with pytest.raises(
            PropertyPackageError,
            match="p get_component found an attribute a, but it does not "
            "appear to be an instance of a Component object."):
        m.p.get_component("a")
Example #5
0
    def test_create_parameters_convert(self):
        m = ConcreteModel()

        m.meta_object = PropertyClassMetadata()

        def get_metadata(self):
            return m.meta_object

        m.get_metadata = types.MethodType(get_metadata, m)
        m.get_metadata().default_units["amount"] = pyunits.mol
        m.get_metadata().default_units["mass"] = pyunits.kg
        m.get_metadata().default_units["time"] = pyunits.s
        m.get_metadata().default_units["length"] = pyunits.m
        m.get_metadata().default_units["temperature"] = pyunits.K

        m.comp = Component(
            default={
                "parameter_data": {
                    "mw": (10, pyunits.g / pyunits.mol),
                    "pressure_crit": (1, pyunits.bar),
                    "temperature_crit": (900, pyunits.degR)
                }
            })

        assert isinstance(m.comp.mw, Param)
        assert m.comp.mw.value == 1e-2

        assert isinstance(m.comp.pressure_crit, Var)
        assert m.comp.pressure_crit.value == 1e5

        assert isinstance(m.comp.temperature_crit, Var)
        assert m.comp.temperature_crit.value == 500
Example #6
0
    def test_is_phase_valid_solid(self, m):
        m.comp5 = Component(
            default={"valid_phase_types": PhaseType.solidPhase})

        assert not m.comp5._is_phase_valid(m.Liq)
        assert m.comp5._is_phase_valid(m.Sol)
        assert not m.comp5._is_phase_valid(m.Vap)
        assert not m.comp5._is_phase_valid(m.Phase)
Example #7
0
    def test_is_phase_valid_vapor(self, m):
        m.comp4 = Component(
            default={"valid_phase_types": PhaseType.vaporPhase})

        assert not m.comp4._is_phase_valid(m.Liq)
        assert not m.comp4._is_phase_valid(m.Sol)
        assert m.comp4._is_phase_valid(m.Vap)
        assert not m.comp4._is_phase_valid(m.Phase)
Example #8
0
    def test_is_phase_valid_LV(self, m):
        m.comp6 = Component(default={
            "valid_phase_types": [PhaseType.liquidPhase, PhaseType.vaporPhase]
        })

        assert m.comp6._is_phase_valid(m.Liq)
        assert not m.comp6._is_phase_valid(m.Sol)
        assert m.comp6._is_phase_valid(m.Vap)
        assert not m.comp6._is_phase_valid(m.Phase)
Example #9
0
    def test_is_phase_valid_aqueous(self, m):
        m.comp6 = Component(
            default={"valid_phase_types": PhaseType.aqueousPhase})

        assert not m.comp6._is_phase_valid(m.Liq)
        assert not m.comp6._is_phase_valid(m.Sol)
        assert not m.comp6._is_phase_valid(m.Vap)
        # Generic components are never valid in the aqueous phase
        assert not m.comp6._is_phase_valid(m.Aqu)
        assert not m.comp6._is_phase_valid(m.Phase)
Example #10
0
    def m(self):
        m = ConcreteModel()

        m.meta_object = PropertyClassMetadata()
        m.meta_object.add_default_units({
            'time': pyunits.s,
            'length': pyunits.m,
            'mass': pyunits.kg,
            'amount': pyunits.mol,
            'temperature': pyunits.K})

        def get_metadata(self):
            return m.meta_object
        m.get_metadata = types.MethodType(get_metadata, m)

        m.comp = Component()
        m.comp2 = Component()

        return m
Example #11
0
    def build(self):
        '''
        Callable method for Block construction.
        '''
        super(PhysicalParameterData, self).build()

        self._state_block_class = SaponificationStateBlock

        # Add Phase objects
        self.Liq = LiquidPhase()

        # Add Component objects
        self.H2O = Component()
        self.NaOH = Component()
        self.EthylAcetate = Component()
        self.SodiumAcetate = Component()
        self.Ethanol = Component()

        # Heat capacity of water
        self.cp_mol = Param(mutable=False,
                            initialize=75.327,
                            doc="Molar heat capacity of water [J/mol.K]",
                            units=units.J / units.mol / units.K)

        # Density of water
        self.dens_mol = Param(mutable=False,
                              initialize=55388.0,
                              doc="Molar density of water [mol/m^3]",
                              units=units.mol / units.m**3)

        # Thermodynamic reference state
        self.pressure_ref = Param(within=PositiveReals,
                                  mutable=True,
                                  default=101325.0,
                                  doc='Reference pressure [Pa]',
                                  units=units.Pa)
        self.temperature_ref = Param(within=PositiveReals,
                                     mutable=True,
                                     default=298.15,
                                     doc='Reference temperature [K]',
                                     units=units.K)
Example #12
0
def test_get_phase_component_set():
    m = ConcreteModel()
    m.p = ParameterBlock()

    m.meta_object = PropertyClassMetadata()
    m.meta_object.add_default_units({
        'time': pyunits.s,
        'length': pyunits.m,
        'mass': pyunits.kg,
        'amount': pyunits.mol,
        'temperature': pyunits.K
    })

    def get_metadata(self):
        return m.meta_object

    m.p.get_metadata = types.MethodType(get_metadata, m.p)

    m.p.p1 = Phase()
    m.p.p2 = Phase()
    m.p.p3 = Phase()
    m.p.a = Component()
    m.p.b = Component()
    m.p.c = Component()

    pc_set = m.p.get_phase_component_set()

    assert isinstance(m.p._phase_component_set, Set)
    assert len(m.p._phase_component_set) == 9
    for v in m.p._phase_component_set:
        assert v[0] in m.p.phase_list
        assert v[1] in m.p.component_list

    assert pc_set is m.p._phase_component_set

    # Check that method returns existing component
    # Delete phase list so that build will fail to make sure it isn't rebuilding
    m.p.del_component(m.p.phase_list)

    assert m.p.get_phase_component_set() is m.p._phase_component_set
Example #13
0
    def test_is_phase_valid_liquid(self, m):
        m.comp3 = Component(
            default={"valid_phase_types": PhaseType.liquidPhase})

        m.Liq = LiquidPhase()
        m.Sol = SolidPhase()
        m.Vap = VaporPhase()
        m.Phase = Phase()

        assert m.comp3._is_phase_valid(m.Liq)
        assert not m.comp3._is_phase_valid(m.Sol)
        assert not m.comp3._is_phase_valid(m.Vap)
        assert not m.comp3._is_phase_valid(m.Phase)
Example #14
0
    def build(self):
        '''
        Callable method for Block construction.
        '''
        super(PhysicalParameterData, self).build()

        self._state_block_class = ThermalOilStateBlock

        # Add Phase objects
        self.Liq = LiquidPhase()

        # Add Component objects
        self.therminol66 = Component()
Example #15
0
    def _make_component_objects(self):
        _log.warning("DEPRECATED: {} appears to be an old-style property "
                     "package. It will be automatically converted to a "
                     "new-style package, however users are strongly encouraged"
                     " to convert their property packages to use phase and "
                     "component objects.".format(self.name))
        for c in self.component_list:
            if hasattr(self, c):
                # An object with this name already exists, raise exception
                raise PropertyPackageError(
                    "{} could not add Component object {} - an object with "
                    "that name already exists.".format(self.name, c))

            self.add_component(
                str(c), Component(default={"_component_list_exists": True}))
Example #16
0
def test_get_phase_component_set_subset():
    m = ConcreteModel()
    m.p = ParameterBlock()

    m.meta_object = PropertyClassMetadata()
    m.meta_object.add_default_units({
        'time': pyunits.s,
        'length': pyunits.m,
        'mass': pyunits.kg,
        'amount': pyunits.mol,
        'temperature': pyunits.K
    })

    def get_metadata(self):
        return m.meta_object

    m.p.get_metadata = types.MethodType(get_metadata, m.p)

    m.p.p1 = Phase()
    m.p.p2 = Phase(default={"component_list": ["a", "b"]})
    m.p.p3 = Phase(default={"component_list": ["c"]})
    m.p.a = Component()
    m.p.b = Component()
    m.p.c = Component()

    phase_comp = {"p1": ["a", "b", "c"], "p2": ["a", "b"], "p3": ["c"]}

    pc_set = m.p.get_phase_component_set()

    assert isinstance(m.p._phase_component_set, Set)
    assert len(m.p._phase_component_set) == 6
    for v in m.p._phase_component_set:
        assert v[0] in phase_comp.keys()
        assert v[1] in phase_comp[v[0]]

    assert pc_set is m.p._phase_component_set
Example #17
0
def test_validate_parameter_block_no_phase_list():
    m = ConcreteModel()
    m.p = ParameterBlock()

    m.meta_object = PropertyClassMetadata()
    m.meta_object.add_default_units({
        'time': pyunits.s,
        'length': pyunits.m,
        'mass': pyunits.kg,
        'amount': pyunits.mol,
        'temperature': pyunits.K
    })

    def get_metadata(self):
        return m.meta_object

    m.p.get_metadata = types.MethodType(get_metadata, m.p)

    m.p.c1 = Component()
    m.p.c2 = Component()

    with pytest.raises(PropertyPackageError,
                       match="Property package p has not defined any Phases."):
        m.p._validate_parameter_block()
Example #18
0
    def build(self):
        """
        Callable method for Block construction.
        """
        super(CoagulationParameterData, self).build()

        self._state_block_class = CoagulationStateBlock

        # phases
        self.Liq = LiquidPhase()

        # components
        self.H2O = Component()
        self.TSS = Component()
        self.TDS = Component()
        self.Sludge = Component()

        #   heat capacity of liquid
        self.cp = Param(mutable=False,
                        initialize=4184,
                        units=pyunits.J / (pyunits.kg * pyunits.K))

        #   reference density of liquid
        self.ref_dens_liq = Param(
            domain=Reals,
            initialize=999.26,
            mutable=True,
            units=pyunits.kg / pyunits.m**3,
            doc="Reference water mass density parameter @ 0 oC and no salts",
        )

        #   change in liquid density with increasing mass fraction of salts/solids
        self.dens_slope = Param(
            domain=Reals,
            initialize=879.04,
            mutable=True,
            units=pyunits.kg / pyunits.m**3,
            doc=
            "Relative increase in liquid density with mass fraction of salts",
        )

        #   adjustment parameters for density change with temperature
        #   Density calculation as a function of temperature and pressure
        #   --------------------------------------------------------------
        #   Engineering Toolbox. Water - Density, Specific Weight, and
        #   Thermal Expansion Coefficients. (2003) https://www.engineeringtoolbox.com/
        #   water-density-specific-weight-d_595.html [Accessed 02-01-2022]
        self.dens_param_A = Param(
            domain=Reals,
            initialize=-2.9335e-6,
            mutable=True,
            units=pyunits.K**-2,
            doc="Density correction parameter A for temperature variation",
        )

        self.dens_param_B = Param(
            domain=Reals,
            initialize=0.001529811,
            mutable=True,
            units=pyunits.K**-1,
            doc="Density correction parameter B for temperature variation",
        )

        self.dens_param_C = Param(
            domain=Reals,
            initialize=0.787973,
            mutable=True,
            units=pyunits.dimensionless,
            doc="Density correction parameter C for temperature variation",
        )

        #   Correction factors for changes in density with changes in pressure
        self.ref_pressure_correction = Param(
            domain=Reals,
            initialize=1.0135,
            mutable=True,
            units=pyunits.dimensionless,
            doc=
            "Density reference correction parameter for changes in pressure",
        )

        self.ref_pressure_slope = Param(
            domain=Reals,
            initialize=4.9582e-10,
            mutable=True,
            units=pyunits.Pa**-1,
            doc="Slope of density change as a function of pressure",
        )

        #   Adjustment for dynamic viscosity as a function of temperature
        #   -------------------------------------------------------------
        #   D.S. Viswananth, G. Natarajan. Data Book on the Viscosity of
        #     Liquids. Hemisphere Publishing Corp. (1989)
        self.mu_A = Param(
            domain=Reals,
            initialize=2.939e-5,
            mutable=True,
            units=pyunits.kg / pyunits.m / pyunits.s,
            doc="Pre-exponential factor for viscosity calculation",
        )

        self.mu_B = Param(
            domain=Reals,
            initialize=507.88,
            mutable=True,
            units=pyunits.K,
            doc="Exponential numerator term for viscosity calculation",
        )

        self.mu_C = Param(
            domain=Reals,
            initialize=149.3,
            mutable=True,
            units=pyunits.K,
            doc="Exponential denominator term for viscosity calculation",
        )

        # ---default scaling---
        self.set_default_scaling("temperature", 1e-2)
        self.set_default_scaling("pressure", 1e-6)
Example #19
0
    def build(self):
        """
        Callable method for Block construction.
        """
        super(WaterParameterData, self).build()

        self._state_block_class = WaterStateBlock

        # components
        self.H2O = Component()

        # phases
        self.Liq = LiquidPhase()
        self.Vap = VaporPhase()
        """ References
        This package was developed from the following references:

        - K.G.Nayar, M.H.Sharqawy, L.D.Banchik, and J.H.Lienhard V, "Thermophysical properties of seawater: A review and
        new correlations that include pressure dependence,"Desalination, Vol.390, pp.1 - 24, 2016.
        doi: 10.1016/j.desal.2016.02.024(preprint)

        - Mostafa H.Sharqawy, John H.Lienhard V, and Syed M.Zubair, "Thermophysical properties of seawater: A review of 
        existing correlations and data,"Desalination and Water Treatment, Vol.16, pp.354 - 380, April 2010.
        (2017 corrections provided at http://web.mit.edu/seawater)
        """

        # Parameters
        # molecular weight
        self.mw_comp = Param(
            self.component_list,
            mutable=False,
            initialize=18.01528e-3,
            units=pyunits.kg / pyunits.mol,
            doc="Molecular weight",
        )

        # Liq mass density parameters, eq. 8 in Sharqawy et al. (2010)
        dens_units = pyunits.kg / pyunits.m**3
        t_inv_units = pyunits.K**-1
        s_inv_units = pyunits.kg / pyunits.g

        self.dens_mass_param_A1 = Var(
            within=Reals,
            initialize=9.999e2,
            units=dens_units,
            doc="Mass density parameter A1",
        )
        self.dens_mass_param_A2 = Var(
            within=Reals,
            initialize=2.034e-2,
            units=dens_units * t_inv_units,
            doc="Mass density parameter A2",
        )
        self.dens_mass_param_A3 = Var(
            within=Reals,
            initialize=-6.162e-3,
            units=dens_units * t_inv_units**2,
            doc="Mass density parameter A3",
        )
        self.dens_mass_param_A4 = Var(
            within=Reals,
            initialize=2.261e-5,
            units=dens_units * t_inv_units**3,
            doc="Mass density parameter A4",
        )
        self.dens_mass_param_A5 = Var(
            within=Reals,
            initialize=-4.657e-8,
            units=dens_units * t_inv_units**4,
            doc="Mass density parameter A5",
        )

        # Vap mass density parameters (approximating using ideal gas)
        self.dens_mass_param_mw = Var(
            within=Reals,
            initialize=18.01528e-3,
            units=pyunits.kg / pyunits.mol,
            doc="Mass density parameter molecular weight",
        )
        self.dens_mass_param_R = Var(
            within=Reals,
            initialize=8.31462618,
            units=pyunits.J / pyunits.mol / pyunits.K,
            doc="Mass density parameter universal gas constant",
        )

        # vapor pressure parameters,  eq. 5 and 6 in Nayar et al.(2016)
        self.pressure_sat_param_psatw_A1 = Var(
            within=Reals,
            initialize=-5.8002206e3,
            units=pyunits.K,
            doc="Vapor pressure of pure water parameter A1",
        )
        self.pressure_sat_param_psatw_A2 = Var(
            within=Reals,
            initialize=1.3914993,
            units=pyunits.dimensionless,
            doc="Vapor pressure of pure water parameter A2",
        )
        self.pressure_sat_param_psatw_A3 = Var(
            within=Reals,
            initialize=-4.8640239e-2,
            units=t_inv_units,
            doc="Vapor pressure of pure water parameter A3",
        )
        self.pressure_sat_param_psatw_A4 = Var(
            within=Reals,
            initialize=4.1764768e-5,
            units=t_inv_units**2,
            doc="Vapor pressure of pure water parameter A4",
        )
        self.pressure_sat_param_psatw_A5 = Var(
            within=Reals,
            initialize=-1.4452093e-8,
            units=t_inv_units**3,
            doc="Vapor pressure of pure water parameter A5",
        )
        self.pressure_sat_param_psatw_A6 = Var(
            within=Reals,
            initialize=6.5459673,
            units=pyunits.dimensionless,
            doc="Vapor pressure of pure water parameter A6",
        )

        # specific enthalpy parameters, eq. 55 and 43 in Sharqawy et al. (2010)
        enth_mass_units = pyunits.J / pyunits.kg

        self.enth_mass_param_A1 = Var(
            within=Reals,
            initialize=141.355,
            units=enth_mass_units,
            doc="Specific enthalpy parameter A1",
        )
        self.enth_mass_param_A2 = Var(
            within=Reals,
            initialize=4202.07,
            units=enth_mass_units * t_inv_units,
            doc="Specific enthalpy parameter A2",
        )
        self.enth_mass_param_A3 = Var(
            within=Reals,
            initialize=-0.535,
            units=enth_mass_units * t_inv_units**2,
            doc="Specific enthalpy parameter A3",
        )
        self.enth_mass_param_A4 = Var(
            within=Reals,
            initialize=0.004,
            units=enth_mass_units * t_inv_units**3,
            doc="Specific enthalpy parameter A4",
        )
        # self.enth_mass_param_B1 = Var(
        #     within=Reals, initialize=-2.348e4, units=enth_mass_units,
        #     doc='Specific enthalpy parameter B1')
        # self.enth_mass_param_B2 = Var(
        #     within=Reals, initialize=3.152e5, units=enth_mass_units,
        #     doc='Specific enthalpy parameter B2')
        # self.enth_mass_param_B3 = Var(
        #     within=Reals, initialize=2.803e6, units=enth_mass_units,
        #     doc='Specific enthalpy parameter B3')
        # self.enth_mass_param_B4 = Var(
        #     within=Reals, initialize=-1.446e7, units=enth_mass_units,
        #     doc='Specific enthalpy parameter B4')
        # self.enth_mass_param_B5 = Var(
        #     within=Reals, initialize=7.826e3, units=enth_mass_units * t_inv_units,
        #     doc='Specific enthalpy parameter B5')
        # self.enth_mass_param_B6 = Var(
        #     within=Reals, initialize=-4.417e1, units=enth_mass_units * t_inv_units**2,
        #     doc='Specific enthalpy parameter B6')
        # self.enth_mass_param_B7 = Var(
        #     within=Reals, initialize=2.139e-1, units=enth_mass_units * t_inv_units**3,
        #     doc='Specific enthalpy parameter B7')
        # self.enth_mass_param_B8 = Var(
        #     within=Reals, initialize=-1.991e4, units=enth_mass_units * t_inv_units,
        #     doc='Specific enthalpy parameter B8')
        # self.enth_mass_param_B9 = Var(
        #     within=Reals, initialize=2.778e4, units=enth_mass_units * t_inv_units,
        #     doc='Specific enthalpy parameter B9')
        # self.enth_mass_param_B10 = Var(
        #     within=Reals, initialize=9.728e1, units=enth_mass_units * t_inv_units**2,
        #     doc='Specific enthalpy parameter B10')

        # specific heat parameters from eq (9) in Sharqawy et al. (2010)
        cp_units = pyunits.J / (pyunits.kg * pyunits.K)
        self.cp_phase_param_A1 = Var(
            within=Reals,
            initialize=5.328,
            units=cp_units,
            doc="Specific heat of seawater parameter A1",
        )
        # self.cp_phase_param_A2 = Var(
        #     within=Reals, initialize=-9.76e-2, units=cp_units * s_inv_units,
        #     doc='Specific heat of seawater parameter A2')
        # self.cp_phase_param_A3 = Var(
        #     within=Reals, initialize=4.04e-4, units=cp_units * s_inv_units**2,
        #     doc='Specific heat of seawater parameter A3')
        self.cp_phase_param_B1 = Var(
            within=Reals,
            initialize=-6.913e-3,
            units=cp_units * t_inv_units,
            doc="Specific heat of seawater parameter B1",
        )
        # self.cp_phase_param_B2 = Var(
        #     within=Reals, initialize=7.351e-4, units=cp_units * s_inv_units * t_inv_units,
        #     doc='Specific heat of seawater parameter B2')
        # self.cp_phase_param_B3 = Var(
        #     within=Reals, initialize=-3.15e-6, units=cp_units * s_inv_units**2 * t_inv_units,
        #     doc='Specific heat of seawater parameter B3')
        self.cp_phase_param_C1 = Var(
            within=Reals,
            initialize=9.6e-6,
            units=cp_units * t_inv_units**2,
            doc="Specific heat of seawater parameter C1",
        )
        # self.cp_phase_param_C2 = Var(
        #     within=Reals, initialize=-1.927e-6, units=cp_units * s_inv_units * t_inv_units**2,
        #     doc='Specific heat of seawater parameter C2')
        # self.cp_phase_param_C3 = Var(
        #     within=Reals, initialize=8.23e-9, units=cp_units * s_inv_units**2 * t_inv_units**2,
        #     doc='Specific heat of seawater parameter C3')
        self.cp_phase_param_D1 = Var(
            within=Reals,
            initialize=2.5e-9,
            units=cp_units * t_inv_units**3,
            doc="Specific heat of seawater parameter D1",
        )
        # self.cp_phase_param_D2 = Var(
        #     within=Reals, initialize=1.666e-9, units=cp_units * s_inv_units * t_inv_units**3,
        #     doc='Specific heat of seawater parameter D2')
        # self.cp_phase_param_D3 = Var(
        #     within=Reals, initialize=-7.125e-12, units=cp_units * s_inv_units**2 * t_inv_units**3,
        #     doc='Specific heat of seawater parameter D3')

        # Specific heat parameters for Cp vapor from NIST Webbook
        # Chase, M.W., Jr., NIST-JANAF Themochemical Tables, Fourth Edition, J. Phys. Chem. Ref. Data, Monograph 9, 1998, 1-1951
        self.cp_vap_param_A = Var(
            within=Reals,
            initialize=30.09200 / 18.01528e-3,
            units=cp_units,
            doc="Specific heat of water vapor parameter A",
        )
        self.cp_vap_param_B = Var(
            within=Reals,
            initialize=6.832514 / 18.01528e-3,
            units=cp_units * t_inv_units,
            doc="Specific heat of water vapor parameter B",
        )
        self.cp_vap_param_C = Var(
            within=Reals,
            initialize=6.793435 / 18.01528e-3,
            units=cp_units * t_inv_units**2,
            doc="Specific heat of water vapor parameter C",
        )
        self.cp_vap_param_D = Var(
            within=Reals,
            initialize=-2.534480 / 18.01528e-3,
            units=cp_units * t_inv_units**3,
            doc="Specific heat of water vapor parameter D",
        )
        self.cp_vap_param_E = Var(
            within=Reals,
            initialize=0.082139 / 18.01528e-3,
            units=cp_units * t_inv_units**-2,
            doc="Specific heat of water vapor parameter E",
        )

        # latent heat of pure water parameters from eq. 54 in Sharqawy et al. (2010)
        self.dh_vap_w_param_0 = Var(
            within=Reals,
            initialize=2.501e6,
            units=enth_mass_units,
            doc="Latent heat of pure water parameter 0",
        )
        self.dh_vap_w_param_1 = Var(
            within=Reals,
            initialize=-2.369e3,
            units=cp_units,
            doc="Latent heat of pure water parameter 1",
        )
        self.dh_vap_w_param_2 = Var(
            within=Reals,
            initialize=2.678e-1,
            units=enth_mass_units * t_inv_units**2,
            doc="Latent heat of pure water parameter 2",
        )
        self.dh_vap_w_param_3 = Var(
            within=Reals,
            initialize=-8.103e-3,
            units=enth_mass_units * t_inv_units**3,
            doc="Latent heat of pure water parameter 3",
        )
        self.dh_vap_w_param_4 = Var(
            within=Reals,
            initialize=-2.079e-5,
            units=enth_mass_units * t_inv_units**4,
            doc="Latent heat of pure water parameter 4",
        )

        # traditional parameters are the only Vars currently on the block and should be fixed
        for v in self.component_objects(Var):
            v.fix()

        # ---default scaling---
        self.set_default_scaling("temperature", 1e-2)
        self.set_default_scaling("pressure", 1e-5)
        self.set_default_scaling("dens_mass_phase", 1e-3, index="Liq")
        self.set_default_scaling("dens_mass_phase", 1, index="Vap")
        # self.set_default_scaling('dens_mass_solvent', 1e-3)
        self.set_default_scaling("enth_mass_phase", 1e-5, index="Liq")
        self.set_default_scaling("enth_mass_phase", 1e-6, index="Vap")
        self.set_default_scaling("pressure_sat", 1e-5)
        self.set_default_scaling("cp_phase", 1e-3, index="Liq")
        self.set_default_scaling("cp_phase", 1e-3, index="Vap")
        self.set_default_scaling("dh_vap", 1e-6)
Example #20
0
    def build(self):
        """
        Callable method for Block construction.
        """
        super(CoagulationParameterData, self).build()

        self._state_block_class = CoagulationStateBlock

        # phases
        self.Liq = LiquidPhase()

        # components
        self.H2O = Component()
        self.TSS = Component()
        self.TDS = Component()
        self.Sludge = Component()

        #   heat capacity of liquid
        self.cp = Param(mutable=False,
                        initialize=4184,
                        units=pyunits.J / (pyunits.kg * pyunits.K))

        #   reference density of liquid
        self.ref_dens_liq = Param(
            domain=Reals,
            initialize=999.26,
            mutable=True,
            units=pyunits.kg / pyunits.m**3,
            doc='Reference water mass density parameter @ 0 oC and no salts')

        #   change in liquid density with increasing mass fraction of salts/solids
        self.dens_slope = Param(
            domain=Reals,
            initialize=879.04,
            mutable=True,
            units=pyunits.kg / pyunits.m**3,
            doc=
            'Relative increase in liquid density with mass fraction of salts')

        #   adjustment parameters for density change with temperature
        #   Density calculation as a function of temperature and pressure
        #   --------------------------------------------------------------
        #   Engineering Toolbox. Water - Density, Specific Weight, and
        #   Thermal Expansion Coefficients. (2003) https://www.engineeringtoolbox.com/
        #   water-density-specific-weight-d_595.html [Accessed 02-01-2022]
        self.dens_param_A = Param(
            domain=Reals,
            initialize=-2.9335E-6,
            mutable=True,
            units=pyunits.K**-2,
            doc='Density correction parameter A for temperature variation')

        self.dens_param_B = Param(
            domain=Reals,
            initialize=0.001529811,
            mutable=True,
            units=pyunits.K**-1,
            doc='Density correction parameter B for temperature variation')

        self.dens_param_C = Param(
            domain=Reals,
            initialize=0.787973,
            mutable=True,
            units=pyunits.dimensionless,
            doc='Density correction parameter C for temperature variation')

        #   Correction factors for changes in density with changes in pressure
        self.ref_pressure_correction = Param(
            domain=Reals,
            initialize=1.0135,
            mutable=True,
            units=pyunits.dimensionless,
            doc='Density reference correction parameter for changes in pressure'
        )

        self.ref_pressure_slope = Param(
            domain=Reals,
            initialize=4.9582E-10,
            mutable=True,
            units=pyunits.Pa**-1,
            doc='Slope of density change as a function of pressure')

        #   reference density of solids
        self.ref_dens_sol = Param(
            domain=Reals,
            initialize=2600,
            mutable=True,
            units=pyunits.kg / pyunits.m**3,
            doc='Reference dry solid mass density parameter')

        # ---default scaling---
        self.set_default_scaling('temperature', 1e-2)
        self.set_default_scaling('pressure', 1e-6)
Example #21
0
    def build(self):
        super(_Parameters, self).build()

        self.p1 = Phase()
        self.c1 = Component()