24
--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 1 Aspen HYSYS SQP Optimization A Practical Guide Aspen HYSYS TM SQP optimizer uses a steady state simulation of the process built using HYSYS software. There are a number of optimization algorithms in Aspen HYSYS. This document only focuses on the Hyprotech SQP method. This document provides information for the following: - Those wishing to gain basic information about SQP optimization using Aspen HYSYS. - Those requiring in depth knowledge in analysing the results from the optimization. This guide covers the following main aspects of optimization: - Configuring a derivative utility for a SQP optimizer, running the optimizer and viewing the results. - Configuring a HYSYS spreadsheet to organize optimizer inputs and results. - Performing derivative analysis and noise calculation to diagnose the optimizer setup. - Analyzing the results to ensure that the optimizer recommendations are justifiable. - Improving the optimizer predictions through analysis of derivative and reducing noise in the simulation. - Using optimizer as a tool to perform What-If case studies exploring new strategies in design and process operation. A simple Aspen HYSYS simulation is used to cover the topics listed above. It is assumed that the readers are familiar with the necessary steps required to build the optimizer in Aspen HYSYS. For further details please refer the following documents. 1. Aspen HYSYS Operations Guide - AspenHYSYSV7_0-Ops.pdf 2. Aspen HYSYS Real Time Optimization Reference Guide - AspenRTOV7_0-Ref.pdf These documents are supplied with the installation disks; alternatively the registered user can download these documents from AspenTech Support Centre at http://support.aspentech.com

SQP Optimization

Embed Size (px)

Citation preview

Page 1: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 1

Aspen HYSYS SQP Optimization

A Practical Guide

Aspen HYSYSTM SQP optimizer uses a steady state simulation of the process built using HYSYS software. There are a number of optimization algorithms in Aspen HYSYS. This document only focuses on the Hyprotech SQP method. This document provides information for the following:

− Those wishing to gain basic information about SQP optimization using Aspen HYSYS.

− Those requiring in depth knowledge in analysing the results from the optimization.

This guide covers the following main aspects of optimization:

− Configuring a derivative utility for a SQP optimizer, running the optimizer and viewing the results.

− Configuring a HYSYS spreadsheet to organize optimizer inputs and results.

− Performing derivative analysis and noise calculation to diagnose the optimizer setup.

− Analyzing the results to ensure that the optimizer recommendations are justifiable.

− Improving the optimizer predictions through analysis of derivative and reducing noise in the simulation.

− Using optimizer as a tool to perform What-If case studies exploring new strategies in design and process operation.

A simple Aspen HYSYS simulation is used to cover the topics listed above. It is assumed that the readers are familiar with the necessary steps required to build the optimizer in Aspen HYSYS. For further details please refer the following documents.

1. Aspen HYSYS Operations Guide - AspenHYSYSV7_0-Ops.pdf

2. Aspen HYSYS Real Time Optimization Reference Guide - AspenRTOV7_0-Ref.pdf

These documents are supplied with the installation disks; alternatively the registered user can download these documents from AspenTech Support Centre at

http://support.aspentech.com

Page 2: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 2

1.0 Overview

1.1 Optimizer Configuration The configuration of a SQP Optimizer is done via the Derivative Utility available within Aspen HYSYS. It is assumed that the readers are already familiar with the necessary steps require to build an optimizer using the derivative utility. Here it is intended to outline the main steps to refresh your understanding in this area. The mains steps are listed with relevant screenshots from the flowsheet.

1. Create a Derivative Utility and give an appropriate name for this utility (e.g., NGL Optimizer).

Figure 1.1: Derivative utility setup screen.

2. Define the scope of the optimizer. The scope can be selected as “FlowSheet Wide” if a generalized optimizer for the whole simulation is to be considered.

Figure 1.2: Selection of optimizer scope.

Page 3: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 3

An optimizer has three main elements:

• Variable – decision variables for the optimization that must be linked with inputs in the flowsheet. The variables can be included or excluded in an optimization by selecting the “Optimize Flag”. The values of the variables are manipulated in order to minimize or maximize the objective function. Each variable has maximum and minimum limits which are used to set the search range. The range can be user specified. If this is not given then optimizer calculate this as

