def test_costing_FH_solve(): m = pyo.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.get_costing() m.fs.costing.CE_index = 550 # for testing only m.fs.unit = pyo.Block() m.fs.unit.heat_duty = pyo.Var(initialize=1e6, units=pyo.units.BTU / pyo.units.hr) m.fs.unit.pressure = pyo.Var(initialize=1e5, units=pyo.units.psi) m.fs.unit.costing = pyo.Block() m.fs.unit.heat_duty.fix(18390000) # Btu/hr m.fs.unit.pressure.fix(700) # psig cs.fired_heater_costing(m.fs.unit.costing, fired_type='fuel', Mat_factor='stain_steel', ref_parameter_pressure=m.fs.unit.pressure, ref_parameter_heat_duty=m.fs.unit.heat_duty) 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) # initialize costing block costing.initialize(m.fs.unit.costing) assert (pytest.approx(pyo.value(m.fs.unit.costing.purchase_cost), abs=1e-2) == 962795.521) results = solver.solve(m, tee=False) # Check for optimal solution assert results.solver.termination_condition == \ pyo.TerminationCondition.optimal assert results.solver.status == pyo.SolverStatus.ok assert (pytest.approx(pyo.value(m.fs.unit.costing.purchase_cost), abs=1e-2) == 962795.521) # Example 22.1 Ref Book
def test_costing_FH_build(): m = pyo.ConcreteModel() m.fs = FlowsheetBlock(default={"dynamic": False}) m.fs.get_costing() m.fs.costing.CE_index = 550 # for testing only m.fs.unit = pyo.Block() m.fs.unit.heat_duty = pyo.Var(initialize=1e6) m.fs.unit.pressure = pyo.Var(initialize=1e5) m.fs.unit.costing = pyo.Block() m.fs.unit.heat_duty.fix(18390000) # Btu/hr m.fs.unit.pressure.fix(700) # psig cs.fired_heater_costing(m.fs.unit.costing, fired_type='fuel', Mat_factor='stain_steel', ref_parameter_pressure=m.fs.unit.pressure, ref_parameter_heat_duty=m.fs.unit.heat_duty) 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)