def test_pipe_vaporphase(): m = pyo.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = WaterPipe(default={ "dynamic": False, "property_package": m.fs.properties, "has_holdup": True, "has_heat_transfer": False, "has_pressure_change": True, "water_phase": 'Vap', "contraction_expansion_at_end": 'None' }) m.fs.unit.diameter.fix(0.04) m.fs.unit.length.fix(40) m.fs.unit.number_of_pipes.fix(100) m.fs.unit.elevation_change.fix(25) m.fs.unit.fcorrection_dp.fix(1.0) state_args = {'flow_mol': 10000, 'pressure': 3.6e6, 'enth_mol': 53942} initialization_tester(m, dof=3, state_args=state_args) m.fs.unit.inlet.enth_mol.fix() m.fs.unit.inlet.flow_mol.fix() m.fs.unit.inlet.pressure.fix() assert degrees_of_freedom(m) == 0 results = solver.solve(m, tee=True) # Check for optimal solution assert results.solver.termination_condition == \ pyo.TerminationCondition.optimal assert results.solver.status == pyo.SolverStatus.ok assert pyo.value(m.fs.unit.control_volume.properties_in[0].vapor_frac) == 1 # check material balance assert (pytest.approx(pyo.value(m.fs.unit.control_volume.properties_in[0]. flow_mol - m.fs.unit.control_volume. properties_out[0].flow_mol), abs=1e-3) == 0) # pressure drop assert (pytest.approx(-539105.588, abs=1e-3) == pyo.value(m.fs.unit. deltaP[0])) # check energy balance assert (pytest.approx( pyo.value(m.fs.unit.control_volume.properties_in[0].enth_mol - m.fs.unit.control_volume.properties_out[0].enth_mol), abs=1e-3) == 0)
def build_unit(): m = pyo.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = WaterPipe(default={ "dynamic": False, "property_package": m.fs.properties, "has_holdup": True, "has_heat_transfer": False, "has_pressure_change": True, "water_phase": 'Liq', "contraction_expansion_at_end": 'contraction' }) return m
def test_pipe_expansion(): m = pyo.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = WaterPipe(default={ "dynamic": False, "property_package": m.fs.properties, "has_holdup": True, "has_heat_transfer": False, "has_pressure_change": True, "water_phase": 'Liq', "contraction_expansion_at_end": 'expansion' }) m.fs.unit.diameter.fix(0.04) m.fs.unit.length.fix(40) m.fs.unit.number_of_pipes.fix(100) m.fs.unit.elevation_change.fix(25) m.fs.unit.area_ratio.fix(0.5) m.fs.unit.fcorrection_dp.fix(1.0) state_args = {'flow_mol': 10000, 'pressure': 1.3e7, 'enth_mol': 18000} initialization_tester(m, dof=3, state_args=state_args) m.fs.unit.inlet.enth_mol.fix() m.fs.unit.inlet.flow_mol.fix() m.fs.unit.inlet.pressure.fix() assert degrees_of_freedom(m) == 0 results = solver.solve(m, tee=True) # Check for optimal solution assert pyo.check_optimal_termination(results) # check material balance assert (pytest.approx(pyo.value(m.fs.unit.control_volume.properties_in[0]. flow_mol - m.fs.unit.control_volume. properties_out[0].flow_mol), abs=1e-3) == 0) # pressure drop assert (pytest.approx(-224306.548, abs=1e-3) == pyo.value(m.fs.unit. deltaP[0])) # check energy balance assert (pytest.approx( pyo.value(m.fs.unit.control_volume.properties_in[0].enth_mol - m.fs.unit.control_volume.properties_out[0].enth_mol), abs=1e-3) == 0)