def test_inerts_dependent_w_multi_phase(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() # Change elemental composition to introduce dependency m.fs.properties.element_comp = { "c1": { "H": 0, "He": 0, "Li": 3 }, "c2": { "H": 4, "He": 5, "Li": 0 } } m.fs.unit = GibbsReactor(default={ "property_package": m.fs.properties, "inert_species": ["c1"] }) assert isinstance(m.fs.unit.inert_species_balance, Constraint) assert len(m.fs.unit.inert_species_balance) == 2 assert m.fs.unit.inert_species_balance[0, "p1", "c1"] != Constraint.Skip assert m.fs.unit.inert_species_balance[0, "p2", "c1"] != Constraint.Skip assert isinstance(m.fs.unit.gibbs_minimization, Constraint) assert len(m.fs.unit.gibbs_minimization) == 2
def test_config(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = GibbsReactor(default={"property_package": m.fs.properties}) # Check unit config arguments assert len(m.fs.unit.config) == 9 assert not m.fs.unit.config.dynamic assert not m.fs.unit.config.has_holdup assert m.fs.unit.config.energy_balance_type == \ EnergyBalanceType.useDefault assert m.fs.unit.config.momentum_balance_type == \ MomentumBalanceType.pressureTotal assert not m.fs.unit.config.has_heat_transfer assert not m.fs.unit.config.has_pressure_change assert m.fs.unit.config.property_package is m.fs.properties assert m.fs.unit.config.inert_species == [] assert isinstance(m.fs.unit.gibbs_minimization, Constraint) assert len(m.fs.unit.gibbs_minimization) == 4 assert not hasattr(m.fs.unit, "inert_species_balance")
def methane(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = MethaneCombustionParameterBlock() m.fs.unit = GibbsReactor( default={ "property_package": m.fs.properties, "has_heat_transfer": True, "has_pressure_change": True }) m.fs.unit.inlet.flow_mol[0].fix(230.0) m.fs.unit.inlet.mole_frac_comp[0, "H2"].fix(0.0435) m.fs.unit.inlet.mole_frac_comp[0, "N2"].fix(0.6522) m.fs.unit.inlet.mole_frac_comp[0, "O2"].fix(0.1739) m.fs.unit.inlet.mole_frac_comp[0, "CO2"].fix(1e-5) m.fs.unit.inlet.mole_frac_comp[0, "CH4"].fix(0.1304) m.fs.unit.inlet.mole_frac_comp[0, "CO"].fix(1e-5) m.fs.unit.inlet.mole_frac_comp[0, "H2O"].fix(1e-5) m.fs.unit.inlet.mole_frac_comp[0, "NH3"].fix(1e-5) m.fs.unit.inlet.temperature[0].fix(1500.0) m.fs.unit.inlet.pressure[0].fix(101325.0) m.fs.unit.outlet.temperature[0].fix(2844.38) m.fs.unit.deltaP.fix(0) return m
def test_inerts_dependent_w_single_phase(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() # Set phase list to only have 1 phase m.fs.properties.phase_list = ["p1"] # Change elemental composition to introduce dependency m.fs.properties.element_comp = { "c1": { "H": 0, "He": 0, "Li": 3 }, "c2": { "H": 4, "He": 5, "Li": 0 } } m.fs.unit = GibbsReactor(default={ "property_package": m.fs.properties, "inert_species": ["c1"] }) assert isinstance(m.fs.unit.inert_species_balance, Constraint) assert len(m.fs.unit.inert_species_balance) == 0 assert (0, "p1", "c1") not in m.fs.unit.inert_species_balance assert isinstance(m.fs.unit.gibbs_minimization, Constraint) assert len(m.fs.unit.gibbs_minimization) == 1
def test_invalid_inert(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() with pytest.raises(ConfigurationError, match="fs.unit invalid component in inert_species " "argument. foo is not in the property package " "component list."): m.fs.unit = GibbsReactor(default={"property_package": m.fs.properties, "inert_species": ["foo"]})
def methane(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = MethaneCombustionParameterBlock() m.fs.unit = GibbsReactor( default={ "property_package": m.fs.properties, "has_heat_transfer": True, "has_pressure_change": True }) return m
def test_inerts(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = GibbsReactor(default={"property_package": m.fs.properties, "inert_species": ["c1"]}) assert isinstance(m.fs.unit.inert_species_balance, Constraint) assert len(m.fs.unit.inert_species_balance) == 2 assert m.fs.unit.inert_species_balance[0, "p1", "c1"] != Constraint.Skip assert m.fs.unit.inert_species_balance[0, "p2", "c1"] != Constraint.Skip assert isinstance(m.fs.unit.gibbs_minimization, Constraint) assert len(m.fs.unit.gibbs_minimization) == 2
def test_config(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = GibbsReactor(default={"property_package": m.fs.properties}) # Check unit config arguments assert len(m.fs.unit.config) == 8 assert not m.fs.unit.config.dynamic assert not m.fs.unit.config.has_holdup assert m.fs.unit.config.energy_balance_type == \ EnergyBalanceType.useDefault assert m.fs.unit.config.momentum_balance_type == \ MomentumBalanceType.pressureTotal assert not m.fs.unit.config.has_heat_transfer assert not m.fs.unit.config.has_pressure_change assert m.fs.unit.config.property_package is m.fs.properties