Tutorial: Optimization of a Multi-Stage Separation Process

Level: Basic

Required Knowledge: None

Keywords: Process Simulation, EOS Calculations, Optimization

Pipe-It Utilities: Streamz Separator, Strexzel, Pipe-It Optimizer, Streamz Library, Streamz Tabulator, Streamz Copier, Linkz, Composite.

Introduction

Objectives

The objective of this tutorial is to optimize the process conditions of a simple 4-stage separation train using Pipe-It.

Multi-Stage Process Sketch

Conditions (pressure and temperature) of the three first stages are variables of the optimization problem. The objective is to maximize the final oil volume. Constraints on vessel temperature and pressure are also considered. The full optimization problem is described later. Note that the feed stream to the process is constant.

Getting Started

You can download the required input files here. You will need to login to the server using your existing uszername and password or register as new user.

Download the file : "Multi-Stage_Process_Optimization.zip" and un-zip it on your disk.

Files inside the folder "Multi-Stage_Process_Optimization"

The folder "Multi-Stage_Process_Optimization" contains several files and one sub-folder:

Create the Streamz Fluid Library

The Fluid Characterization Library (also called Streamz library) contains all fluid descriptions (e.g EOS models) and conversions (EOS volume calculation) needed in the Pipe-It project. Each new fluid description needs to be added to the Streamz library following this set of instructions:

  1. Open the Streamz Library window by:

Open the Streamz library

  1. Add a new file by clicking on the "Add File" button of the Streamz library.

Add a new file to the Streamz library

  1. Choose the file "Characterizations.chr". A new window appears and should look like this:

New characterization file scanned by Streamz

  1. Click on "OK".
  1. Click again on the "Add File" button, but now choose the file "Volumetric_Conversions.cnv". A new window appears and should look like this:

New conversion file scanned by Streamz

  1. Click on "OK" and close the Streamz library window.

Three new characterization have been added:

In addition, two EOS volume conversions have been added:

Process Modeling

Define a Feed Stream

Insert a New Resource Element on the Canvas

Insert a new resource element on the canvas either by:

Insert a new resource element on the canvas

Link the Resource File to an Existing File on the Disk

A resource element is always a reference to a file on a hard disk. We first need to link this resource element to a file on the disk. This can be done by right-clicking on the resource element. This operation can also be done by selecting the resource and pressing the touch F of the keyboard.

Insert a new resource element on the canvas

Select the file "Feed\_2\_process.str" and click on "Save".

This file can be open within Pipe-It by double clicking on the resource element. A new window appears:

Feed_2_process.str open with Strexzel

The name of the resource element can be changed by right-clicking on it. This operation can also be done by selecting the resource file and pressing F2.

Change the name of a resource element (1/2)

Change the name of a resource element (2/2)

Set a Characterization to the Resource Element

In Pipe-It, a Stream file (.str) needs to be linked to a fluid characterization in most of the cases. This can be done by right-clicking on the resource element. This operation can also be done by selecting the resource element and pressing F3.

Set a characterization to a resource element (1/2)

A new window appears. Select the "EOS11" characterization and click on "OK".

Set a characterization to a resource element (2/2)

Insert the Process Conditions

In this tutorial, we are going to use Strexzel to insert the process conditions.

Insert a Strexzel Process Element

First we need to insert a Strexzel process element on the canvas either by:

Insert a new Strexzel process element

Insert a Strexzel Macro

Insert a new resource file on the canvas by following the procedure described above. When setting the file, choose the file "Insert_Process_Conditions.stm". Note that this resource does not need to be associated with a characterization. Only Stream files need a characterization.

Insert an Output Ressource File

Insert a new resource element. When setting the file, type "Feed_2_process_w_cond.str" and click on "Save".

Create a new file from Pipe-It

Note that this file does not exist yet, but will be created by Pipe-It. This resource element is linked to a Stream file and needs to be linked to a characterization. Set the characterization "EOS11" to this file, following the procedure described above.

At this moment, the canvas should look like this:

Current status of the canvas

Connect the Resource Files to the Strexzel Process Element

Insert a connector by clicking on the connector icon in the tool bar or by clicking on Insert > Connector. The difference between "Elbow" and "Straight" is only graphical and will not affect the Pipe-It model.

Insert a new connector (1/5)

Connect the resource element "Feed_2_process.str" to the Strexzel element. The connector should start from the resource element and be pointing the process element. When the connection is done, Pipe-It gives you several option. You need to indicate if the input resource file is:

In this case, the input resource file is a Stream file.

Insert a new connector (2/5)

Insert a new connector (3/5)

