# Layout of a controller for controlling a water pump

I'm currently writing a simulation environment in python/c for heat networks and got to the point where I'm implementing the controls for the environment.
The PID controller is already implemented and should be working, but now I stumbled upon a question where I need some advice which way is the best or most common way to go.

Let's say I've got a heat generator with the power $P=40\,kW$, through which water with a heat capacity $c_p \approx 4000\,\frac{J}{kgK}$ is flowing. The inlet flow temperature is $T_{in} = 50\,^°C$, current outlet flow temperature at timestep $n$ is $T^{n}_{out} = 70\,^°C$ and the massflow is $\dot m^{n} = 0.5\,\frac{kg}{s}$. The desired outlet flow temperature $T^{*}_{out} = 90\,^°C$.
For a constant $c_p$ I need to tell the pump to reduce the massflow to $\dot m^{n+1} = 0.25\,\frac{kg}{s}$ to get $T^{n+1}_{out} = 90\,^°C$ (assuming infinitely long timesteps to get a steady state condition).

To make the example fast and easy, I assume to only have a P-controller with a proportional factor of $K_p = 1.2$ and a pump control algorithm, which is an equation to correlate massflow and temperature, but has no P/I/D-parts! The pump control algorithm equation is: $$\dot m = \frac{P}{c_p \left(T_{out} - T_{in}\right)}$$

Now I've got two possibilites which values to pass as setpoint-values to the P(ID)-controller:

• I can pass the desired outlet temperature $T^{*}_{out} = 90\,^°C$ as setpoint-value and the current outlet temperature $T^{n}_{out} = 70\,^°C$ as process-value to the controller.
This means that the control variable output of the controller will be $C = \left(90\,^°C - 70\,^°C\right)K_p = 24\,^°C$.
This will be fed into my pump-control-algorithm equation with $T_{out} = T^{n}_{out} + C$ which then yields $\dot m^{n+1} = \approx 0.2272 \frac{kg}{s}$ and will then be set as the massflow.
• Or I can pass the desired outlet temperature $T^{*}_{out} = 90\,^°C$ to the pump-control algorithm to get the desired massflow and then pass the desired massflow as setpoint variable to the P(ID)-controller.
Thus the desired massflow will be according to the pump control algorithm equation: $\dot m^{*} = 0.25\,\frac{kg}{s}$. This will be passed to the P(ID)-controller as setpoint-value and the current massflow $\dot m^{n}_{out} = 0.5\,\frac{kg}{s}$ as process-value, which yieds the control variable: $C = \left(0.25\,\frac{kg}{s} - 0.5\,\frac{kg}{s}\right)K_p = -0.3\,\frac{kg}{s}$.
So the massflow set by the pump will be: $\dot m^{n+1} = \dot m^{n} + C = 0.2\,\frac{kg}{s}$

Considering both possibilities, the second path with passing the massflow to the controller seems alot more aggressive. Since I have little to no experience with controlling water flows with a pump, I don't know which is the common way to go. Or is there anything I forgot to consider?
What also could be interesting is the region/nation in which it is made in one or the other way and for which applications. My application would be on the one hand a district heating network and on the other hand potable hot water stations, both situated in germany.

