software integration for online dynamic simulation

5
Software Integration for Online Dynamic Simulation Applications Matthew Mitchell 1 , Isuru Udugama 1 , Jonathan Currie 2 and Wei Yu 1 Abstract— Current process industries such as refineries and pharmaceutical industries have been facing increasing chal- lenges with respect to productivity, reducing waste and en- ergy consumption, as well as environmental and safety issues becomingly increasingly comprehensive. One way to address these issues is to utilize online dynamic simulation via process modelling and control software. While there are multiple pro- cess simulation packages available, such as VMGsim, HYSYS, Aspen etc., comprehensive control algorithms such as Model Predictive Control (MPC) or many Advanced Process Control (APC) algorithms which are available in the literature and third party packages cannot be easily and/or directly implemented in these packages. In this paper, we develop a software integration framework which allows Matlab to drive dynamic simulations built within a software simulator. The framework will open these high-fidelity process simulation packages for engineers and researchers to test, implement and tune advanced process control strategies, in both offline and online scenarios. I. INTRODUCTION In the current processing industries such as refineries, petrochemical and food industries, improving the plant ef- ficiency has become more challenging since the scale of processes has become larger, process complexity has dra- matically increased, as well as the increase in environmental impacts. Furthermore, knowing how to help operators to handle the plant safety and deal with abnormal operations has become more difficult due to the lack of critical mea- surements, i.e. compositions and a lack of understanding of the dynamic behaviour changes driven by various resources. Dynamic simulation provides an efficient and economical way to help industries to solve these challenges. Since dynamic simulation combines the knowledge of multiple disciplines it can be used for various purposes such as analysis, optimization, control and training/education. Today, the mature application of process dynamic simulation brings us as close as possible to the real process. This allows engineers to integrate process design, technology, control, operation, safety and environment together through dynamic simulation. Recently, simulation technology has used for multiple purposes; for example, operation start-up and shutdown [1], [2], [3], process optimisation [4], [5], [6], [7] and process control [8], [9]. An extension of process simulation tech- nologies in the process industry is to develop an online dynamic simulator. By taking all existing measurements from the plant, it can provide much more valuable predictions which cannot be measured in economical and/or easy ways. 1 Chemical and Materials Engineering Department, The University of Auckland, New Zealand 2 School of Engineering, Computing and Mathematical Sciences, Auck- land University of Technology, New Zealand Since the models are developed based on physical and chemical laws and validated by the process data, the models enable reliable dynamic characteristics of the processes to be modelled. However, the application of online dynamic simulation is often performed in isolation from an APC layer, thus limiting it’s use in control. Usually a commercial dynamic simulator such as HYSYS does not provide the flexibility for implementing different control strategies such Model Predictive Control (MPC) or user defined APC algorithms. This significantly limits the usage of the online dynamic simulations to information reporting and measurement validation only, and does not complete a feedback loop for closed-loop control. Previous implementations have attempted to address this limitation by combining the dynamic simulator with sophisticated proto- typing software e.g. Matlab. In [10] the authors have used Matlab to capture the input-output data from the simulation models to build approximate models which can be used in simpler Matlab-specific simulations. An integrated, real-time computing environment was successfully developed to link HYSYS and Matlab by Excel for education purposes in [11]. The environment provided detailed development procedures which can be easily reproduces by other researchers in public domain. Yokogawa engineering team developed its in-house on-line dynamic simulator: OmegaLand, which was applied to real industrial plants [12], [13]. This paper presents a way to connect the powerful proto- typing software Matlab to the commercial dynamic simulator HYSYS via a middle layer provided by Microsoft Excel and set of VBA scripts. This software integration allows researchers and engineers to have the flexility to test, tune, and implement different control algorithms on high-fidelity nonlinear process models. The successful development also provides the first step for the broad application of online dynamic simulations. II. ONLINE DYNAMIC SIMULATION WITH SOFTWARE INTEGRATION In order to implement an MPC controller in Matlab that is capable of controlling a simulation in the simulator software, there is a need to send and receive information between the two programs. Microsoft Excel provides a convenient script- ing layer via VBA macros that enables a set of extensive libraries for communicating with each of these programs, so it was chosen as a communication hub for the MPC environment. The framework was designed so that Microsoft Excel is used as the user interface. The user can input all simulation parameters such as how long to run the simulation for, the set 6th International Symposium on Advanced Control of Industrial Processes (AdCONIP) May 28-31, 2017. Taipei, Taiwan 978-1-5090-4396-5/17/$31.00 ©2017 IEEE 360

