State Space Representation of a discharge through a gate I have one equation that describes the discharge through a radial gate placed in a hydro power plant, given by
$$
Q = \frac{dV(t)}{dt} = C_g \cdot D \cdot L \cdot \sqrt{2\cdot g \cdot H_g(t)}
$$
where
$$
H_g(t) = H(t) - \frac{D}{2}
$$

*

*$Q$ is the discharge through the gate with the unit $[m^3/s]$.

*$C_g$ is a dimensionless discharge coefficient, dependant on various features of the design such as gate lip angle and shape, gate radius and trunnion pin point height.

*$D$ is gate opening with the unit $[m]$.

*$L$ is the total length of the gate with the unit $[m]$

*$g$ is the acceleration of gravity with the unit $[m/s^2]$

*$H$ is the height of the water with the unit $[m]$.

Image of the radial gate
I'm trying to design a control system for the gate, so the height of the water will always stay at 116 m. I am having difficulties to find the state space model for this equation.
My idea is to choose

*

*Control Input: $u(t) = D$

*State: $x_1(t) = H(t)$
Therefore I get
$$
Q = \frac{dV(t)}{dt} = C_g L u(t) \sqrt{2gx_1(t) - gu(t)}
$$
I am wondering if I should also choose $Q$ as a state, so I would get $x_2(t) = Q(t)$?
How can I set this equation up on the form
$$
\bf{\dot x} = \bf{A} \bf x + \bf B \bf u \\
\bf y = \bf C \bf x + \bf D \bf u
$$
?
I feel this is so complicated because I have $x_1(t)$ and $u(t)$ under the square root. I don't know how to compensate for that?
Do I need to do some integral or differential magics to this formula?
I had one idea of changing the formula to get
$$
H = \frac{Q^2}{D^2}\left(\frac{1}{C_g^2 \cdot L^2 \cdot 2g}\right) + D\left(\frac{D}{2}\right)
$$
and maybe differentiate that? Can I do something with the formula like this?
When I will figure this out, my next step is to apply the control law $u(t) = -\bf K \bf x(t)$ to make a feedback loop for this system. All help is appreciated.
 A: The dynamics is highly nonlinear. I don't think it can be expressed in the standard linear  State-space representation $\dot{x} = A x + B u$. However, we can probably consider this design approach:
Assuming that $V = A H$, then
$$ \dot{H} = \frac{1}{A} C_{D} L u \sqrt{2 g H - g u} $$
$$ \dot{H} = \frac{1}{A} C_{D} L u \sqrt{g \left(2 H - u\right)} $$
$$ \dot{H} = \frac{1}{A} C_{D} L u \sqrt{g} \sqrt{2 H - u} $$
Grouping $\frac{1}{A} C_{D} L \sqrt{g} = \mathcal{C}_{1} > 0$ as a constant, then
$$ \dot{H} = \mathcal{C}_{1} u \sqrt{2 H - u} $$
Consider the Lyapunov function candidate
$$ V(H) = \frac{1}{2} H^{2}, \quad \forall \; H > 0 $$
The derivative of $V(H)$ along the trajectories of the system is given by
$$ \dot{V}(H) = H \dot{H} $$
$$ \dot{V}(H) = H \mathcal{C}_{1} u \sqrt{2 H - u} $$
If the control law $u = - k H$ where $k > 0$ is applied, then
$$ \dot{V}(H) = - k \mathcal{C}_{1} H^{2} \sqrt{2 H + k H} \\ $$
$$ \dot{V}(H) = - k \mathcal{C}_{1} H^{2} \sqrt{\left(2 + k\right) H} $$
$$ \dot{V}(H) = - k \mathcal{C}_{1} \sqrt{2 + k} H^{2} \sqrt{H} $$
Grouping $k \mathcal{C}_{1} \sqrt{2 + k} = \mathcal{C}_{2} > 0$ as another constant, then
$$ \dot{V}(H) = - \mathcal{C}_{2} H^{2} \sqrt{H} < 0, \quad \forall \; H > 0 $$
If $H_{r}$ is the desired reference water height, then the proposed control law becomes
$$ u = - k \left(H - H_{r}\right) $$
The value selection of the gain $k$ depends on how fast the motorized actuator can open/close the gate.
Addendum: To implement the proposed control law, one has to look into this term
$$ \sqrt{2 H - u} = \sqrt{2 H + k \left(H - H_{r}\right)} $$
because the square root of any real number cannot be negative. Thus, solving the inequality
$$ 2 H + k \left(H - H_{r}\right) \geq 0 $$
shows that water level $H$ has to be retained at the minimum level of
$$ H_{\text{min}} = \frac{k H_{r}}{k + 2} $$
In other words, if the desired water level is to be regulated at $H_{r} = 116$ m, and $k = 1$ is a constant, then the minimum water level at the hydropower plant would be
$$ H_{\text{min}} = \frac{116}{3} \approx 38.66 \; \text{m} $$
If the hydropower plant engineers can guarantee that the water level won't go below $H_{\text{min}}$ during operation, then the proposed control law should work, in theory.
If the hydropower plant engineers need to safeguard the operation, where $H_{\text{min}}$ can be unpredictable due to some unforeseen circumstances, then the gain $k$ should be varied according to certain water level $H$.
One possible way is to introduce a piecewise function for the gain $k$
$$ k(H) = \begin{cases}
\frac{2 \beta H}{H_{r} - H} & \text{if }\; 0 < H < H^{*} \\
k_{0} & \text{if }\; H \geq H^{*} 
\end{cases} $$
where $0 < \beta < 1$ and the gain saturates at $k = k_{0}$, a constant, when $H^{*} = \frac{k_{0} H_{r}}{2 \beta + k_{0}}$, which is found by solving the equation
$$ \frac{2 \beta H}{H_{r} - H} = k_{0} $$
For example, if $\beta = 0.5$ and $k_{0} = 1$, then the gain saturates at $k(58) = 1$. So, when the water level drops below $H^{*} = 58$ m, then the gain $k$ will automatically adjust according to the schedule
$$ k_{\downarrow 58} = \frac{2 \beta H}{H_{r} - H} $$
Note that $\beta = 0.5$ is selected in this example so that $H^{*} > H_{\text{min}}$ gives a safety margin of approximately $20$ m. This ensures the square root of positive number for $0 < H < 58$
$$ \sqrt{2 H + k \left(H - H_{r}\right)} = \sqrt{2 H \left(1 - \beta\right)} $$
because $1 - \beta > 0$. If the safety margin needs to be increased, then $\beta$ has to be lowered.