Edit
As several people keep telling me, that a system like this is unlikely to be built: It is common and very much likely in central europe, where energy efficiency is rated quite highly!
In fact systems like this are being built often! (I definetely know this, as I am working at operation optimization for systems like this. Thus I'm working with alot of systems like this.)

So this question is not about if systems like this are likely to exist. It is if the control flow usually first goes to the controller and then to some algorithm which calculates a value to set for an actuator, or vice versa.

I know that usually a voltage or PWM is passed to the actuator and not a massflow which has to be set. This is the only point where I agree that it is unlikely it is going to be done in reality. But this is how it works best for my simulation environment and it does not affect my question which is about the order of the control flow!
So... Help is really appreciated, but I don't want to discuss if this system exists or not.

• Water based central heating systems just use hysteresis and turn the pump just on and off. Water has enough heat capacity to get that averaged out. – ratchet freak Sep 6 '17 at 17:32
• Well, I work in that sector and none of the systems which were build around here in the last ten years uses just on-off-switches. All of them use a PWM or 0-10V controlled pump. I just don't know which way the control-flow goes, but I know that it is not on-off. – Scotty1- Sep 6 '17 at 17:36
• @ratchetfreak I'm not sure if that universally applies anymore. Definitely still common, but control systems and mechanical devices are definitely getting smarter in terms of energy efficiency. The push towards systems with variable parameters is definitely real. I think a lot of building system designers just aren't comfortable enough with it for it to be a go-to during the design process. (Also money) – JMac Sep 6 '17 at 18:05
• I guess it also strongly depends on the region/nation and its legal regulations considering energy efficient systems. And yeah, in my experience especially build designers are often just relying on what they always did in the last 40 years... Whatever... This is my problem/question and I would appreciate some help! :) – Scotty1- Sep 6 '17 at 18:22
• In a real system, the heat transfer from heat source to wter will depend on flow, high turbulence is good for heat transfer - so the pump will deliver a fixed flow (internally controlled for pressure is common these days) and a three way valve will mix flow into the return to adjust temperature. Or the heat source is controlled for flow temp. I'm not sure heating pumps commonly control for flow. In short, I'm not sure you describe a system that's liekly to be built. This may be the system you want to simulate anyway, or maybe there's a misunderstanding along the way and you need to reconsider? – mart Sep 7 '17 at 9:21

Control problems are usually easier if you specify

1. The measured variables, I assume $T_{in}$ and $T_{out}$
2. The manipulated variables, I assume the pump speed according to your description
3. The objectives of the controller. Do you need to be exactly at 90 degC or would and outlet with a certain offset be acceptable? Or is the temperature very important and you would vary the pump outlet a lot if needed in order to be exactly at 90 degC?

Your approaches are almost feedforward: you rely on a basic model of how water gets heated in order to control your system. Although that can be a sensible option, it can fail if there are heat losses, changes in $T_{in}$ that you are not measuring, etc. For such a system good old feedback should work.

If you can accept a certain offset, the easiest by far is to use just a proportional controller using $T_{out}$ as a controlled variable (with setpoint 90 degC or slightly higher) and the pump speed (or voltage) as the manipulated variable.

If you need to be exactly at 90 degC, then you would require integral action. The tricky part is that you can make your controller unstable if you specify a very tight integral action or have very long oscillations if the integral action is too slow. However, for a system like yours, it should not be a problem.

• Okay, thanks for that information! Yeah, $T_{out}$ is passed to the controller as process variable but I forgot to mention that $T_{in}$ is also measured, but only passed to the pump control algorithm. The manipulated variable is the pump speed, in my example the mass flow to be specific (as I can pass the massflow directly as a command to the pump). Exact control is not needed, overshoot of $3\,^°C$ is allowed. – Scotty1- Sep 8 '17 at 11:47
• Considering feedback: I calculate the output $C$ of the controller with $C = err * K_p$ (for a simple proportional control), with the error being $err = 90\,^°C - T_{out}$. Isn't that using feedback? My control theory lectures are quite far in the past and I've only spent a few days on refreshing it now, so I might be wrong here... – Scotty1- Sep 8 '17 at 11:50
• Yes, that is feedback. But remember that the idea of such a controller is regulation: to keep a set point despite disturbances. Therefore the control law would be written rater $C = C_0 + K_p*err$ where $C_0$ is the nominal pump flow at steady state. You just need to find an appropriate $K_p$ but given that you can allow a 3 degC overshoot, you could consider that the pump is at 10% of variation for the 3 degC error, thus: $K_p = 0.1 \Delta C_{max} / 3$ – Toulousain Sep 11 '17 at 8:57
• Thanks, I'm starting to get a hold of it now. Yeah, the control law with $C=C_0+K_p*err$ is quite much equivalent to $T_{out} = T^{n}_{out}+C$ (or the massflow formula), I just got confused with the translation from the german variable names to the english variable names. Thanks for clarification and also for the $K_p$-equation! – Scotty1- Sep 11 '17 at 11:24
• Cascaded structures (where the setpoint is the actuator of another controller) are possible and widely used. They are helpful when you have very different time constants (so you have a fast loop and a slow loop) or nonlinearities that you tackle by splitting the control action into two loops. It doesn't seem to be your case – Toulousain Sep 11 '17 at 15:04