February 7, 2025

Physically Based vs. Feedback Control Models: Choosing the Right Approach for Water System Simulation

 Posted by  Jason Lillywhite

We’ve often been asked about the best way to simulate flow between two tanks: should it be modeled physically, based on fluid mechanics, or actively controlled using a feedback mechanism? With the release of GoldSim 15 and its new Controller element, now is a good time to compare these approaches and perhaps even combine them. In this post, we’ll examine the performance of our existing physically based model (Flow Between Two Tanks) alongside a feedback-controlled version using the Controller element. By comparing these methods, we’ll explore their strengths, limitations, and when one approach might be preferable over the other.



Modeling Interflow Between Two Tanks

Interflow between two tanks is calculated using a binary search algorithm to solve for the flow rate that balances hydraulic head and frictional losses. The flow is initialized within a range (0 to 100 m³/s), and the velocity is computed as velocity = flow / area.

Inputs for the physically based model include data used to capture the properties of the pipe, orifice and geometry of the tanks. Below is a screen capture showing how the inputs relate to the different components of the model.



The physical model calculates flow using the Darcy-Weisbach equation and energy balance, iteratively solving for flow in both directions. Head losses include minor losses and frictional losses, with the friction factor determined by the Reynolds number and the Moody diagram for turbulent flow. Flow is computed from the available head using Bernoulli’s principle, and a binary search algorithm refines the solution until it converges within 0.001 m³/hr. The same method applies when Tank 2 is higher than Tank 1, ensuring consistent hydraulic behavior. Below is a screen capture of the Script element performing the binary search.


This method is useful during periods of higher volumes when flow is primarily driven by hydraulic head differences, allowing for a realistic simulation of passive flow behavior. 

However, this method can cause oscillations when the volume approaches the target volume, particularly when the change in net flow during a time step is significant relative to the available storage capacity. As our system nears equilibrium, small deviations in head difference can result in abrupt flow adjustments, leading to repeated overcorrections. This effect is most pronounced in our model when we change the time step from 1 hour to 1 day as seen in the example below (compare to first image above).



The new Controller element in GoldSim 15 provides a way to model feedback control, allowing for dynamic flow adjustments based on system conditions rather than relying solely on hydraulic equations. Unlike the physically based approach, which determines flow passively based on head differences, feedback control continuously monitors the reservoir volume and adjusts outflow directly to maintain a target level. This is achieved using control strategies such as proportional, proportional-integral (PI), and proportional-integral-derivative (PID) control, which enable smooth and responsive regulation of flow. By tuning the controller parameters, users can minimize oscillations and improve system stability, particularly when the volume is near the target. The screen capture below shows the GoldSim Controller element in action, where it dynamically adjusts flow between two tanks to maintain the desired setpoint.


Here is a comparison of results using both methods:


Combine Physical and Feedback Models

I decided there’s a threshold where it makes sense to switch from physical flow calculations to feedback control, and vice versa. In my model, I set this threshold at 

abs(Tank 1 - Tank 2) > 10 ML 

If the above statement is true, use the physically based model. But once the tanks get closer to equalizing, the model switches to feedback control. This setup gives me realistic behavior for higher flows, where hydraulic equations work well, while preventing oscillations when the volume difference is small. It’s a simple way to combine both methods, and while my threshold is specific to this setup, others could apply a similar approach based on their own system dynamics.

Here is the result of combining the methods (see screen capture shown below). Notice how smooth the response is compared to the physically based model, particularly at the times when the volume of the 2 reservoirs approaches each other.


A comparison of the outflow from Tank 2 to Tank 1 using the 3 methods is shown below. Early in the simulation, the hybrid model is the same as the physically based but it switches after day 3 to feedback control, allowing it to approach it's target without oscillations.



This comparison highlights how both physical modeling and feedback control have their strengths, and in some cases, a combination of the two can provide the best results. The physically based approach works well when flow is primarily driven by hydraulic forces, but it can introduce instability when the system nears equilibrium. Feedback control offers stable regulation but may not always capture natural flow behavior at higher volume differences. 

By setting a threshold to switch between methods, I was able to get a more stable and realistic simulation. While the exact cutoff will depend on the specifics of each system, this hybrid approach shows that flexibility in modeling can lead to better performance in dynamic water systems.

If you are interested in playing with this model, you can download it from here: Flow Between 2 Tanks – GoldSim Help Center

No comments:

Post a Comment