Do the same operation for the resource element "Insert_Process_Conditions.stm". In this case, choose the option "Macro file (.stm)".

Insert a new connector (4/5)

The last resource file is an output of the Strexzel process element. The connector should go from the process element and be pointing the resource file. Several options are available. Choose "Output Stream file (.str)".

Insert a new connector (5/5)

At this moment, your Pipe-It project should look be similar to the following picture. You can run it by clicking on the run button in the tool bar or by pressing CTRL + R on the keyboard. #Run Pipe It?

Run the Pipe-It project

Note that the output file "Feed_2_process_w_cond.str" has been created while Pipe-It was running. Now, it can be open by double-clicking on it. A Strexzel window appears:

"Feed_2_process_w_conditions.str" open inside Strexzel

Set-up a Gas-Oil Separator

Insert a New Streamz Separator Element

Insert a new Streamz separator element either by:

Insert a new Streamz separator element

Rename the Streamz separator by right-clicking on it (or pressing F2) and call it "Stage 1".

Inser Output Resource Elements

We now need to insert two resources elements which will be the output of the Streamz separator element:

When setting the files, typewrite "Stg1_oil.str" for the first file and "Stg1_gas.str" for the second file. Both files need to be linked to the same characterization "EOS11".

At this moment, the canvas should look like this:

Current status of the canvas

Connect the Resources Files to the Separator

Use the connector element to make connections between resource files and the separator. The procedure is described here.

When connecting the input file "Feed_2_process_w_cond.str" to the Streamz separator, several options are available. Choose "INPUT STREAMS".

Connect the input resource to the separator

When connecting the Streamz separator to the output files, several options are available. Choose "OUTPUT OIL STREAMS" for the resource "Stg1_oil.str".

Connect the separator to the first output file (separator liquid)

Choose "OUTPUT GAS STREAMS" for "Stg1\_gas.str".

Connect the separator to the second output file (separator gas)

At this moment, the canvas should look like this:

Current status of the canvas

Configure the Streamz Separator

For the moment, we have indicated:

Now, we need to configure the type of separation process we want to model. To do this, double click on the Streamz separator element. A new window appears. Select the "EOS Flash" option to perform an EOS-based flash calculation.

Streamz separator configuration (1/3)

In the section "Variables", you have to define the pressure and temperature for the flash calculation. Use the pressure and temperature we previously defined using Strexzel and a macro file:

Streamz separator configuration (2/3)

Streamz separator configuration (3/3)

Run the Project

Run the project, following the instructions given here. Pipe-It will perform automatically the flash calculation of the feed stream at the given pressure and temperature, using the EOS model "EOS11". The output files "Stg1_oil.str" and Stg1_gas.str" will be created during the run. You can open them by double clicking on the resource files. They contain respectively the molar rates of all components in the separator oil and separator gas.

Insert the Remaining Streamz Separators

Following the previous instructions, insert three additional Streamz separators with the following configuration:

Separator Name Feed file Output file (separator oil) Output file (separator gas) Pressure Temperature
Stage 2 Stg1_oil.str Stg2_oil.str Stg2_gas.str P_Stg2 T_Stg2
Stage 3 Stg2_oil.str Stg3_oil.str Stg3_gas.str P_Stg3 T_Stg3
Stage 4 Stg3_oil.str Stg4_oil.str Stg4_gas.str P_sc T_sc

Note that all files need to be set up with the same characterization "EOS11".

After having configured a new separator, it is useful to re-run the Pipe-It project, so the new output files will be created on the disk.

At this moment, the canvas should look like this:

Current status of the canvas

Gather the Gas Streams

The gas released at each stage of the separation trains need to be commingled into a single stream. This can be done using the "Tabluator" process element of Pipe-It.

Insert a New Tabulator Process Element

First, you need to insert a new tabulator process element on the canvas either by:

Insert a new Tabulator process element

The Tabulator process element will behave like a "mixer". It will gather the input streams and tabulated them in a single output file. Thus, a new output resource element has to be inserted.

Insert a New Resource Elemet

Following the instructions given here, insert a new resource element on the canvas.

Typewrite "total_gas.str" for the file name and set the characterization to "EOS11".

Connections

Now, we need to connect the different resources elements to the tabulator element.

First, connect the resource element "Stg1_gas.str" to the Streamz Tabulator using a connector. Several connection options are available. Choose "INPUT STREAMS".

Streamz tabulator: Input connections (1/2)

Follow the same instructions for the other input streams:

For the output file, set a connect from the tabulator element to the resource element "total_gas.str". Choose the option "OUTPUT STREAMS".