MinimumMaximumRange −=

• Constraint – the constraints are linked with the calculated results in the flowsheet. A constraint can be included or excluded in an optimization by selecting the “Use Flag”. Similar to variables, the constraints have minimum and maximum limits but these can be one-sided (i.e. having either minimum or maximum limit). The optimizer must meet the constraints defined by the user. Each constraint has a scale parameter which must be specified. In general a constraint is considered to be feasible if:

( ) ( )ScaleMaximumValueCurrentScaleMinimum +≤≤−

The scale can be used as the accuracy of measurement, for example a scale of 1oC can be used for a process temperature of 100oC. Typical range is 1-5% of maximum limit. Sometimes a larger scale helps solving problems with non-linear relationships as the feasible region is expanded by the amount of the scale. However, one drawback is a non-feasible problem can give a false convergence. An optimization using a well constructed simulation should always give an optimum within the specified limits of the constraints.

• Objective function – this is the function which is to be minimized or maximized. Individual objective function can be added separately and price of each specified. Alternatively, this can be built in a spreadsheet, with a single cell representing the results. By default the SQP optimizer works as a minimization algorithm. For a maximization problem the price term should be negative.

3. Add variables and specify their limits (minimum and maximum values). Give meaningful names for the variables.

Figure 1.3: Optimizer variable setup screen.

Page 4: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 4

4. Add constraints and specify their limits and scale. Give meaningful names for the constraints.

Figure 1.4: Optimizer constraint setup screen.

5. Add objective function terms and specify the prices.

Figure 1.5: Optimizer objective function setup screen.

6. Close the Derivative Utility page.

Page 5: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 5

7. Open the optimizer page following the Menu bar, Simulation and Optimizer or simply using shortcut F5. The Hyprotech SQP and other optimization methods available in Aspen HYSYS are shown in the optimizer page (Figure 1.6).

Figure 1.6: Optimizer screen showing the options available in HYSYS. We will only consider the Hyprotech SQP method.

8. Select Hyprotech SQP. This will add a new tab named Hyprotech SQP. Select this tab and then click on “Select Utilities to Run”. The available Derivative Utilities will be listed here. Select the utility to run with this SQP optimizer.

Figure 1.7: Optimizer page giving selection of a configured derivative utility.

Page 6: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 6

9. Close the “Select Utilities to Run” window. Now the optimizer page with all the default parameters will be visible. The optimizer is now ready to start.

Figure 1.8: Optimizer main screen.

Page 7: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 7

1.2 Optimizer Results The optimizer can be run by selecting the “Start” button in the optimizer page. There are some parameters with default values which should be carefully reviewed before optimization is performed.

Maximum Iterations: Default value 50. In most cases this is sufficient. A simulation involving significant noise usually requires a large number of iterations.

Objective Scale: Default value 1. The objective function value is multiplied by the scale factor. This is used for scaling the objective function and its gradients. This gives a relative weight between the objective function and feasible search when performing an optimization search. A smaller value in objective scale sometimes helps in solving the non-linear problems.

Accuracy Tolerance: Default value 1e-04. This is the relative accuracy tolerance of objective function improvement used as the convergence tolerance of the optimizer. This is not scale dependent. Typical range is 1e-04 to 1e-06.

Step Reduction: Default value 0.2.

Perturbation: Default value 1e-03. This is the step size of the scaled variables used in gradient calculations. Typical range is 1e-02 to 1e-03. A smaller value gives faster gradient calculation, however this may not give accurate gradient if there is a significant noise in the simulation.

An optimizer can be run by selecting the “Start” button located in the optimizer screen.

Figure 1.8: Overall results shown in the main optimizer screen.

The optimizer results are displayed in “Running Results” section of the screen. A successful optimization displays one of the following messages in the “Termination Reason” field.

• OK – This is based on the feasibility point search indicating that a feasible termination of this phase.

• Step convergence – During the optimization search the stepping back procedure resulted in a step collapse to below the step tolerance.

Page 8: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 8

• Cost convergence – Two successive iterations resulted in objective function value difference in less than the accuracy tolerance.

