Structured Flowsheet Example#
The Structured Flowsheet subpackage, in idaes.core.util.structfs, provides a way to consistently structure flowsheets and then functions to help manipulate them interactively or from an API.
Author: Dan Gunter, LBNL
Imports#
[2]:
# Import the 'FS' structured flowsheet wrapper
from flash_flowsheet import FS
Solve the square problem#
Run the solver#
[3]:
# solve the square problem (up to 'solve_initial')
print("Run steps:")
print("\n".join(FS.list_steps()))
print("=" * 40)
FS.run_steps(last="solve_initial")
Run steps:
build
set_operating_conditions
initialize
set_solver
solve_initial
solve_optimization
========================================
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_in: Initialization Step 1 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_in: Initialization Step 2 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_in: Initialization Step 3 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_in: Initialization Step 4 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_in: Initialization Step 5 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_out: Initialization Step 1 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_out: Initialization Step 2 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_out: Initialization Step 3 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_out: Initialization Step 4 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_out: Initialization Step 5 optimal - Optimal Solution Found.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_out: State Released.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume: Initialization Complete
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash.control_volume.properties_in: State Released.
2025-12-06 05:31:08 [INFO] idaes.init.fs.flash: Initialization Complete: optimal - Optimal Solution Found
Show results#
[3]:
print(FS.results)
Problem:
- Lower bound: -.inf
Upper bound: .inf
Number of objectives: 1
Number of constraints: 41
Number of variables: 41
Sense: unknown
Solver:
- Status: ok
Message: Ipopt 3.13.2\x3a Optimal Solution Found
Termination condition: optimal
Id: 0
Error rc: 0
Time: 0.005049467086791992
Solution:
- number of solutions: 0
number of solutions displayed: 0
Show timings#
[4]:
FS.timings
Time per step:
build : 0.022 14.5%
set_operating_conditions : 0.000 0.1%
initialize : 0.111 74.7%
set_solver : 0.000 0.0%
solve_initial : 0.016 10.7%
Total time: 0.151 s
Show degrees of freedom#
[5]:
FS.dof
Degrees of freedom: 0
Degrees of freedom after steps:
build:
fs : 7
fs.flash : 2
fs.flash.control_volume : 7
fs.flash.split : 0
fs.properties : 0
fs.properties.Liq : 0
fs.properties.Vap : 0
fs.properties.benzene : 0
fs.properties.toluene : 0
solve_initial:
fs : 0
fs.flash : 0
fs.flash.control_volume : 0
fs.flash.split : 0
fs.properties : 0
fs.properties.Liq : 0
fs.properties.Vap : 0
fs.properties.benzene : 0
fs.properties.toluene : 0
Solve optimization#
[6]:
# unfix the inlet temperature
temp = FS.model.fs.flash.inlet.temperature[0]
print(f"Before: {temp.value}")
temp.free()
# solve again
FS.run_steps(first="solve_optimization")
# look at new value
print(f"After : {temp.value}")
Before: 368
After : 368.85306111169916
Show new degrees of freedom#
Putting the name of the step as an additional attribute will print a summary of the DoF for that step only.
[7]:
FS.dof.solve_optimization
Degrees of freedom: 5
fs : 1
fs.flash : 0
fs.flash.control_volume : 5
fs.flash.split : 0
fs.properties : 0
fs.properties.Liq : 0
fs.properties.Vap : 0
fs.properties.benzene : 0
fs.properties.toluene : 0