# 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.

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