The benefits from the optimizer can be calculated from values shown in “Starting Objective” and “Objective Value” fields as

Optimizer benefits = - (Objective Value – Starting Objective)

The results of the optimizer variables and constraints can be found in the Derivative Utility. This utility can also be accessed from the optimizer page by a mouse double-click on the optimizer item (in this case “NGL Optimizer”) located under “Derivative Utility”.

Figure 1.9: Result screen of optimizer variables.

Figure 1.10: Result screen of optimizer variables.

Page 9: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 9

2.0 Spreadsheet Configuration The Spreadsheet functionality within Aspen HYSYS provides a flexible approach in organizing the optimizer data. This allows gathering ON/OFF flags, limits and results. The optimizer can be run using the selected variables and constraints. In this way the operation can be restricted within a certain section of the flowsheet.

Note that the operation scope in the Derivative Utility is always exclusive which restricts the users to share a variable or constraint by more than one optimizer. The spreadsheet approach provides the flexibility of selecting the required variables and constraints out of the global configuration (i.e., selecting the “FlowSheetWide” scope).

The flowsheet shown below (Figure 2.1) is constructed with a number of spreadsheets each containing specific type of information. The following spreadsheets are used.

Power & Utilities – This is used to gather power consumption by compressors and reboilers. The power is then converted to costs using appropriate unit price (Figure 2.2).

Products – All the products are accounted here and sales value is calculated based on unit sale price for each product (Figure 2.3).

Marginal Benefits – This is calculated as the difference between sales and costs (Figure2.4).

Variables & Constraints – This spreadsheet links all the optimizer variables and constraints including the initial and final objective values (Figure 2.5). For a larger problem it would be ideal to have separate spreadsheets for variables, constraints and benefits.

Figure 2.1: Aspen HYSYS flowsheet.

Page 10: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 10

Figure 2.2: Spreadsheet containing power & utilities and their costs.

Figure 2.3: Spreadsheet containing the products and their prices.

Figure 2.4: Spreadsheet showing calculation of optimizer benefits.

Page 11: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 11

The variables and constraints can be imported from the optimizer objects to a spreadsheet. This provides a convenient method in performing benefits analysis using multiple what-if scenarios, for example

- The statuses of the variables can be switched ON or OFF

- The limits can be changed

- The current values for the variables can be specified

- The recommended values for variables and constraints are readily available

- Calculated benefits can be obtained

The screenshot given below (Figure 2.5) illustrates how an Aspen HYSYS spreadsheet can be put together with optimizer variables, constraints and objective function values.

Figure 2.5: Spreadsheet showing optimizer variables, constraints and benefits.

Importing/Exporting data to a Spreadsheet

To import/export a parameter of a variable (e.g., Minimum Limit) to a spreadsheet follow steps listed below.

(1) Select a cell in the spreadsheet

(2) Apply the right mouse click on a cell

(3) Select Import Variable or Export Formula Result

Page 12: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 12

Figure 2.6: Object navigation page for importing or exporting values in a spreadsheet.

(4) Select the option Custom from the Object Filter

(5) Select Optimization Object from the available list of Select Type

Figure 2.7: Screen showing optimization objects.

Page 13: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 13

(6) There will be a list of all the optimization parameters. Now if, for example, you want the minimum limit value of a variable then select “Optimizer Variable” from the list, select the variable, Variable Property Value and “min” from Variable specific column.

Figure 2.8: List of optimization variables and their properties.

Page 14: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 14

3.0 Optimizer Analysis This section provides some important tips to identify any mismatch in the optimizer setup and analyse the results for consistency.

3.1 Derivative Analysis A numerical perturbation is performed to the optimization variables and the resulting effects on the objective function and optimizer constraints are presented in a table within the derivative utility.

The derivative analysis helps if the optimizer has been configured correctly, for example

• The variables with zero derivative values indicate

− Either the variables are not linked to the simulation input conditions.

− Or the variable does not have any influence in the simulation. In this case this variable can be deleted or ignored by de-selecting the “Optimize Flag” from the variable setup page (see Figure 1.9).