Upload: others

Post on 10-Jan-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Software Integration for Online Dynamic Simulation

Software Integration for Online Dynamic Simulation Applications

Matthew Mitchell1, Isuru Udugama1, Jonathan Currie2 and Wei Yu1

Abstract— Current process industries such as refineries andpharmaceutical industries have been facing increasing chal-lenges with respect to productivity, reducing waste and en-ergy consumption, as well as environmental and safety issuesbecomingly increasingly comprehensive. One way to addressthese issues is to utilize online dynamic simulation via processmodelling and control software. While there are multiple pro-cess simulation packages available, such as VMGsim, HYSYS,Aspen etc., comprehensive control algorithms such as ModelPredictive Control (MPC) or many Advanced Process Control(APC) algorithms which are available in the literature and thirdparty packages cannot be easily and/or directly implemented inthese packages. In this paper, we develop a software integrationframework which allows Matlab to drive dynamic simulationsbuilt within a software simulator. The framework will openthese high-fidelity process simulation packages for engineersand researchers to test, implement and tune advanced processcontrol strategies, in both offline and online scenarios.

I. INTRODUCTION

In the current processing industries such as refineries,petrochemical and food industries, improving the plant ef-ficiency has become more challenging since the scale ofprocesses has become larger, process complexity has dra-matically increased, as well as the increase in environmentalimpacts. Furthermore, knowing how to help operators tohandle the plant safety and deal with abnormal operationshas become more difficult due to the lack of critical mea-surements, i.e. compositions and a lack of understanding ofthe dynamic behaviour changes driven by various resources.Dynamic simulation provides an efficient and economicalway to help industries to solve these challenges. Sincedynamic simulation combines the knowledge of multipledisciplines it can be used for various purposes such asanalysis, optimization, control and training/education. Today,the mature application of process dynamic simulation bringsus as close as possible to the real process. This allowsengineers to integrate process design, technology, control,operation, safety and environment together through dynamicsimulation.

Recently, simulation technology has used for multiplepurposes; for example, operation start-up and shutdown [1],[2], [3], process optimisation [4], [5], [6], [7] and processcontrol [8], [9]. An extension of process simulation tech-nologies in the process industry is to develop an onlinedynamic simulator. By taking all existing measurements fromthe plant, it can provide much more valuable predictionswhich cannot be measured in economical and/or easy ways.

1Chemical and Materials Engineering Department, The University ofAuckland, New Zealand

2 School of Engineering, Computing and Mathematical Sciences, Auck-land University of Technology, New Zealand

Since the models are developed based on physical andchemical laws and validated by the process data, the modelsenable reliable dynamic characteristics of the processes tobe modelled. However, the application of online dynamicsimulation is often performed in isolation from an APC layer,thus limiting it’s use in control.

Usually a commercial dynamic simulator such as HYSYSdoes not provide the flexibility for implementing differentcontrol strategies such Model Predictive Control (MPC) oruser defined APC algorithms. This significantly limits theusage of the online dynamic simulations to informationreporting and measurement validation only, and does notcomplete a feedback loop for closed-loop control. Previousimplementations have attempted to address this limitation bycombining the dynamic simulator with sophisticated proto-typing software e.g. Matlab. In [10] the authors have usedMatlab to capture the input-output data from the simulationmodels to build approximate models which can be used insimpler Matlab-specific simulations. An integrated, real-timecomputing environment was successfully developed to linkHYSYS and Matlab by Excel for education purposes in [11].The environment provided detailed development procedureswhich can be easily reproduces by other researchers in publicdomain. Yokogawa engineering team developed its in-houseon-line dynamic simulator: OmegaLand, which was appliedto real industrial plants [12], [13].

