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_phase_comp": ( 0, 0.1, 0.2, pyunits.kmol/pyunits.s), "temperature": (522, 621, 720, pyunits.degR), "pressure": (1, 3, 5, pyunits.bar)}, "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": 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) with pytest.raises( ConfigurationError, match="props\[1\] - found unexpected state_bounds key " "mole_frac_comp. Please ensure bounds are provided only for " "expected state variables and that you have typed the " "variable names correctly."): define_state(m.props[1])
def test_always_flash(self, frame): define_state(frame.props[1]) assert not frame.props[1].always_flash