• The sign and size of the objective function gradient indicates the direction the variable should move during optimization. For maximization problem with a negative derivative value the optimizer variable favours a higher value and with a positive derivative value it favours a lower value.

The screenshot for derivative analysis inside the optimizer is shown in Figure 3.1.

Figure 3.1: Derivative analysis page in HYSYS optimizer.

Page 15: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 15

There are two modes available for derivative calculation.

1-sided (forward): v

vcvvc

dv

dc

∆−∆+= )()(

2-sided (centered): v

vvcvvc

dv

dc

∆∆−−∆+= )5.0()5.0(

Where v is an optimizer variable, and c is the objective function or constraint.

3.1 Noise Analysis The noise in the objective function and constraints are calculated during derivative analysis. One-side forward derivative calculations follow the sequences listed below.

(1) Record the starting values of objective function and constraints

(2) Perform a perturbation to the optimizer variables using a step size v∆

(3) Record the new values of objective function and constraints

(4) Return the variable to their starting values

(5) Record the values of objective function and constraints

The noise is calculated as the difference of values recorded in sequences (1) and (5). See Figure 3.2 for a screenshot of absolute noise data.

Figure 3.2: Screenshot showing absolute noise in derivative calculation.

Page 16: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 16

The noise can propagate throughout the flowsheet and convolute the gradient values. Inaccurate gradient produces erroneous optimizer results. In Aspen HYSYS simulation noise is attributed to the solver convergence tolerances in heat exchanger, recycle operation, column, adjust operation etc. The noise level can be reduced by tightening the convergence tolerance in these unit operations. This will be demonstrated in the following section.

Page 17: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 17

4.0 Result Analysis The section provides tips on how to analyse the results from an optimization run. The flowsheet used in this study contains an LNG exchanger and three columns. These units are calculated by solvers consisting of default error tolerance. The optimizer results with the default error tolerances will be investigated first. We will then examine improvements following tightening the tolerances from their default values.

4.1 Results with Default Tolerances The optimizer results will be explored with the default error tolerance values. The optimizer setup parameters used are those shown in the optimizer page (Figure 4.1).

To run the optimizer select “Start” button available in the optimizer screen. The screenshot in Figure 4.1 shows that the optimizer is solved successfully giving the starting and final values of the objective function. The screen also shows the CPU time, termination reason and various iteration counts.

Figure 4.1: Optimizer overall results with default tolerances for columns and LNG exchanger.

The detailed results can be found in the spreadsheet shown in Figure 4.2. This screenshot shows the values of the optimizer variables, constraints and the calculated benefits by the optimizer.

The calculated benefits is shown as 1.321e05 $/day.

Page 18: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 18

Figure 4.2: Optimizer results with default error tolerances for columns and LNG exchanger.

Now we see how the optimizer results can be explained in conjunction with the derivative values. A screenshot for the derivative values are shown below (Figure 4.3).

Figure 4.3: Derivative values with default error tolerances for columns and LNG exchanger.

Page 19: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 19

How does the optimizer accomplish the benefit?

The sign of the derivative values indicates the direction the variable should move to give a higher objective function value. For a maximization problem and with a negative derivative value, the variable favours a higher value subject to limits of the constraints imposed in the optimization problem. The opposite is expected for variables with positive derivative values. The move of variables can be compared with the sign of derivative values for the objective function (Daily Benefits). The expected and actual move in optimizer variables are presented in a table below. See Figures 4.2 and 4.3 for optimizer results and derivative values respectively.

Variable Derivative Value (Figure 4.3)

Expected Value Actual Value (Figure 4.2)

Chiller temperature +ve decrease decreased

Expander pressure -ve increase increased

DePropanizer feed pressure +ve decrease decreased

DeMethanizer C1 purity +ve decrease increased

DeEthanizer C2 purity +ve decrease decreased

DeEthanizer reflux ratio +ve decrease decreased

DePropanizer C3 purity +ve decrease decreased

DePropanizer reflux ratio -ve increase increased

This table shows that the variable, de-methanizer purity, did not move in the direction following the sign of the derivative value. The screenshot shown in Figure 4.4 shows the calculated noise associated with derivative calculations for this optimization. The noise level is possibly the contributing factor giving this inconsistent result.

Figure 4.4: Noise in derivative calculations using default tolerances for columns and LNG exchanger.

Page 20: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 20

4.2 Results with Improved Tolerances The error tolerances for the three columns and an LNG exchanger in the simulation were tightened from their default values. The default and new values are shown in the table below.

Tolerance terms Default Value New Value

LNG exchanger error 1e-04 1e-06

HYSYS column default equilibrium error 1e-05 1e-06

HYSYS column default Heat / Spec error 5e-05 1e-06

The optimiser was run with improved error tolerances and the overall results from the optimizer are shown in Figure 4.5. The optimizer setup parameters were unchanged.

Figure 4.5: Optimizer overall results with improved error tolerances for columns and LNG exchanger.

The results for the variables, constraints and objective function values are in the spreadsheet in Figure 4.6. The calculated benefits is shown as 1.377e05 $/day.

Page 21: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 21

Figure 4.6: Optimizer results with improved error tolerances for columns and LNG exchanger.

The derivative values obtained with improved error tolerances are shown in Figure 4.7.

Figure 4.7: Derivative values with improved error tolerances for columns and LNG exchanger.

Page 22: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 22

The move of optimizer variables are compared with the derivative values for the objective function (Daily Benefits). This is presented in a table below.

Variable Derivative Value (Figure 4.7)

Expected Value Actual Value (Figure 4.6)

Chiller temperature +ve decrease decreased

Expander pressure -ve increase increased

DePropanizer feed pressure +ve decrease decreased

DeMethanizer C1 purity +ve decrease decreased

DeEthanizer C2 purity +ve decrease decreased

DeEthanizer reflux ratio +ve decrease decreased

DePropanizer C3 purity -ve increase increased

DePropanizer reflux ratio -ve increase increased

This table shows that all the variables moved in the direction consistent with their derivative values. The absolute error in the derivative calculation is shown in Figure 4.8. Comparing this with Figure 4.4 (using defaults error tolerances) it can be seen that errors are significantly less when the tolerances are tightened.

Figure 4.8: Noise in derivative calculations using improved error tolerances for columns and LNG exchanger.

Page 23: SQP Optimization

-------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 23

4.3 Case Study The optimizer can be used by the process development engineer to perform What-If case studies and explore potentials for process improvement. The limits of variables and constraints can be relaxed from the current operating guideline and the resulting improvement in benefits can be studied. This section illustrates this feature using two examples.

From the optimizer results presented in Figure 4.8 shows that chiller temperature decreased from the starting value of -62.0oC to -62.45oC but it did not reach the lower limit of -65oC. One possible reason for this would be the duty limit in the de-methanizer reboiler as this constraint is currently on the high limit. We can verify this by running the optimizer with a higher duty limit.

The optimizer results presented in Figure 4.9 is a rerun from the previous results but the reboiler duty limit was increased by 50% from 2400 to 3600 kW.

With the increase of duty limit the chiller temperature decreased from -62.45oC until it reaches the lower limit of -65oC. The additional benefit calculated by the optimizer is $4528/day.

Figure 4.9: Optimizer case study results with higher duty limit for the de-methanizer reboiler.

Now suppose the design engineer is interested to know the additional benefits by setting the chiller temperature minimum limit of -75oC and maximum duty limit for the de-methanizer reboiler of 3600 kW.

To calculate the additional benefits the optimizer was run from the base case (Figure 4.6). The results for this run are shown in Figure 4.10.

Page 24: SQP Optimization

--------------------------------------------------------------------------------------------------------------------------------------------------------------- Aspen HYSYS SQP Optimization - A Practical Guide V1.0.doc 24

Figure 4.10: Optimizer case study results with higher duty limit for the de-methanizer reboiler and reduced lower limit for the chiller.

With this new strategy the optimizer pushed the chiller temperature as low as -71.09oC and this is again constrained by de-methanizer reboiler duty. The additional benefit calculated by the optimizer with this new proposed operating scenario is $1.353e+04/day.

These two examples illustrate how the optimizer can be used to perform What-If case studies. The design engineer can use this as a tool to study beyond current guidelines in place for process operation and undertake strategies for process improvement.