# Optimization of process simulations

Process simulations of pipeline networks usually require a slow manual analysis of the results. This article discusses how process models can be treated as functions and used in optimization algorithms, effectively automating the analysis of hundreds or thousands of simulations.

Liquid produced from onshore wells are held in storage tanks until they can be pumped to an export line. As a field grows, the pressure in this export line increases as it handles more liquid from more wells. Pumping operations are not coordinated between the different wells and eventually the maximum allowable operating pressure (MAOP) is reached in the export line triggering a shutdown or creating unsafe operating conditions. Assured Flow Solutions built a proof-of-concept solution by running a hydraulic simulator through optimization algorithms. The results are a reduced export line pressure and a coordinated pump schedule.

The hydraulic model was programmed in Modelica. Modelica is a hierarchical, object-oriented, equations-based programming language. The primary use of the language is to solve the time dependence of physical systems. For our case, we’re interested in building a small network of onshore wells, pumps, storage vessels, and pipelines.

The wells are modeled as a simple flow source to the storage tanks. The level of the storage tanks is sent to an on-off controller with its output signal connected to a pump. The well, pump, tank, and controller constitute one source to the export line. For this project, three of these sources are configured in parallel.

At this point, the model will run forward in time but will exceed MAOP once all 3 pumps begin draining into the pipeline. The next step is to optimize the set points for the controllers. There are many ways to design an objective function; for this case we keep it simple by minimizing the export pressure by adjusting the high level setpoint on the on-off controllers.

The Modelica code was developed in Wolfram SystemModeler®, which has interoperability with Wolfram Mathematica®. The model is imported into Mathematica where an optimization routine can be applied to it. The problem is constrained by limiting the liquid height to the tank height. Even though the on-off controller is a discrete process, the heights are continuous so a standard optimization method like Nelder-Mead can be used.

The optimization process takes only a few seconds, meaning as flowrates change day to day or hour to hour, the pumping schedule can be adjusted to keep the export line below MAOP. The optimization also shows that the export line can handle additional wells. Not requiring a second export line drastically reduces CAPEX calculations when considering the addition of wells to the field.