Exemple #1
0
    def frame(self):
        m = ConcreteModel()

        m.params = DummyParameterBlock(default={
                "components": {"c1": {}, "c2": {}, "c3": {}},
                "phases": {
                    "a": {"equation_of_state": dummy_eos},
                    "b": {"equation_of_state": dummy_eos}},
                "state_definition": modules[__name__],
                "pressure_ref": 1e5,
                "temperature_ref": 300,
                "state_bounds": {
                    "flow_mol": (0, 0.1, 0.2, pyunits.kmol/pyunits.s),
                    "temperature": (522, 621, 720, pyunits.degR),
                    "pressure": (1, 3, 5, pyunits.bar),
                    "enth_mol": (0, 0.5, 1, pyunits.kJ/pyunits.mol)},
                "base_units": {"time": pyunits.s,
                               "length": pyunits.m,
                               "mass": pyunits.kg,
                               "amount": pyunits.mol,
                               "temperature": pyunits.K}})

        # Create a dummy state block
        m.props = Block([1])
        m.props[1].config = ConfigBlock()
        m.props[1].config.declare("defined_state", ConfigValue(default=False))
        add_object_reference(m.props[1], "params", m.params)

        # Add necessary variables that would be built by other methods
        m.props[1].dens_mol_phase = Var(m.params.phase_list, initialize=1)
        m.props[1].enth_mol_phase = Var(m.params.phase_list, initialize=1)

        define_state(m.props[1])

        return m
    def test_mole_frac(self, caplog):
        m = ConcreteModel()

        caplog.set_level(
            idaeslog.WARNING,
            logger=("idaes.generic_models.properties.core."))

        m.params = DummyParameterBlock(default={
                "components": {"c1": {}, "c2": {}, "c3": {}},
                "phases": {
                    "p1": {"equation_of_state": DummyEoS}},
                "state_definition": modules[__name__],
                "pressure_ref": 1e5,
                "temperature_ref": 300,
                "base_units": {"time": pyunits.s,
                               "length": pyunits.m,
                               "mass": pyunits.kg,
                               "amount": pyunits.mol,
                               "temperature": pyunits.K},
                "state_bounds": {"mole_frac_comp": (None, None, None)}})

        # Build state block
        m.props = m.params.build_state_block(
            [1], default={"defined_state": False})
        m.props[1].enth_mol_phase["p1"] = 1

        define_state(m.props[1])

        assert ("props[1] - found state_bounds argument for mole_frac_comp."
                " Mole fraction bounds are set automatically and "
                "this argument will be ignored." in caplog.text)
Exemple #3
0
    def test_mole_frac(self, caplog):
        m = ConcreteModel()

        caplog.set_level(idaeslog.WARNING,
                         logger=("idaes.generic_models.properties.core."))

        m.params = DummyParameterBlock(
            default={
                "components": {
                    "c1": {},
                    "c2": {},
                    "c3": {}
                },
                "phases": {
                    "p1": {
                        "equation_of_state": dummy_eos
                    }
                },
                "state_definition": modules[__name__],
                "pressure_ref": 1e5,
                "temperature_ref": 300,
                "base_units": {
                    "time": pyunits.s,
                    "length": pyunits.m,
                    "mass": pyunits.kg,
                    "amount": pyunits.mol,
                    "temperature": pyunits.K
                },
                "state_bounds": {
                    "mole_frac_comp": (None, None, None)
                }
            })

        # Create a dummy state block
        m.props = Block([1])
        m.props[1].config = ConfigBlock()
        m.props[1].config.declare("defined_state", ConfigValue(default=False))
        add_object_reference(m.props[1], "params", m.params)
        m.props[1].enth_mol_phase = {"p1": 1}

        define_state(m.props[1])

        assert ("props[1] - found state_bounds argument for mole_frac_comp."
                " Mole fraction bounds are set automatically and "
                "this argument will be ignored." in caplog.text)
Exemple #4
0
    def test_bad_name(self):
        m = ConcreteModel()

        m.params = DummyParameterBlock(
            default={
                "components": {
                    "c1": {},
                    "c2": {},
                    "c3": {}
                },
                "phases": {
                    "p1": {
                        "equation_of_state": dummy_eos
                    }
                },
                "state_definition": modules[__name__],
                "pressure_ref": 1e5,
                "temperature_ref": 300,
                "base_units": {
                    "time": pyunits.s,
                    "length": pyunits.m,
                    "mass": pyunits.kg,
                    "amount": pyunits.mol,
                    "temperature": pyunits.K
                },
                "state_bounds": {
                    "foo": (None, None, None)
                }
            })

        # Create a dummy state block
        m.props = Block([1])
        m.props[1].config = ConfigBlock()
        m.props[1].config.declare("defined_state", ConfigValue(default=False))
        add_object_reference(m.props[1], "params", m.params)

        with pytest.raises(
                ConfigurationError,
                match="props\[1\] - found unexpected state_bounds key foo. "
                "Please ensure bounds are provided only for expected state "
                "variables and that you have typed the variable names "
                "correctly."):
            define_state(m.props[1])
Exemple #5
0
    def test_always_flash(self, frame):
        define_state(frame.props[1])

        assert frame.props[1].always_flash