This paper presents a way to connect the powerful proto-typing software Matlab to the commercial dynamic simulatorHYSYS via a middle layer provided by Microsoft Exceland set of VBA scripts. This software integration allowsresearchers and engineers to have the flexility to test, tune,and implement different control algorithms on high-fidelitynonlinear process models. The successful development alsoprovides the first step for the broad application of onlinedynamic simulations.

II. ONLINE DYNAMIC SIMULATION WITH SOFTWAREINTEGRATION

In order to implement an MPC controller in Matlab that iscapable of controlling a simulation in the simulator software,there is a need to send and receive information between thetwo programs. Microsoft Excel provides a convenient script-ing layer via VBA macros that enables a set of extensivelibraries for communicating with each of these programs,so it was chosen as a communication hub for the MPCenvironment.

The framework was designed so that Microsoft Excel isused as the user interface. The user can input all simulationparameters such as how long to run the simulation for, the set

6th International Symposium onAdvanced Control of Industrial Processes (AdCONIP)May 28-31, 2017. Taipei, Taiwan

978-1-5090-4396-5/17/$31.00 ©2017 IEEE 360

Page 2: Software Integration for Online Dynamic Simulation

points for the outputs and how they change during the simu-lation, the measured and unmeasured disturbances, weightingparameters for all inputs and outputs, and all constraintsincluding inputs, outputs, soft constraint configuration, andrate of change constraints. The simulation is then initiatedby running a macro from the Excel interface. The VBAmacro sends the current outputs from HYSYS, the measureddisturbances, and the set points to Matlab where its used tocalculate the next optimum plant inputs for control. Theseinputs are then sent to the HYSYS simulation along with themeasured and unmeasured disturbances so that the HYSYScan calculate the outputs at the next control step time. Theresults for the inputs and outputs are sent to Excel throughoutthe simulation to record the results for later interpretation. Abasic representation of the transfer of data between programsis shown below.

Fig. 1. Software integration diagram

A graphic user interface (GUI) developed in this work wasillustrated in Figure 2.

Fig. 2. GUI of the proposed software integration

A diagram of how the VBA macro is executed is illustratedin Figure 3. The number of control steps, time betweencontrol steps, set points, disturbances, weighting parametersfor inputs and outputs, and constraints are all set by the userin the Excel user interface before the macro is run.

A. Issues with implementing a Matlab-HYSYS MPC environ-ment

One of the major issues with using one program tosimulate the plant (HYSYS) and another to run the MPCcontroller (Matlab) is getting the programs to run in sync.The MPC controller takes in the measured plant outputs anddisturbances in order to calculate the next optimum inputs.

Fig. 3. Signal flowchart for the proposed software integration

Therefore, the time taken to calculate the inputs must beshort enough so that the states of the plant do not changefrom what the controller is using. If the calculation timefor the controller is too long, the inputs are calculated for astate that no longer represents the plant at the time they areimplemented.

In a real chemical process plant situation, the time con-stants of the system are generally quite longer so that controlsteps are minutes apart. Linear MPC solvers take relativelylittle time (<1 second) so that delays are insignificant.However, plant simulations on HYSYS usually are run muchfaster in order to save simulation time. This makes the delayof the MPC solver more significant. In order to ensure theplant simulation and MPC solver were run in sync, thesimulation was paused each time the MPC solver was run.This was achieved by manually running the simulation inHYSYS for a predetermined number of steps, then once theintegration step was complete, the next control inputs werecalculated in Matlab, sent to HYSYS, and then the integratorwas instructed to run again for the same number of steps.

