# Use of Ports and Streams IV – Creating Condenser, Trays, and Reboiler as Units and Connecting them with Streams

This example extends example V for connectors. But instead of simply connecting the three equation systems for condenser, trays, and reboiler, we save them as units and then connect them with streams.

### Model description

The model is discussed in Use of Connectors V – Connecting Condenser, Trays, and Reboiler with Different Naming Policies and will therefore not be repeated here.

### Modeling workflow

To make things easier, we use the same notation, parameter list, equations, and functions as in the example linked above. However, the use of ports requires us to define an interface and new connectors for these ports. As the tray system has four stream connections for ingoing and outgoing streams, and reboiler and condenser both have two, we need a total of eight connectors. This is a significant overhead. Therefore, using ports and streams is not recommended if a single user wants to solve an equation system. It might, however, be of advantage if you collaborate with others and everyone is working on an individual unit. Then, you can just agree on the generic information that is exchanged via ports.

• Notation ID: 185711
• Parameter list ID: 185740
• Condenser equation IDs: 185724, 185725, 185726, 185727, 185728, 185752, 185729, and 185730
• Tray equation IDs: 185712, 185714, 185715, 185716, 185717, 185718, 185719, 185720, and 185721
• Reboiler equation IDs: 185733, 185734, 185735, 185736, 185737, 185738, and 185739
• Functions IDs: 185741, 185742, and 185743

#### Notation for stream interface

In addition to the notation of the units, we specify a notation for the stream interface with the following symbols:

##### Base names
• , mole flow in mol/s
• , molar enthalpy in kJ/mol
• , pressure in bar
• , mole fraction in mol/mol
##### Indices
• , component index 1…NC

The resulting notation has ID 185768.

#### Interface

Go to the Interface tab and create a new interface by taking the following steps:

1. Set the stream notation you just created as Notation
2. Set a description for the interface
3. Add variables, i.e., for mole flow, for enthalpy, for pressure, and for mole fractions
4. Leave “in/out” as is because streams have no direction
5. Leave “Dim” as is. The mole fraction should be automatically set to Dim “Vector”
6. Save the interface

#### Connectors

We now set up the eight connectors for the eight ports. For this purpose, go to the Connector tab and do the following:

1. Add a helpful description for the connector, e.g., connector inlet condenser
2. Activate the tab Edit Matching, select the notation of the units as Sub Notation and the stream notation created in this example as super notation
3. Create the following variables for the Sub Notation:
4. Create the following variables for the Super Notation:
5. Match the variables accordingly and save the connector
6. Click on “Break all connections” below the bin. This puts all variables back in the columns on the left side
7. Rename the variables in the Sub Notation to
8. Update the connector description, match the variables, and save this second connector
9. Repeat steps 6-8 for the following variable sets in the Sub Notation:
• , , ,
• , , ,
• , , ,
• , , ,
• , , ,
• , , ,

The connectors are available with IDs 185770 and 185771 (condenser), 185772-185775 (trays), and 185776 and 185777 (reboiler).

#### Equation systems

To construct the units from the equation systems of condenser, trays, and reboiler, go to the Equation System tab and take the following steps:

##### Condenser system
2. Click on “Add EQU/EQS” and add the equation system of the condenser (ID 185744)
3. Make sure that the Naming policy is integrate
4. Go to the tab Flowsheeting and then to the tab External Ports
5. Click on “+ Port”, select Direction “in”, give the port a helpful name, load the interface created above and select the connector for the condenser inlet. Then click on “Check Port Configuration” and then on “Confirm”
6. Add a second port with Direction “out” and the connector for the condenser outlet
7. Save this equation system as unit
##### Tray system
2. Click on “Add EQU/EQS” and add the equation system of the trays (ID 185745)
3. Make sure that the Naming policy is integrate
4. Go to the tab Flowsheeting and then to the tab External Ports
5. Click on “+ Port”, select Direction “in”, give the port a helpful name, load the interface created above and select the connector for the liquid inlet of the trays. Then click on “Check Port Configuration” and then on “Confirm”
6. Add a second port with Direction “out” and the connector for the liquid outlet of the trays
7. Add a third port with Direction “in” and the connector for the vapor inlet of the trays
8. Add a fourth port with Direction “out” and the connector for the vapor outlet of the trays
9. Save this equation system as unit
##### Reboiler system
2. Click on “Add EQU/EQS” and add the equation system of the reboiler (ID 185746)
3. Make sure that the Naming policy is integrate
4. Go to the tab Flowsheeting and then to the tab External Ports
5. Click on “+ Port”, select Direction “in”, give the port a helpful name, load the interface created above and select the connector for the reboiler inlet. Then click on “Check Port Configuration” and then on “Confirm”
6. Add a second port with Direction “out” and the connector for the reboiler outlet
7. Save this equation system as unit

