def test_build_phase_equilibrium(): m = ConcreteModel() m.fs = Flowsheet(default={"dynamic": False}) m.fs.pp = PhysicalParameterTestBlock() m.fs.mix = Mixer(default={"property_package": m.fs.pp, "has_phase_equilibrium": True}) assert isinstance(m.fs.mix.material_mixing_equations, Constraint) assert len(m.fs.mix.material_mixing_equations) == 4 assert hasattr(m.fs.mix, "phase_equilibrium_idx_ref") assert isinstance(m.fs.mix.phase_equilibrium_generation, Var) assert isinstance(m.fs.mix.enthalpy_mixing_equations, Constraint) assert len(m.fs.mix.enthalpy_mixing_equations) == 1 assert isinstance(m.fs.mix.inlet_idx, Set) assert isinstance(m.fs.mix.minimum_pressure, Var) assert len(m.fs.mix.minimum_pressure) == 2 assert isinstance(m.fs.mix.eps_pressure, Param) assert isinstance(m.fs.mix.minimum_pressure_constraint, Constraint) assert len(m.fs.mix.minimum_pressure) == 2 assert isinstance(m.fs.mix.mixture_pressure, Constraint) assert isinstance(m.fs.mix.inlet_1, Port) assert isinstance(m.fs.mix.inlet_2, Port) assert isinstance(m.fs.mix.outlet, Port)
def sapon(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = SaponificationParameterBlock() m.fs.unit = Mixer(default={"property_package": m.fs.properties}) return m
def btx(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = BTXParameterBlock(default={"valid_phase": 'Liq'}) m.fs.unit = Mixer(default={"property_package": m.fs.properties}) return m
def test_report(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.pp = PhysicalParameterTestBlock() m.fs.sb = TestStateBlock(m.fs.time, default={"parameters": m.fs.pp}) m.fs.mix = Mixer(default={"property_package": m.fs.pp}) m.fs.mix.report()
def test_model_checks(): m = ConcreteModel() m.fs = Flowsheet(default={"dynamic": False}) m.fs.pp = PhysicalParameterTestBlock() m.fs.mix = Mixer(default={ "property_package": m.fs.pp, "momentum_mixing_type": MomentumMixingType.equality}) m.fs.mix.model_check() assert m.fs.mix.inlet_1_state[0].check is True assert m.fs.mix.inlet_2_state[0].check is True assert m.fs.mix.mixed_state[0].check is True
def iapws(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = Mixer( default={ "property_package": m.fs.properties, "material_balance_type": MaterialBalanceType.componentTotal, "momentum_mixing_type": MomentumMixingType.equality }) return m
def test_build_phase_pressure_equality(): m = ConcreteModel() m.fs = Flowsheet(default={"dynamic": False}) m.fs.pp = PhysicalParameterTestBlock() m.fs.mix = Mixer(default={ "property_package": m.fs.pp, "momentum_mixing_type": MomentumMixingType.equality}) assert isinstance(m.fs.mix.material_mixing_equations, Constraint) assert len(m.fs.mix.material_mixing_equations) == 4 assert isinstance(m.fs.mix.enthalpy_mixing_equations, Constraint) assert len(m.fs.mix.enthalpy_mixing_equations) == 1 assert isinstance(m.fs.mix.pressure_equality_constraints, Constraint) assert len(m.fs.mix.pressure_equality_constraints) == 2 assert isinstance(m.fs.mix.inlet_1, Port) assert isinstance(m.fs.mix.inlet_2, Port) assert isinstance(m.fs.mix.outlet, Port)
def test_initialize(): m = ConcreteModel() m.fs = Flowsheet(default={"dynamic": False}) m.fs.pp = PhysicalParameterTestBlock() m.fs.sb = TestStateBlock(m.fs.time, default={"parameters": m.fs.pp}) m.fs.mix = Mixer(default={ "property_package": m.fs.pp, "mixed_state_block": m.fs.sb }) # Change one inlet pressure to check initialization calculations m.fs.mix.inlet_1_state[0].pressure = 8e4 f = m.fs.mix.initialize(hold_state=True) assert m.fs.mix.inlet_1_state[0].init_test is True assert m.fs.mix.inlet_2_state[0].init_test is True assert m.fs.sb[0].init_test is True assert m.fs.mix.inlet_1_state[0].hold_state is True assert m.fs.mix.inlet_2_state[0].hold_state is True assert m.fs.sb[0].hold_state is False assert m.fs.sb[0].flow_mol_phase_comp["p1", "c1"].value == 2 assert m.fs.sb[0].flow_mol_phase_comp["p1", "c2"].value == 2 assert m.fs.sb[0].flow_mol_phase_comp["p2", "c1"].value == 2 assert m.fs.sb[0].flow_mol_phase_comp["p2", "c2"].value == 2 assert m.fs.sb[0].enth_mol_phase["p1"].value == 2 assert m.fs.sb[0].enth_mol_phase["p2"].value == 2 assert m.fs.sb[0].pressure.value == 8e4 m.fs.mix.release_state(flags=f) assert m.fs.mix.inlet_1_state[0].hold_state is False assert m.fs.mix.inlet_2_state[0].hold_state is False assert m.fs.sb[0].hold_state is False