# How to simulate open and close and control valve using a simple controller

I have successfully developed a mathematical model for my physical system. My objective is to control the mass of gas in and out of the system.

The mass flowrate is given by:

$$V_f = C_d.\sqrt{2.\frac{\Delta P}{\rho}}$$

$$\frac{dM_{gas}}{dt} = A_{valve}.\rho.V_f$$

where $$V_f$$ is the volumetric flow rate of the valve.

Assuming I am using a simple PI controller in the system.

$$u(t) = K_p.e(t) + K_i \int_0^t e(t) dt$$.

How can I relate the controller output $$u(t)$$ to the system model?

My objective is to open and close the valve.

When the valve is closed $$V_f = 0$$

I have not been able to find any reference material that explained how to achieve this task.

Please I will appreciate if someone can please explain how to perform this task or direct me to reference material.

The input is a scaling factor between 1 and 0 that is multiplied with the area of the valve. Do note that for most valves, putting the valve half open does not mean the throughput area is half the total area, so you might want to link that in an equation.

$$\frac{dM_{gas}}{dt} = u(t)A_{valve}\rho V_f$$ $$0\leq u(t) \leq 1$$

Which also instantly leads to an issue with PI valve controllers. See the PI controller doesnt care about your limits, and if it thinks putting the valve on 10 (so 10 times opened), it will do that. In reality, as that is impossible, the valve will only open to the fullest. To prevent this mismatch, you could reduce the aggressiveness of the controller, or use alternative control methods that include physical constraints or limit themselves to only using the extreme values (like Bang-Bang control).

• Thank you @Petrus1904
– Tee
Jul 16 at 16:45

Typically, the output of the controller is the input to the valve. Depending on the sophistication of the valve model, it could be either the voltage or the valve opening in % or mm (or similar).