66f2d131b4b0d0c8fae18371 Shutterstock 2285340363 Converted

Realism for dynamic simulation for control testing

Sept. 24, 2024
Part one of this two-part article explains how to add environmental effects to your simulations

Understanding controllers, such as the benefits of cascade and reset feedback, came from my observation with simulations. It didn’t happen with abstract mathematical derivations, memorizing what's written or trial-and-error. Simulations are useful for evaluating and demonstrating the benefits of next-level, advanced regulatory control or model predictive control (MPC). 

I encourage you to use dynamic simulators to legitimately represent your process, and add environmental effects to the simulator (noise, drift, stiction, resolution) to make the simulation representative of what nature provides. 

Get your subscription to Control's tri-weekly newsletter.

A simulation including natural vagaries is termed a stochastic simulation. By contrast, most simulations are deterministic. By definition, a deterministic calculation returns the same value whenever or wherever you do it. For example, 3 x 4 = 12, whether you did the multiplication in fourth grade, or when astronaut does it today at the space station. A stochastic process, however, doesn't reproduce exact values. It produces a realization (a possible value) from a distribution of values. For example, roll a six-sided die and the values could be 1, 2, 3, … 6, each with a 0.166 probability. When your process is operating, nature doesn't keep the inlet humidity, fuel BTU content, ambient losses or catalyst reactivity constant. Also, nature contrives mechanisms that add noise to measurements. 

Run the tests you want to use on a stochastic simulation to evaluate controllers. Use both long periods at steady setpoints to determine process variability, setpoint changes that mimic changes in production rates, and product specs. 

From extended time simulation, measure the frequency and magnitude of specification violations and waste generation, and on-constraint events. Then, shift setpoints away from constraints and specifications, and tune controllers to make violations acceptable. Evaluate the process economics (throughput, costs of materials and energy, cost of upsets, etc). 

The deterministic simulator represents what we model as the truth about nature. In general, the exact rules and coefficient values that nature uses to generate data are unknown. To create a digital twin with appropriate fidelity to your process, you may need to calibrate your simulator—adjust coefficient values to better match the process data. Once you've calibrated a dynamic simulator, add the following features to better represent the control challenges. 

Simulating noise

Measurements are subject to noise, which are random perturbations of the true process output. Noise on measurements can come from several sources. One is thermal static from device electronics. Another is caused by electromagnetic influences from proximity machines on measurement transmission wires. A third is mechanical vibrations of a device. These are external to the process. However, the process might also generate noise-like deviations.

Flow turbulence causes pressure perturbations on a differential pressure measurement device. Boiling causes pressure perturbations and thermal variations on sensors in the two-phase mixture. Incomplete mixing downstream of an injection point causes composition fluctuations. Noise perturbations are independent and normally distributed. 

Commonly, the Gaussian (also called normal or bell-shaped) distribution is accepted as a representative model of noise. It represents the confluence of many random influences of equivalent impact:

