def sapon(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = SaponificationParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.pump, "compressor": False }) m.fs.unit.inlet.flow_vol[0].fix(1e-3) m.fs.unit.inlet.temperature[0].fix(320) m.fs.unit.inlet.pressure[0].fix(101325) m.fs.unit.inlet.conc_mol_comp[0, "H2O"].fix(55388.0) m.fs.unit.inlet.conc_mol_comp[0, "NaOH"].fix(100.0) m.fs.unit.inlet.conc_mol_comp[0, "EthylAcetate"].fix(100.0) m.fs.unit.inlet.conc_mol_comp[0, "SodiumAcetate"].fix(0.0) m.fs.unit.inlet.conc_mol_comp[0, "Ethanol"].fix(0.0) m.fs.unit.deltaP.fix(-20000) m.fs.unit.efficiency_pump.fix(0.9) iscale.calculate_scaling_factors(m) return m
def test_compressor(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "compressor": True }) # set inputs m.fs.unit.inlet.flow_mol[0].fix(10000) m.fs.unit.inlet.enth_mol[0].fix(4000) m.fs.unit.inlet.pressure[0].fix(101325) m.fs.unit.deltaP.fix(500000) m.fs.unit.efficiency_isentropic.fix(0.9) iscale.calculate_scaling_factors(m) assert degrees_of_freedom(m) == 0 m.fs.unit.get_costing(mover_type="compressor") m.fs.unit.initialize() assert m.fs.unit.costing.purchase_cost.value == \ pytest.approx(334598.679, abs=1e-3) assert_units_consistent(m.fs.unit) solver.solve(m, tee=True) assert m.fs.unit.costing.purchase_cost.value == \ pytest.approx(334598.679, abs=1e-3)
def test_pump(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.pump, "compressor": True }) # set inputs m.fs.unit.inlet.flow_mol[0].fix(10000) m.fs.unit.inlet.enth_mol[0].fix(4000) m.fs.unit.inlet.pressure[0].fix(101325) m.fs.unit.deltaP.fix(50000) m.fs.unit.efficiency_pump.fix(0.9) iscale.calculate_scaling_factors(m) assert degrees_of_freedom(m) == 0 m.fs.unit.get_costing(pump_type='centrifugal', Mat_factor='nickel', pump_motor_type_factor='enclosed') m.fs.unit.initialize() # check costing block initialization assert m.fs.unit.costing.purchase_cost.value == \ pytest.approx(70115.019, abs=1e-2) assert_units_consistent(m.fs.unit) solver.solve(m, tee=True) assert m.fs.unit.costing.purchase_cost.value == \ pytest.approx(70115.0, 1e-5)
def get_initialized_model(self): """ Returns an initialized model for the PressureChanger unit model convergence evaluation Returns ------- Pyomo model : returns a pyomo model of the PressureChanger unit """ m = pe.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.props = pp.Iapws95ParameterBlock() m.fs.pc = PressureChanger( default={ "property_package": m.fs.props, "thermodynamic_assumption": 'isothermal' }) m.fs.pc.deltaP.fix(-1e3) m.fs.pc.inlet[:].flow_mol.fix(27.5e3) m.fs.pc.inlet[:].enth_mol.fix(4000) m.fs.pc.inlet[:].pressure.fix(2e6) init_state = {"flow_mol": 27.5e3, "pressure": 2e6, "enth_mol": 4000} m.fs.pc.initialize(state_args=init_state, outlvl=0) # Create a solver for initialization opt = self.get_solver() opt.solve(m) # return the initialized model return m
def model(): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": True}) m.fs.params = PropertyInterrogatorBlock() m.fs.P01 = PressureChanger( default={ "property_package": m.fs.params, "thermodynamic_assumption": ThermodynamicAssumption.isentropic }) m.fs.HX02 = HeatExchanger1D( default={ "shell_side": { "property_package": m.fs.params }, "tube_side": { "property_package": m.fs.params } }) m.fs.F03 = Flash(default={"property_package": m.fs.params}) return m
def test_turbine(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "compressor": False }) # set inputs m.fs.unit.inlet.flow_mol[0].fix(1000) # mol/s Tin = 500 # K Pin = 1000000 # Pa Pout = 700000 # Pa hin = iapws95.htpx(Tin * units.K, Pin * units.Pa) m.fs.unit.inlet.enth_mol[0].fix(hin) m.fs.unit.inlet.pressure[0].fix(Pin) m.fs.unit.deltaP.fix(Pout - Pin) m.fs.unit.efficiency_isentropic.fix(0.9) m.fs.unit.initialize() m.fs.unit.get_costing() calculate_variable_from_constraint(m.fs.unit.costing.purchase_cost, m.fs.unit.costing.cp_cost_eq) assert degrees_of_freedom(m) == 0 assert_units_consistent(m.fs.unit) solver.solve(m, tee=True) assert m.fs.unit.costing.purchase_cost.value ==\ pytest.approx(213199, 1e-5)
def test_dynamic_build(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": True}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = PressureChanger( default={"property_package": m.fs.properties}) assert hasattr(m.fs.unit, "volume")
def test_isentropic_material_balances_none(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() with pytest.raises(BalanceTypeNotSupportedError): m.fs.unit = PressureChanger(default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "material_balance_type": MaterialBalanceType.none})
def test_compressor_fan(): m = pyo.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() # Add property packages to flowsheet library m.fs.prop_fluegas = FlueGasParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.prop_fluegas, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "compressor": True }) # # FLUE GAS Inlet from Primary Superheater FGrate = 425.813998 # mol/s # # Use FG molar composition to set component flow rates (baseline report) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["H2O"].\ fix(FGrate*8.69/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["CO2"].\ fix(FGrate*14.49/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["N2"].\ fix(FGrate*74.34/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["O2"].\ fix(FGrate*2.47/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["NO"].\ fix(FGrate*0.0006) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["SO2"]\ .fix(FGrate*0.002) m.fs.unit.control_volume.properties_in[0].temperature.fix(200.335) m.fs.unit.control_volume.properties_in[0].pressure.fix(98658.6) m.fs.unit.deltaP.fix(101325 - 98658.6) m.fs.unit.efficiency_isentropic.fix(0.9) m.fs.unit.get_costing(mover_type='fan') m.fs.unit.initialize() # make sure costing initialized correctly assert (pytest.approx(pyo.value(m.fs.unit.costing.purchase_cost), abs=1e-2) == 22106.9807) assert degrees_of_freedom(m) == 0 # Check unit config arguments assert isinstance(m.fs.unit.costing.purchase_cost, pyo.Var) assert isinstance(m.fs.unit.costing.base_cost_per_unit, pyo.Var) results = solver.solve(m, tee=True) assert results.solver.termination_condition == \ pyo.TerminationCondition.optimal assert results.solver.status == pyo.SolverStatus.ok assert (pytest.approx(pyo.value(m.fs.unit.costing.base_cost), abs=1e-2) == 4543.6428) assert (pytest.approx(pyo.value(m.fs.unit.costing.purchase_cost), abs=1e-2) == 22106.9807)
def test_dynamic_build(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": True, "time_units": units.s}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = PressureChanger( default={"property_package": m.fs.properties}) iscale.calculate_scaling_factors(m) assert hasattr(m.fs.unit, "volume")
def test_pump(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = PressureChanger(default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.pump}) iscale.calculate_scaling_factors(m) assert isinstance(m.fs.unit.fluid_work_calculation, Constraint)
def iapws_turb(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = PressureChanger(default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "compressor": False}) iscale.calculate_scaling_factors(m) return m
def test_adiabatic(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.adiabatic }) iscale.calculate_scaling_factors(m)
def test_adiabatic(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.adiabatic }) assert isinstance(m.fs.unit.adiabatic, Constraint)
def btx(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = BTXParameterBlock(default={"valid_phase": 'Liq'}) m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isothermal }) return m
def test_blower_build_and_solve(): m = pyo.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() # Add property packages to flowsheet library m.fs.prop_fluegas = FlueGasParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.prop_fluegas, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "compressor": True }) # # FLUE GAS Inlet from Primary Superheater FGrate = 8516.27996 # mol/s # # Use FG molar composition to set component flow rates (baseline report) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["H2O"].\ fix(FGrate*8.69/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["CO2"].\ fix(FGrate*14.49/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["N2"].\ fix(FGrate*74.34/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["O2"].\ fix(FGrate*2.47/100) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["NO"].\ fix(FGrate*0.0006) m.fs.unit.control_volume.properties_in[0].flow_mol_comp["SO2"]\ .fix(FGrate*0.002) m.fs.unit.control_volume.properties_in[0].temperature.fix(200.335) m.fs.unit.control_volume.properties_in[0].pressure.fix(99973.98) m.fs.unit.deltaP.fix(144790 - 99973.98) m.fs.unit.efficiency_isentropic.fix(0.9) m.fs.unit.initialize() m.fs.unit.get_costing(mover_type='fan') calculate_variable_from_constraint(m.fs.unit.costing.purchase_cost, m.fs.unit.costing.cp_cost_eq) assert degrees_of_freedom(m) == 0 # Check unit config arguments assert isinstance(m.fs.unit.costing.purchase_cost, pyo.Var) assert isinstance(m.fs.unit.costing.base_cost, pyo.Var) results = solver.solve(m, tee=True) assert results.solver.termination_condition == \ pyo.TerminationCondition.optimal assert results.solver.status == pyo.SolverStatus.ok assert (pytest.approx(pyo.value(m.fs.unit.costing.base_cost), abs=1e-2) == 56026.447) assert (pytest.approx(pyo.value(m.fs.unit.costing.purchase_cost), abs=1e-2) == 272595.280)
def test_isentropic_comp_total_balances(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = PressureChanger(default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "material_balance_type": MaterialBalanceType.componentTotal}) iscale.calculate_scaling_factors(m) assert isinstance(m.fs.unit.state_material_balances, Constraint) assert len(m.fs.unit.state_material_balances) == 2
def sapon(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = SaponificationParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.pump, "compressor": False }) return m
def btx(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = BTXParameterBlock(default={"valid_phase": 'Liq'}) m.fs.unit = PressureChanger(default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isothermal}) m.fs.unit.inlet.flow_mol[0].fix(5) # mol/s m.fs.unit.inlet.temperature[0].fix(365) # K m.fs.unit.inlet.pressure[0].fix(101325) # Pa m.fs.unit.inlet.mole_frac_comp[0, "benzene"].fix(0.5) m.fs.unit.inlet.mole_frac_comp[0, "toluene"].fix(0.5) m.fs.unit.deltaP.fix(50000) iscale.calculate_scaling_factors(m) return m
def iapws(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = PressureChanger(default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "compressor": True}) m.fs.unit.inlet.flow_mol[0].fix(100) m.fs.unit.inlet.enth_mol[0].fix(4000) m.fs.unit.inlet.pressure[0].fix(101325) m.fs.unit.deltaP.fix(50000) m.fs.unit.efficiency_isentropic.fix(0.9) iscale.calculate_scaling_factors(m) return m
def test_compressor(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = iapws95.Iapws95ParameterBlock() m.fs.unit = PressureChanger( default={ "property_package": m.fs.properties, "thermodynamic_assumption": ThermodynamicAssumption.isentropic, "compressor": True }) # set inputs m.fs.unit.inlet.flow_mol[0].fix(10000) m.fs.unit.inlet.enth_mol[0].fix(4000) m.fs.unit.inlet.pressure[0].fix(101325) m.fs.unit.deltaP.fix(500000) m.fs.unit.efficiency_isentropic.fix(0.9) iscale.set_scaling_factor(m.fs.unit.control_volume.work[0], 1e-5) iscale.calculate_scaling_factors(m) assert degrees_of_freedom(m) == 0 m.fs.unit.get_costing(mover_type="compressor") m.fs.unit.initialize() results = solver.solve(m) # Check for optimal solution assert results.solver.termination_condition == \ TerminationCondition.optimal assert results.solver.status == SolverStatus.ok assert value(m.fs.unit.control_volume.work[0]) == \ pytest.approx(101410.4, rel=1e-5) assert m.fs.unit.costing.purchase_cost.value == \ pytest.approx(334598, rel=1e-5) assert_units_consistent(m.fs.unit) solver.solve(m, tee=True) assert m.fs.unit.costing.purchase_cost.value == \ pytest.approx(334598, rel=1e-5)
def test_config(self): m = ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.properties = PhysicalParameterTestBlock() m.fs.unit = PressureChanger( default={"property_package": m.fs.properties}) # Check unit config arguments assert len(m.fs.unit.config) == 12 assert m.fs.unit.config.material_balance_type == \ MaterialBalanceType.useDefault 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_phase_equilibrium assert m.fs.unit.config.compressor assert m.fs.unit.config.thermodynamic_assumption == \ ThermodynamicAssumption.isothermal assert m.fs.unit.config.property_package is m.fs.properties