Streamz tabulator: Input connections (2/2)

At this moment, the canvas should look like this:

Current status of the canvas

Configure the Streamz Tabulator

The Streamz Tabulator needs to be configured.

First double-click on the tabulator element. A new window appears.

  1. In the tab "Basic", tick the check box "Tabulate".

Streamz tabulator configuration (1/3)

  1. In the tab "Basic", click on "Add" and then on "Add all vars:"

Streamz tabulator configuration (2/3)

  1. In the tab "Advanced", tick the check box "Gathering options" and then select "Gather and Accumulate".

Streamz tabulator configuration (3/3)

  1. Click on "OK".

Oil Volume Calculation

We want to convert the molar rates of the final oil product into a liquid volume.

Insert a New Copier Process Element

Insert a new Streamz Copier either by:

Insert a new Copier process element

Insert a New Resource Element

Insert a new resource element following the instructions given here.

Typewrite "Oil_volume.str" as file name and set the characterization to "OIL".

Connect the Resource Elements to the Streamz Copier

First connect the resource element "Stg4_oil.str" to the Copier element with a connector. Select "INPUT STREAMS".

Streamz copier: Connections (1/2)

Then, connect the Copier element to the output resource file "Oil_volume.str". Select "OUTPUT STREAMS".

Streamz copier: Connections (2/2)

Streamz EOS Calculations

The Streamz Copier element automatically picks up the correct conversion in the Streamz library. You can check this by double-clicking on the Copier element and going in the tab "Conversions".

Conversions inside a Copier element (1/2)

Here, we can see that Pipe-It will perform an EOS calculation to translate moles into volume, using the EOS model. You can check the input file used for the conversion by double clicking on the green square. A new window appears showing the file where the conversion is read from. You can also double click on the file name to open the file.

In our case, we are converting molar rates (described with "EOS11" characterization) into an oil volume (characterized by "OIL"). Pipe-It will automatically use the EOS model to do this conversion.

Conversions inside a Copier element (2/2)

It is important to emphasize here that the volumetric calculation is sensitive to:

Gas Volume Calculation

Follow the same set of instructions to translate the gas molar rates from the resource file "total_gas.str" to a new resource called "Gas_volume.str". Set the characterization of this new resource file to "GAS" (instead of "OIL").

At this moment, the canvas should look like this:

Current status of the canvas

Organization of the Pipe-It Project

To make the Pipe-It project easier to understand, you can rename the following process elements:

In addition, you can create a composition. Select the elements as shown in Fig. \ref{fig:composite}, right click and select "Create Composite from Selection".

Create a composite

At this moment, the canvas should look like this:

Current status of the canvas

You can rename the composite "Process Simulation".

To navigate inside the composite, you only to double click on it.Navigation t upper level can be done using the arrows of the tool bar or by double clicking on the sockets.

Navigation to the upper level

Run the Pipe-It Project

The Pipe-It project can be run.

You can look at the influence of changing some of the process conditions (in the file "Insert_Process_Conditions.stm") on the final oil and gas volumes.

Change process conditions

Each time a modification is done, the entire Pipe-It project needs to be launched.

Process Condition Optimization

Introduction

We have seen in the previous section that the process conditions have an impact on the final oil volume. In this section, we are going to try to maximize the oil rate by changing the process conditions. We can eventually add some topside constraints: (1) Maximum pressure for the first stage separator; (2) minimum and maximum pressure for the other stages and (3) Minimum and maximum temperature. Note that the feed stream (mixture and molar rates) will remain unchanged.

Optimization Problem

The optimization problem we are going to consider is quite simple.

Maximize the final oil rate:

\[
\textrm{maximize } q_o,
\]

by changing the process conditions:

\[
p_1,T_1,p_2,T_2,p_3 \textrm{ and } T_3,
\]

and subject to:

\[
p_1 < 50 \textrm{ bara},
\]\[
p_1 > p_2,
\]\[
p_2 > p_3,
\]\[
p_3 > 1.013 \textrm{ bara},
\]\[
50 \textrm{ C} <T_1 < 70 \textrm{ C},
\]\[
25 \textrm{ C} <T_2 < 45 \textrm{ C},
\]

and

\[
18 \textrm{ C} <T_3 < 22 \textrm{ C}.
\]

The first step is to link the input files and output files. This can be done using Pipe-It built-in utility called Linkz. It allows to open any ASCII file and pin-point the number you want to link. Each time you define a new link in an ASCII file, this link is added to the Linkz library. Pipe-It optimizer has access to the Linkz library. We will come to that later on.