ni = σ √[(-2ln (r1,i)] sin(2πr2,i)

Here, the variables r1,i and r2,i represent uniformly distributed, independent, random numbers on the 0 to 1 range (excluding 0), typically called a RAN or RAND function. And ni is normally and independently distributed with a mean of zero and standard deviation of σ. The subscript i represents the sampling counter, which is shown to explicitly indicate that the perturbation changes with each sampling. There's no need to include it in the simulator.

There are several approaches to including noise in a measurement. The most common is to consider the noise as additive to the true measurement. To simulate this, add the noise perturbation to the deterministic model output. Here, σ in the previous equation has the same units as the measured variable:

xmeasured,i = xdeterministic model,i +ni

Other noise models could consider that the noise magnitude scales with the variable. This may be relevant in flow rate measurements, when the intensity of process turbulence is proportional to flow rate, or when process gains could characterize the noise. For example, in pH processes, measurement noise might be due to imperfect mixing, with base-rich and acid-rich fluid packets passing the sensor. In a strong-acid/strong-base mixture, pH sensitivity to composition is high in the near-neutral (pH = 7) region, but low in the far-from-neutral ranges (pH < 5, or pH > 9). Finally, in some processes, noise isn't symmetric. The “plus” deviations may be larger or smaller than the “minus” deviations, and may need an alternate function to generate skewed noise. 

You must understand the sources of random noise in your process measurement to be able to choose a noise model. You need to choose a value for  in the first equation. The 5 σ range includes about 99% of all values. So, if you use your experience for the range of normally noisy values when the process is at steady state, set σ to be one fifth of that range:

σ ≅ Range at SS/5 = xSS noisy high-xSS noisy low/5

In my experience, there is no justification to determine the exact value for σ. It takes time, and the actual noise your process generates will likely not be exactly Gaussian. 

In the third equation, don't use the range of possible process values. Use the range of the perturbations at steady state. For example, the speedometer on an automobile might have a noisy display with a  of about 0.1 mph, so at 55 mph, the display fluctuates between 54.75 and 55.25 mph. The same vehicle might have a speed range of 0 to 80 mph. Incorrectly using the speed range implies the measurement noise has a standard deviation of 16 mph, indicating that at 55 mph the display would fluctuate between 15 and 95 mph.

Simulating resolution

Resolution is the smallest reportable change in a signal. Your digital watch might reveal the time in seconds, and report that time persists at 11:15:26, until it jumps to 11:15:27. Time did not stop for the duration; the display just held the last reportable value, until it could report a new value. The resolution is 1 second or 1/60th of a minute or 1.67% of a minute. A digital thermometer may have a resolution of 0.5 ºC, and as the temperature progressively changes, the display holds the prior value until the change is enough to display the new value. If the thermometer range is 25-45 ºC, then it can only report 41 distinct values, and has a resolution of 2.5% of full range. If a 10-bit processor is in the signal transmission path, it can only hold 28 = 1,024 values. If the calibration range is in the middle 64% of its signal range (as 4-20 mA is a portion of the 0-25 mA range), then only 655 values are used. This means the signal resolution is the CV range divided by 655. The resolution, the ability to detect change, is 0.153% of the full range. 

Resolution is visually detectable when the signal jumps between identical discrete values. In nonlinear processes or sensors, discretization can be invisible at one operating range and clearly visible at another. When detectable, poor resolution can cause a controller cycle in a pattern like valve stiction.

This effect could be termed discretization or truncation. Choose either the smallest interval for change, ∆, or the number of values, N, within a range of R = yhigh – ylow.  The relation is ∆ = R/N. Then, if y is the process value, and ydisplay is what will be transmitted or reported, calculate ydisplay from y: 

ydisplay = ylow + ∆ ∙ INT ((y – ylow) / ∆)

This equation truncates the y-value. You could round it by using INT((y – ylow) / ∆+0.5).

The controller should act on the ydisplay value, not on the simulated y value.

Simulating bias

Noise is often termed random error. However, there may be a measurement calibration bias, a permanent offset, also called a systematic error. To simulate a systematic error, simply add the error to the measurement:

xmeasured,i = xdeterministic model,i + bias

Certainly, you can simulate both random and systematic error combined. As with noise, the systematic error might be scaled by (not added to) the process variable value.

Simulating faults

Faults could be related to many types of instrument failures, process issues or data transmission errors. These could be spurious signals, a progressive degradation, or a step event. You might be demonstrating an automation technique for robustness to faults. Simulate the fault effect in a reasonable and defensible manner.

About the Author

R. Russell Rhinehart | Columnist

Russ Rhinehart started his career in the process industry. After 13 years and rising to engineering supervision, he transitioned to a 31-year academic career. Now “retired," he returns to coaching professionals through books, articles, short courses, and postings to his website at www.r3eda.com.

Sponsored Recommendations

Make Effortless HMI and PLC Modifications from Anywhere

The tiny EZminiWiFi is a godsend for the plant maintenance engineers who need to make a minor modification to the HMI program or, for that matter, the PLC program. It's very easy...

The Benefits of Using American-Made Automation Products

Discover the benefits of American-made automation products, including stable pricing, faster delivery, and innovative features tailored to real-world applications. With superior...

50 Years of Automation Innovation and What to Expect Next

Over the past 50 years, the automation technology landscape has changed dramatically, but many of the underlying industry needs remain unchanged. To learn more about what’s changed...

Manufacturing Marvels Highlights Why EZAutomation Is a Force to Be Reckoned With

Watch EZAutomation's recent feature on the popular FOX Network series "Manufacturing Marvels" and discover what makes them a force to be reckoned with in industrial automation...