B. Issues with stopping the HYSYS integrator

In the paper [11] the authors present a simulation envi-ronment that uses VBA to communicate between rigorousdynamic models in HYSYS and advanced process controllersin Matlab. Their method works in one of two ways, either byrunning the HYSYS simulation continuously during control,or by stopping the simulation integrator between control

361

Page 3: Software Integration for Online Dynamic Simulation

steps.With running the simulation continuously for advanced

control, we run into an issue of having a delay betweenwhen the Matlab controller reads the current state of thesystem and when the outputs are calculated and sent backto the HYSYS model. By running the simulation fasterthan real time, this issue becomes worse. On one handit is desired to run the simulation as fast as possible tosave time, but the faster the simulation runs the greater thedelay between plant state measurements and control moves.This issue can usually be resolved by using the secondmethod, stopping the simulation integrator between eachcontrol move. Although this works well for simulations withsimple control structures, we experienced problems whentrying to apply it to a complex multi-component distillationcolumn simulation. We identified that when the integratoris stopped, some information for the dynamic simulation islost. In our case, the slave PID controller states were reseteach time the integrator was stopped and restarted. When theintegrator was started again, the slave PID controller wouldact to change the state of the system in a way that would nothappen in a real plant (or if the integrator was not stopped).It was shown in Figure 4.

Fig. 4. Issues with stopping the HYSYS integrator

The red lines on plant outputs represent the time where theintegrator was stopped and restarted. It is clear that there wasa significant system upset due to restarting the integrator.

It was clear that when running the simulation at anaccelerated rate that it would be necessary to stop thesimulation between control steps. However, when stoppingand restarting the integrator we must have a method thatensures the results and information are stored properly.

To solve these issues, we developed a new method of con-trolling the HYSYS simulation in VBA. Instead of sendingcommands to run the simulation in Auto mode indefinitely,we set the integrator to manual mode so that we could solvethe simulation for a pre-determined number of integratorsteps without actually stopping the integrator.

In this way, we can send commands from VBA to force theintegrator to solve for a certain number of steps equal to the

time between a control step, once the simulation has solvedthese steps it waits until a command is sent to solve moresteps. While the integrator is waiting, Matlab reads the plantstates and calculates the new inputs for the HYSYS modelbefore sending the next lot of integration steps to solve.

To ensure that this method of pausing the integrator didnot cause a system upset, we run the simulation withoutchanging any inputs and paused and restarted it using ourmethod. The results are shown in Figure 5.

Fig. 5. Issues with stopping the HYSYS integrator

Figure 5 shows that there was no longer a system upsetupon pausing and restarting the integrator. The observednoise in the two cases above are due to the normal operationof the slave controller.

C. Custom MPC controller vs Default HYSYS Controller

HYSYS comes with an effective constrained linear MPCcontroller, although this has a number of limitations. Forinstance, the tuning parameters for the controller are limitedto a single weight for all inputs and another for all outputs.In many cases it is desired to control one output a lot closerthan another, for example if we are controlling the recoveryof a product while maintaining its composition it may bedesired to maximise the recovery while sacrificing its qualityso long as it maintains in spec. It can also be economicallybeneficial to change one input more than another such aswhen changing one input adversely affects other areas in theplant. By using a separate MPC controller such as the jMPCToolbox in Matlab, we can adjust the weight of individualinputs and outputs to give us greater freedom on optimisingcontrol of the plant.

The jMPC controller which was developed by Currie(2009) [15] also allows the use of soft output constraints.These constraints can be broken in the controller at the costof penalising the MPC cost function to a set amount, knownas the soft constraint slack. This is a helpful tool for extremesituations where a constraint must be broken as it allows thecontroller to continue to function and get back within theconstraints as soon as possible.

There is also the possibility for a range of complex MPCconfigurations to be implemented. For example, one could

362

Page 4: Software Integration for Online Dynamic Simulation

