MP in Action‎ > ‎Oil Industry‎ > ‎

Representing Time in Refinery Models

This article concludes the exposition of how Mathematical Programming is used in oil refineries by exploring the phasing of activities through time. Preceding articles were Mathematical Programming in the Oil Industry, Planning and Scheduling in Oil Refineries and Modelling Oil Refineries using Linear Programming

Operations in an Oil Refinery

An oil refinery is primarily a continuous process. Crude oil is pumped in continuously to the Crude Distillation Unit (CDU) where it is boiled. As with so much of industry, what was originally a batch process (think of boiling a kettle) has been superseded by a continuous process in which feed is continuously added and products continuously drawn off.

But although crude oil is fed continuously to the CDU, the quality of that crude oil changes over time. Refineries process a variety of crudes, depending on their availability and marginal economics. Some refineries will take part of their feed from pipelines which are connected directly to the oilfields, in which case there is greater stability of feed. In western Europe, howver, this usually forms no more than half the crude processed. Even in the Middle East, refineries supplement their domestic crudes with cargoes of imported ones, in order to be able to make a wider variety of products.

While crude from a pipeline may be fed directly to the CDU, cargoes of crude are delivered in tanker loads and stored in enormous tanks. The supply of crudes to the CDU is thus a batch operation. Typically only one tank feeds a CDU at a time and it is run down to (almost) empty before the feed is switched to another tank. Although it is a simplification, it is usually considered that the contents of a tank are homogeneous and of uniform quality and that there is a step change in quality when the feed switches from one tank to the next.

When the quality of the crude changes there are consequential changes in the quantities and qualities of the materials being produced from the CDU and downstream of it. These changes do not occur instantaneously: crude takes several hours to pass through a refinery, but the dynamics of the changeover are complex and are not modelled. A change of crude may necessitate changes to the processing conditions and to the rates of operation of the CDU and the other process units.

While most process units can be considered to work synchronously with the CDU, varying their conditions when the CDU does, some units work asynchronously.

An example is the reformer unit, which increases the octane of light oils which are one of the main components of petrol. This may change from producing 95 octane reformate to producing 98 octane reformate completely independently of other activities in the refinery.

Blending activities are also carried out completely separately from the main processing activities. As with the crude tanks and the CDU, the practical logistics of tanks and pipework intrude. Although some products may be blended directly into the holds of ships, it is more usual to make up the blends in product tanks in the refinery. This gives rise inevitably to a sequence of operations in which individual tanks of products are blended one after another. There are usually several areas of the refinery which work independently of each other, e.g. petrol blending, middle distillate (diesel, domestic heating oil, etc) blending, fuel oil blending.

Decision Variables as Snapshots

An LP model consists of a number of decision variables which are related to each other by the constraints. Typically these decision variables represent the rate at which some material is being processed or how much of some component is used in a blend.

In building a model we need to define all our terms very precisely. Let us consider a decision variable which represents the rate at which some material is being processed. This sounds like an instananeous snapshot of what is happening now. If we are to relate this decision variable to others which measure the consequences, it follows that we shall need to have a series of decision variables which are all telling us about the rates at which activities are taking place in our snapshot.

There are some circumstances in which this is just what we do: we build a model of the refinery which represents its activities in a snapshot. Ironically, such a model is used for long-term planning. This is because a snapshot freezes time. The stock level in each tank is constant during a snapshot, so it is of no interest whether we are building up or running down stocks and if so, at what rate.

Stock levels are only important if they enable us to do things which we otherwise could not. For instance we may wish to be able to supply a cargo of some product when a ship docks. That cargo may represent several days' production, in which case we must build up the stock in advance. When we are processing one crude we may also wish to build stocks of some component which we can make from that crude but not from a subsequent crude.

If we are doing long-term planning we are concerned with what the refinery can produce and which products its should be supplying to which markets. Stocks are then irrelevant and so we build a model which represents a snapshot of the refinery's activities and in which we ignore stocks altogether.

Scheduling Models

By contrast, if we are engaged in short-term planning and scheduling, one of our main concerns is having sufficient quantities of products available to meet the export schedule. We are therefore concerned with stocks and how they vary through time. It follows that we need to represent the passage of time in our model. How should we do this?

The usual approach is to define a schedule period and divide it into a number of time periods whose lengths we define. We shall consider below how we determine the length of the schedule period and divide it into time periods. For each activity (processing, blending, etc) we then define separate sets of decision variables for each time period.

One way of looking at this is to say that we assume that all the activities within a time period take place at a constant rate throughout that time period and that at the end of that time period they then switch to a new set of rates. Rather than defining decision variables for the rate at which we build stocks during a time period, we usually define decision variables for the stock levels in each tank at the end of each time period and constrain them to lie within the tanks' physical limits.

In fact, as we have seen, activities in a refinery do not occur continuously at a constant rate for an extended period of time. It is therefore better to consider our decision variables as average rates at which activities are performed during the time period. There is then some imprecision about this and it leaves some of the detailed scheduling to be worked out by the refinery staff. But they are better placed to understand exactly how their refinery works and there are other tools which are more appropriate to tackling these issues, e.g. detailed refinery simulators.

There is one class of activities which do not occur continuously but which we can represent directly within an LP model. This is the arrival of a cargo of crude at some specified date or the export of a cargo of product at some specified date. Note the words "at some specified date". If we know when the activity takes place we can construct constraints which compute the quantity of material in the tanks immediately before the import or export and the quantity immediately after (see Figure 1). We constrain these quantities to lie within the physical limits of the tanks thereby ensuring that we are able to receive the import or make the export.

Figure 1: Stock Levels through Time with Exports

Selection of Time Periods

Most refineries work with some form of monthly rolling schedule. Each month they prepare a schedule of their activities over, say, the next three months. The first month is fairly firm but the second and third months are preliminary indications rather than hard forecasts.

Within the forthcoming month they may use a system of weekly rolling schedules. The first week is a firm plan for the forthcoming week but subsequent weeks are less certain.

Such an approach would be reflected by having a planning model to support the preparation of the monthly rolling schedules and a more detailed model for the weekly rolling schedules. There might be three 1-month time periods for the former and perhaps 5 time periods for the latter.

Often the first couple of time periods in a detailed scheduling model reflect what is happening with the crude tanks. The first time period will end when the crude tank which is currently feeding the CDU becomes empty. The length of the second time period corresponds to the time for which the CDU is expected to be processing crude from the next crude tank.

Beyond these time periods there is less certainty: the crude tanks may not have been scheduled and there may be changes to the imports and exports. In any case, the model will be run again before those time periods have been reached. There is therefore no reason to continue with short time periods which give a false impression that we are deciding exactly what we shall be doing some weeks hence. We prefer to keep things simple and avoid unnecessary increase in the size of the model.

Why then, do we bother at all with time periods beyond the immediate future? It is because optimisation models will do whatever they can to achieve the best solution. In a refinery this means running down stocks of the more desirable materials and building up those of the less desirable. Later time periods help to reduce these effects by requiring the model to do something sensible beyond the time periods of immediate concern.

These practices, of using a hierarchy of models with rolling time horizons and of defining subsequent time periods of longer durations to protect against end effects, are widely used in LP modelling. They reflect the way in which many planning and scheduling problems are tackled, whether the decision-making is being supported by optimisation models or not.

Related articles include Modelling Oil Refineries using Linear Programming and MIMI Brings OR Tools Together. To find other articles, refer to the MP in Action page.