Professional Documents
Culture Documents
AMOSS: A Bespoke Stochastic Simulation Environment Built On Open Source Software
AMOSS: A Bespoke Stochastic Simulation Environment Built On Open Source Software
Abstract—Sasol’s Operation Research department developed complex when output streams are recycled back into the value
their own discrete event flow-sheet simulation methodology to chain. In such cases, a change can have a big impact on a
Model Operations using Stochastic Simulation (MOSS). This completely different part of the operation, making it difficult
generic methodology is not restricted to Sasol, but can be for the plant Subject Matter Experts (SME) to envisage the
applied to any type of continuous process operation. In Sasol’s impact and even harder to quantify the impact which is always
case, MOSS has been so successfully applied that new process
required for the motivation of Capital Expenditure (CAPEX).
modifications will hardly be done without a MOSS simulation.
However, these simulations require handling multi-component This is an example where process simulation can be applied
flows with material recycle as well as optimal allocation to units with great effect. Since the model must be able to simulate
based on their capacity and profitability, resulting in complex plant availabilities, operational philosophies (rules and heuris-
models which require long development times. Commercial pack- tics operators use to run the plant) and storage vessels, the
ages were evaluated to improve model development time using model must be dynamic, stochastic and heuristic in nature.
the MOSS methodology, but they did not comply with these
requirements. Automatic Modelling Operations using Stochastic
Over the years, Sasol has developed a modeling methodology,
Simulation (AMOSS) is a bespoke simulation platform developed Modeling Operations using Stochastic Simulation (MOSS) [1],
to fit the MOSS requirements using free/open source software. to determine the impact of modifications on value chains. The
It is equation-oriented (as opposed to sequential modular) and strength of such a simulation lies in the ability to quantify
automatically generates mass and component balance equations the impact of a change over the whole value chain and in
from user-generated process connectivity diagrams and operating the process reduce the amount of subjective decision-making.
unit specifications (reactor conversions, separator efficiencies and However, MOSS does not easily deal with value chains that
simulation-specific variables). It can allocate flows based on have tightly coupled feedback loops where resource optimiza-
unit operating rules (unit priorities and capacities). Stochastic tion is a prerequisite.
elements are introduced with user-defined distributions based on
actual plant data. Before automation, the existing simulation method had
Keywords–stochastic simulation; Monte Carlo; flowsheeting; to be extended by hand to simulate the operation with an
equation-orientated; equation ordering. acceptable level of accuracy. The modification included a
number of complex mathematical formulae that had to be
I. I NTRODUCTION derived, programmed and tested. This added a significant
amount of model development time, resulting in a delayed,
Sasol is an integrated energy and chemicals industry in but accurate set of results. This triggered the search for an
South Africa and leads the world in producing liquid fuels from alternative set of stochastic simulation tools.
natural gas and coal. The whole operation can be grouped into
a number of value chains. A value chain normally consists of a A number of alternative software tools were identified,
group of interlinked plants, designed to produce a basic com- but due to time constraints, Sasol was not in a position to
ponent which is then distributed and converted by consumer complete a proper study. Hence, the University of Pretoria
plants into value-added products, which are then supplied to was contracted to submit a modeling solution. The existing
their respective markets. The value chains and their external stochastic model [2], the existing optimization model and the
influences are studied and improved as a unit prevents the local existing steady state model were handed to the University as
optimization which results when only individual plants are usable references.
optimized. Factors such as limited plant capacity, insufficient The rest of this paper is organized as follows. Section II
plant availability and sub-optimal operational philosophies are describes the performance criteria used to guide development.
often the main constraints. A value chain can become quite Section III discusses decisions made about the software devel-
opment environment used to develop the simulation software. III. S OFTWARE D EVELOPMENT
Section IV lists and explains the steps involved in developing The current Sasol value chain models that make use of the
a simulation using AMOSS. Section V elaborates on some MOSS methodology are developed in MS Excel using VBA
of the steps to include information about the implementation. [3] but fail some of the simulation environment requirements
The conclusion summarizes the achievements of the project mentioned. Most notably, the current solution requires manual
compared to the performance criteria and suggests future work. rewriting of equations in order to satisfy continuity equations
II. S IMULATION E NVIRONMENT R EQUIREMENTS balances. Additionally, heuristics must be embedded in the
simulation code manually in order to do optimal unit allo-
Sasol proposed the following list of performance criteria cation.
for the new development environment. Note that the re-
quirements are not completely independent. For example, an Alternative simulation platforms, namely Simio [4] and
increase in accuracy can lead to an increase in development AnyLogic [5] were investigated, but they did not allow for
time. the simulation of continuous multi-component process streams
with optimal allocation at each time step. Both packages have
Development time: The simulation environment must re- the ability to simulate continuous process flows and Simio has
duce development time compared to manual equation rewriting the ability to do splitting of streams to maximise throughput.
and not be affected by the complexity of the model. The operating philosophies of the Sasol plant, however, call
Accuracy: The model must be appropriately accurate and for more widespread optimisation at each time step than these
the accuracy must be independent of the complexity of the packages supply without custom development.
value chain AMOSS is built using mainly open-source tools. It is
Linear scalability: The resulting simulation must scale written in Python [6], the graphical flowsheeting is done in
linearly with the number of units. Open Modelica’s Connection Editor OMEdit [7] while the
Development flexibility: New scenarios that require mod- Atom [8] text editor facilitates additional user inputs. Although
ification to the existing model must be easy and simple to not open source, Microsoft Excel [9] is widely available and
incorporate. used as an interface for editing tabular data.
Simulation time: The simulation execution time must be The open source technologies allow for simple modifica-
short which will ensure that sufficient replications per scenario tions to accommodate the needs of the platform.
can be run as well as more runs during model validation
and verification. Target simulation time should be less than IV. M ODELING AND S IMULATION W ORK -F LOW
3 minutes per replication consisting of 70000 time steps. The basic work-flow of AMOSS is illustrated in Figure 1
Package stability: The model must calculate a value for and descriptions of the steps are as follows:
each variable in each time increment for all replications in all Step 1 requires the user to draw a process diagram in
the scenarios. OMEdit together with operational unit-specific data in Excel.
Generic application: The solution must be able to model The unit library contains the unit operations of concern in the
any value chain in Sasol irrespective of the combination and Sasol value chains (Buffers, Reactors, Pipes and Separators).
configuration of plants, which imply that the existing legacy User inputs such as a component list, flow rates, separator
models will be converted to the new modeling solution. splits, buffer sizes and reactor conversions are entered during
Debug capability: The solution must be able to guide this step.
the user to locate a bug in a faulty model and requires the Step 2 takes the OMEdit diagram which contains the
recreation of an error situation in the same replication and process connectivity and operational unit information and
scenario in which it had occurred. parses it into a network graph. Using graph theory, a graph
Fit for purpose: The modeling environment must be table is generated containing the connectivity and attributes of
focused on supporting the stochastic modeling methodology the process units.
of the Sasol and allows for ability to add additional features Step 3 iterates through the graph, creating all the necessary
and plants. equations automatically. These equations are categorized as
Learning curve: A quick learning curve is required for component mass balance equations, total flow equations, mix
the model developer, but it is accepted that the learning curve point equations, reactor equations, separator equations and
for the software tool developer will take longer. buffer equations.
Version control: As more than one person can use the Step 4 tears the equations using the block lower triangular
same model at any time, the solution must allow for simulta- method and symbolically solves the smaller blocks to lower the
neous modification and development in a controlled manner. stiffness of the system of equations, making it easier to solve.
Cause identification: When simulation results are counter- Prior to pre-solving equations, a degree of freedom (DOF)
intuitive, the tool must allow the user to explain the results by analysis is done to ensure that the system is not under- or
relating causes and effects. The tool must also assist in finding over-specified.
bottlenecks. Step 5 requires the user to define additional equations to
Software Cost: Simulation packages are expensive and it describe how the unit is operated (operating rules) together
will be difficult to justify purchasing a new simulation tool with identifying which variables or parameters are stochastic
which will only partially solve Sasol’s problem and therefore and provide a distribution. These rules are typically the unit
the initial cost as well as the annual maintenance cost must constraints (minimum and maximum capacities) of the units,
thus be low. as well as the feed distribution priority between multiple units
receiving feed from the same source. The stochastic element’s a library of operations. The building blocks are as follows:
distributions are also specified by the user during this step. Source is the location where mass enters the
Step 6 takes the system of equations in Step 4 and concate- simulated process.
nates it with the equations in Step 5 and tears these equations,
using the bordered block lower triangular method, producing Sink is the location where mass exits the simu-
the full system of equations. The bordered lower triangular lated process.
form of the system of equations requires less variables to be Mix Point is an operational unit where streams of
solved simultaneously compared to the unordered system. A different compositions are mixed and the streams
model is created from the ordered system and is solved using leaving the Mix Point all have the same compo-
numerical root-finding software. sition.
Step 7 simulates the process for all active scenarios for the Buffer is a tank or accumulator within the pro-
number of required replications. Results generated are written cess.
to a file.
Reactor is an operational unit where components
can be converted to different components.
Pipe is a block used to give streams names and
indicate the flow direction.
Separator is the operational unit that models
a distillation column. The block splits incoming
streams into multiple streams with different com-
positions.
Visual Unit is used to indicate a conglomeration
0
TABLE IV. E XAMPLE OF HOW A USER CAN DEFINE A DISTRIBUTION . a file 15 times smaller than a CSV file. BLT ordering Block
lower triangular ordering was used to increase the simulation
Discrete 0 speed. The improvement seen by implementing BLT tearing is
value P due to the reduction in the number of variables that need to be
0 0 solved numerically. CasADi The implementation of CasADi
1 0.0625
shows the power of derivative information. Parallel Process-
ing The simulations of AMOSS are embarrassingly parallel
2 0.125
(the scenarios can be simulated completely independently of
3 0.1875
one another). Celery [14] is used to distribute the load of the
4 0.25
scenarios.
5 0.1875
6 0.125
Figure 6 shows the effect of each of these improvements on
the simulation time. Parallel processing scales all these times
7 0.0625
by a constant factor for each CPU used.
8 0
Figure 4. Entry of user inputs via Atom. From top to bottom: Adding
comments, tab completion, syntax highlighting and error indication. Figure 6. Simulation runtimes of the AMOSS test process with the
cumulative improvements
20 20
40 40
A. Achieved requirements
60 60
The deliverables that are satisfied by AMOSS are:
80 80