include dynamic tuning parameters and constraints that putdifferent weights on the inputs and outputs of the controllerdepending on the state of the system. This would be benefi-cial for situations such as when other processes in the plantlimit out ability to manipulate certain plant inputs (e.g. ifanother process requires a higher steam flowrate then wehave less immediately available to provide to our process).Other possibilities for this environment include the ability toimplement a Nonlinear process model and optimiser to makebetter predictions on process responses. This would be veryuseful for highly nonlinear unit operations that have tightoperating constraints.

III. CASE STUDY

We will demonstrate the proposed software integrationframework via a methanol distillation dynamic simulation.In the methanol distillation model a multi-component feedof methanol, water and ppm levels of ethanol, is refined toachieve a tight high purity product and bottoms (ppm levels)and high methanol product recovery (≥ 97.5%). The detailednominal operating conditions in this study are listed in TableI. The nominal feed fracitons are 83% methanol, 150 ppmethanol, 17% water and 95 ppm isobutanol.

TABLE IMASS FLOW RATES FOR COLUMN OPERATING AT 97.7% RECOVERY.

stream mass flow in kg/hFeed F 142000Distillate D 114600Side Draw S 3113Bottoms B 24287

The distillation column was built in HYSYS in [14].The data provided by industry and the model show goodconsistency for the essential variables, like product ethanolconcentration, bottoms methanol concentration, energy input,mass flows and the composition of the side draw.

The jMPC environment was implemented on a high puritymulti-component Methanol refining column. The controlledvariables for the column are the amount of Ethanol in thedistillate (limited to below 10ppm to remain in spec) andthe weight recovery of methanol (flowrate of methanol indistillate / flowrate of methanol in the feed). The manipulatedvariables for the column are the set point of the ethanolcomposition control loop on the distillate stream which is astandard PID loop with the distillate flowrate, and the reboilerduty of the column. The proposed MPC control scheme isillustrated in Figure 6.

A. Set-point change

The simulation was run for a step change in the recoveryfrom 99.6% to 99.7% while maintaining the set point forethanol at 8ppm. The tuning parameters were set up to tightlycontrol the recovery while sacrificing the ethanol content inthe distillate, a higher weight was also given to the ethanolcontroller set point compared to the reboiler duty to minimisethe power input to the column.

Fig. 6. Schematic MPC control for methonal distillation column

Fig. 7. Disturbance responses from the proposed software integration

B. Disturbance rejection

A feed flowrate step increase disturbance was used to testour algorithm. The CV and MV movements were plottedin Figure 8 and 9 respectively. In these figures, the legend‘plant’ represents the CV values from the model and thelegend ‘model’ represents the values from the Matlab transfermodel which was estimated from the simulation.

IV. NEXT STEP: ONLINE DYNAMIC SIMULATION

A significant issue with many process operations is thedifficulty in measuring certain outputs on line which wewish to control. For example, it is very difficult to measurecomposition on line for distillation columns. Traditionallypeople have used soft sensors such as temperature probesto estimate composition for distillation, although this is notpossible for high purity columns such as that described abovebecause impurities in the range of ppm do not register ameasurable temperature change.

It is possible to incorporate a rigorous process modeldeveloped in a simulator software as soft sensors where inputdata are received alongside measurable plant outputs in order

363

Page 5: Software Integration for Online Dynamic Simulation

Fig. 8. Disturbance responses from the proposed software integration

Fig. 9. Disturbance responses from the proposed software integration

to estimate unmeasurable process dynamics. A softwareintegration of an online dynamic simulation is illustrated inFigure 10.

In the case of a high purity Methanol refining column,the measured outputs would include pressure, temperature,and flowrates of streams. These would be sent to the modelto estimate the stream compositions to be used in thecontroller. This has the benefit of a rigorous model to makeoutput estimates, and a linear model to quickly calculate theoptimum plant inputs for control.

V. CONCLUSIONS