The equation systems of the three units have the IDs 185778, 185779, and 185780.

##### Flowsheet

To combine the three sub-systems, click on “New” and do as follows:

2. Add the three units with naming policy integrate; once added, the naming policy has automatically switched to streams
3. Go to the tab Flowsheeting and then to the tab Internal Streams
4. Add a stream by clicking on “+ Stream” at the bottom right corner.
5. Load the interface created above, then click on “Port 1” and select the equation system of the tray unit; select the vapor outlet port and confirm. Then click on “Port 2” and select the condenser unit; select the condenser inlet port. Give the stream a helpful name, e.g., Trays2Condenser, click on “Check Stream Connection” and then confirm
6. Repeat these steps for the other three connections, i.e., condenser to liquid inlet of the trays, liquid outlet of the trays to reboiler, and reboiler to vapor inlet of the trays
7. Save the flowsheet as equation system
8. Go to the tab Preview and click on “Update Preview”. In the tab Flowsheeting, you can now go to the tab Visualization and click on “Print Unit(s)”. You should now see your flowsheet

### Simulation workflow

#### Equation system and Indexing

Go to the “Simulation” section and do the following:

1. Load your equation system containing the flowsheet in the tab Equation System
2. Set the maximum value NC to 2 for all indices and the maximum value NTR to 10 for all in the tab Indexing

#### Initialization and results

If you scroll through the variables, you will see that three namespaces were created: e0e0 for the condenser variables, e0e1 for the tray variables, and e0e2 for the reboiler variables. In addition, the streams have also received their namespaces, i.e., e0s0, e0s1, e0s2, and e0s3. To initialize and specify the model, we now proceed as shown in the example V for connectors:

1. Click on Import Values
2. Select a language specificator, e.g., Matlab NLE
3. Select SpecList as Source and load the variable specification from above (ID: 185751)
4. Select “Match Namespaces” and “Import Classification”
5. Selecting Match Namespaces adds a second tab. Go to this tab and remove all lines by clicking on “Delete Match” at the bottom right corner
6. Click on “+ Match” and enter the namespace e0
7. You can now select three namespaces on the right side in the column System
8. Select the namespace e0 on the right side and click on “Test Import”. You will now see which variables will be changed if you import them. Close this window and click on “Import”.
9. Repeat this step by changing the namespace in the system to e0e0 (test import and then import), e0e1, and e0e2 (test import and then import)
10. The stream variables cannot be initialized this way, as they have not only different namespaces, but also different variable names (, , , and ). Hence, you need to initialize them by hand
11. When you import the classifications correctly, you will have one degree of freedom left. This is because the condenser pressure is no longer part of the equation system as it is now a stream variable in namespace e0s1. Therefore, select the pressure in this namespace as design value
12. Your whole system should now be initialized in the same way as the simulation with the naming policy integrate and have a degree of freedom equal to zero
13. Save the variable specification
14. Go to the parameter specification and import the parameters the same way as for the variable specification because the parameters also appear in different namespaces now, i.e., import the values from the parameter specification with ID 185753 to the three namespaces e0e0, e0e1, and e0e2
15. Save the parameter specification
16. Save the simulation
17. Go to the Evaluation tab and generate the code for your preferred environment
18. Solve the system using the generated code

This simulation is available with ID 185785 with variable specification 185786 and parameter specification 185803. The solution for all iteration variables can be found in Use of Connectors V – Connecting Condenser, Trays, and Reboiler with Different Naming Policies. Note that the name spaces are different for the example at hand.