def frame(self): m = ConcreteModel() # Create a dummy parameter block m.params = Block() # Add necessary parameters to parameter block m.params.config = ConfigBlock() m.params.config.declare("state_bounds", ConfigValue(default={})) m.params.phase_list = Set(initialize=["a", "b"], ordered=True) m.params.component_list = Set(initialize=[1, 2, 3], ordered=True) # 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 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) }, "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) 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)
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])
def test_always_flash(self, frame): define_state(frame.props[1]) assert frame.props[1].always_flash