The development of the software integration of a dynamicsimulator and Matlab for advanced process control wasproposed. The implementation of the proposed softwareintegration on the methanol distillation column shows aneffective framework between the two packages can be de-veloped, and the proposed control strategy out-performedthe existing built-in simulator MPC controller. This workaims to accelerate the use of dynamic simulators from off-

Fig. 10. Schematic MPC control for methonal distillation column

line to on-line, by enabling robust APC packages to be usedin conjunction with high-fidelity simulators and a flexiblemiddle layer that can interface to real-time process data.

REFERENCES

[1] X. Yang, Q. Xu, K. Li and C. Sagar, Dynamic simulation andoptimization for the start-up operation of an ethylene oxide plant,Industrial & Engineering Chemistry Research, vol. 49, no. 9, pp. 4,4360, 2010.

[2] F. Reepmeyer, J.U. Repke and G. Wozny, Time optimal start-upstrategies for reactive distillation columns, Chemical EngineeringScience, vol. 59, pp. 4339, 2004.

[3] I. Iliuta and F. Larachi, Modelling simultaneous biological cloggingand physical plugging in trickle-bed bioreactors for wastewater treat-ment, Chemical Engineering Science, vol. 60. pp. 1477, 2005.

[4] T. Tosukhowong, J.M. Lee, J.H. Lee and J. Lu, An introduction toa dynamic plant-wide optimization strategy for an integrated plant,Computers and Chemical Engineering, vol. 29, pp. 199, 2004.

[5] D.R. Alistair and D.I. Gerogiorgis, Multi-objective process optmisationof beer fermentation via dynamic simulation, Food and BioproductsProcessing, DOI: 10.1016/j.fbp.2016.04.002, 2016.

[6] F. Calise, D. Capuano and L. Vanoli, Dynamic simulation and exergo-economic optimization of a hybrid solar-geothermal cogenerationplant, Engergies, vol. 8, pp. 2606, 2015.

[7] L. Han, Dynamic simulation, optimization and control of flexiblechemical-looping combustion, Ph.D. dissertation, University of Con-necticut, Connecticut, USA, 2016.

[8] J. Hahn, T.F. Edgar and W. Marquardt, controllability and observabilitycovariance matrices for the analysis and order reduction of stablenonlinear systems, Journal of Process Control, vol, 13, pp. 115, 2003.

[9] S.I. Biagiola, J.L. Figueroa, Application of state estimation basedNMPC to an unstable nonlinear process, Chemical Engineering Sci-ence, vol. 59, pp. 4601, 2004.

[10] T.T. Tuan, L.D. Tufa, M.I.A. Mutalib, A.F.M. Abdallah, Control ofdepropanizer in dynamic Hysys simulation using MPC in Matlab-Simulink, Procedia Engineering, vol, 148, pp, 1104, 2016.

[11] J.H.V. Lee, D.G. Olsen, B.R. Young, W.Y. Svrcek, An integrated, real-time computing environment for advanced process control develop-ment, Chemical Engineering Education, pp, 172, 2001.

[12] G. Fukano, Y. Onoe, M. Nakaya, T. Ohtani, appplication of trackingsimulator to steam reforming process, Yokogawa Technical Report,No. 43, pp.19-32, 2007.

[13] M. Nakaya, G. Fukano, Y. Onoe, K. Watanabe, T. Ohtani, On-linesimulator for plant operation, SICE Annual Conference 2005, pp.3811-3815, 2005.

[14] I. Udugama, R. Kirkpatrick, R., W. Yu, B.R. Young, High puritydistillation column: Simulation and optimization. Paper presented atChemeca 2013, Brisbane, Australia, Sept. 29 - Oct. 2, 2013, paper30270, 2013.

[15] J. Currie, Practical Applications of Industrial Optimization: FromHigh-Speed Embedded Controllers to Large Discrete Utility Systems,Ph.D. dissertation, Auckland University of Technology, New Zealand,2014.

364