Wolfram Blog
Patrik Ekenberg

Releasing the OPCClassic Library

August 26, 2015 — Patrik Ekenberg, Applications Engineer, Wolfram MathCore

Explore the contents of this article with a free Wolfram SystemModeler trial.Wouldn’t it be great if you could easily connect your simulation models to your existing infrastructure? Whether you are working in industries such as oil and gas, industrial energy, or life sciences, connecting to your processes in order to monitor and control them is vital.

The OPC (Object Linking and Embedding for Process Control) standard has been developed by industry and the OPC Foundation just for that purpose. OPC is a set of data transfer standards for multi-vendor, multi-platform, secure, and reliable interoperability in industrial automation:

OPC illustarted as a set of data transfer standards

Today we’re introducing the OPCClassic library for Wolfram SystemModeler. The OPC library contains a full set of components for connecting to physical systems using the OPC Classic standard. The library makes it possible to connect to one or more OPC servers, and thereby your real-world processes.

Using the library to connect to servers

With the OPC library, you can set up communication with servers using easy drag-and-drop, just as with any other SystemModeler library. This makes it possible to incorporate production data from the real world into your models (for example, as block inputs or reference signals); write model data directly to OPC servers; monitor production data in real time; perform data analyses; and design control systems.

To illustrate the use of the library, I’ll use the master thesis project that I did for Wolfram MathCore and Linköping University this spring, in which I controlled a bioethanol production process. Here is a picture of me working with my reactor:

Patrik working with the reactor

Just like when you bake bread, to make ethanol you need mainly two things: sugar and yeast. Yeast are unicellular organisms that can multiply quickly provided the right conditions. Most importantly, the yeast needs sugar and oxygen in order to grow. When you bake bread, sugars (mainly maltose) are produced from the flour, allowing the yeast to grow.

The more oxygen you add, the faster the yeast can grow, while low levels of oxygen result in slower yeast growth but produce more ethanol. When producing bread, you want to maximize the yeast growth, but when producing ethanol you want to maximize the production of ethanol. So the main difference between the two processes is how much oxygen you supply.

When baking you have a lot of excess oxygen provided through the air, while in ethanol production the amount of added oxygen is controlled more rigorously.

The model diagram below is a model of the bioethanol process, developed with the BioChem library:

Model of bio ethanol process

To produce ethanol, yeast is combined with sugar-rich substrates (glucose and maltose) that over time are converted to ethanol, while the yeast cultures (biomass) steadily increase. The process is controlled by setting the amount of oxygen that is added. As mentioned above, low levels of oxygen will favor ethanol production and high levels will favor yeast growth.

In order to optimize the process, I wanted to investigate the use of model predictive control (MPC) to control the amount of oxygen supplied and hence the ethanol production. My goal was to construct a controller that worked on an industrial scale for a partner company, but that could be piloted in a lab setting.

To test my controller I used the model above and connected it to the rest of the system using the OPCClassic library:

Illustration of connecting model of bio ethanol process using OPC Classic Library

The MPC controller (bottom left in the picture above), implemented in Mathematica, controlled the amount of oxygen in the batch by adjusting the stirrer speed, while the online and high-performance liquid chromatography parts communicated with measurement equipment (in this case, measurements made in the model). With this setup, I could run simulations to see how the system behaved:

Running simulations to see how the system behaved

Now that I had managed to control the process using the model, it was time to switch in the real system. Instead of getting the concentration levels from my model, I took continuous measurements of yeast, sugar, and ethanol concentrations and supplied them to the controller. The system was run in real time and was set to communicate with the Mathematica-based controller through OPC. The figure below is taken from one experiment that I ran in the lab.

Experiment run in the lab

The leftmost graph shows the concentration of glucose (solid line), ethanol (dotted line), maltose (solid line, circles), and biomass (solid line, squares). The rightmost graph shows the dissolved oxygen (solid line) and temperature (dotted line).

You can see from the graph that the oxygen concentration is relatively close to a step function. In fact, the standard industrial bioethanol process today is to start by stirring air into the yeast and sugar mixture, allowing the yeast to grow and multiply, and then completely shut off the oxygen in order to produce the desired ethanol. I got similar behavior using the model predictive control.

There are many factors that might vary from one batch to another, including the concentrations of the sugars, the starting pH, and the concentrations of various nutrients. A model predictive controller should adjust to these varying conditions in order to produce more ethanol.

Now that we have demonstrated in the concept study that the OPCClassic library makes it easy to model the process, a cooperation between the companies Agroetanol and Iggesund, Linköping University, and Wolfram MathCore will continue with a full-scale project partially funded by Sweden’s innovation agency, VINNOVA.

Learn More

If you would like to try modeling with OPCClassic, it is available for trial or purchase in the SystemModeler Library Store. From the website you can also download a free trial of SystemModeler. For more ideas on what you can do with OPC, check out our collection of SystemModeler examples or visit our online Documentation Center, which hosts the full OPCClassic library documentation.

Posted in: SystemModeler
Leave a Comment

No Comments




Leave a comment

Loading...

Or continue as a guest (your comment will be held for moderation):