Select the resource element "Insert_Process_Conditions.stm" and right-click on it.

Open a  file in Linkz

A new window appears:

Linkz interface

The last separator being the separation at standard conditions, the parameters we want to optimize are:

To create a link for P_Stg1, follow the next steps:

  1. Pin-point the number "20" in the Linkz interface and double-click on it;

Create a new link (1/5)

  1. A new window appears;

Create a new link (2/5)

  1. Change the name of the link. The link name is used to find the link in the Linkz library, so it is important to give understandable names. Here, call the link "P_stg1".

Create a new link (3/5)

  1. Linkz works with one (or several) keyword(s). The target (here the number "20") is located based on the keyword(s). By default, Linkz use the first word of line as keyword. In our case, the default keyword is "SET". Since the word "SET" is used several times in the file, it is not a safe keyword. Add a new keyword with the button + and then choose the word "P_stg1" located on line 2 using the arrows.

Create a new link (4/5)

  1. To make sure that the link is define in a unique way, you can click on the "Test" button and check the number of occurrences. If the link is defined in a unique way, the number of occurrence is one.

Create a new link (5/5)

  1. Click on "OK"

The link has been created and added to the Linkz library. You can check this by opening it:

Open the Linkz library

A new window appears:

Linkz library

Use the same procedure to define links for the other process conditions. Keep the same nomenclature.

We now need to link the final oil volume. Open the resource file "Oil_volume.str" in Linkz. Create a link for the oil rate (pin-point the number "615.286") using the same procedure as described above. Rename the link "Oil_rate" and choose "DATA" as single keyword for this link.

Define a link for the oil rate

If you open the Linkz library, it should look like this:

Status of the Linkz library

Pipe-It Optimizer Configuration

Pipe-It Optimizer is a user-friendly optimization tool that allows to do model-based (or black box) optimization. Several built-in solvers are available: IPOPT, reflection, simplex... For each solver iteration, variables are changed in the input files (through user-defined links), the model is launched. Objective function and constraints are then read by the optimizer (using user-defined links). The solver decides the values of the variables for the next iteration.

Open Pipe-It Optimizer

To open Pipe-It optimizer, you can either:

Open Pipe-It Optimizer

A new window appears:

Pipe-It Optimizer window

Add a New Variable to the Optimizer

To add a new variable, click on the button + of the optimizer. Change the name of the variable in the column "Name" and rename it "p1". In addition, change the upper and lower limits to 1.013 for the lower bound and 50 for the higher bound.

Add a new variable (1/2)

Now, we need to link this optimizer variable to an actual number in one of the input file. We will use the linkz library for this. Double-click on the cell "Link" of the current row. A new window appears. Select "P_stg1" and click on "OK".

Add a new variable (2/2)

The optimizer variable "p1" is now mapped to the link "P_stg1". After each iteration, the value of this link in the file "Insert_Process_Conditions.stm" will be changed automatically.

Add the Remaining Variables

Add the remaining variables following the following instructions:

Name Lower Bound Upper Bound Link
p2 1.013 50 P_Stg2
p3 1.013 50 P_Stg3
T1 50 70 T_Stg1
T2 25 45 T_Stg2
T3 18 22 T_Stg3

At this moment, the optimizer window should look like this:

Status of the optimizer window

You can save the optimizer settings by clicking on the "Save" button in the optimization window.

Add an Objective

To add an objective, use the + button. Rename the variable "Qo" and change its "role" to "OBJ". Then link this variable to "Oil_volume".

Add an objective

The optimizer window should now look like this:

Status of the optimizer window

Add a New Constraint

It is not directly possible to include inequality constraints between two variables in the optimizer. However, we can note the equivalency:

\[
p_1 > p_2 \Leftrightarrow p_1-p_2 > 0.
\]

To add a this new constraint, use the + button. Rename the variable "Press_con". Set the lower bound to 0 and the upper bound to 1 000 000. Change its role to "CON". Then double-click on the corresponding "Equation" cell.

Add a new constraint

A new window appears. In the input box "Expression", type:

p1-p2

Then click "OK".

Evaluate a constraint using an equation

Add the Remaining Constraint

Add the remaining constraint following the same instruction. Name it "Press_con1". Note that the equation which needs to be entered is:

p2-p3

The optimizer window should look be similar to this:

Status of the optimizer window

Launch the Optimization

It is possible now to launch the optimization by clicking on "Optimize". Some additional settings are available:

It is possible to access the history of the optimization by clicking on the "History" button.

Here are some ideas for further studies:

Pipe-It optimizer in progress




Copyright © 2008-2013 Petrostreamz