I'm working on a Unity project to simulate water flow over a grid with varying elevation. I'm trying to accurately reflect how water would spill over from one cell to the next.
For example, cell A in the image below is holding $100$ $m^3$ of water (10 x 10 x 1).
https://i.stack.imgur.com/iNM0A.png
This water in cell A would spill over into cell B over some period of time. I want to update the board once per simulated second, so all I really need to determine is the water volume of cell A each second after it starts spilling.
This answerer cited a helpful formula to calculate the flow rate over a weir given the dimensions of the water body:
$$ Q=\frac{2}{3}C_d b \sqrt{2g}\, h^\frac{3}{2} $$
Sub out height for volume, and make negative to express water volume being lost from cell A:
$$ \require{cancel} Q(V)=-\frac{2}{3}C_d b \sqrt{2g}\, (\frac{V}{bℓ})^\frac{3}{2} $$ where $Q$ is the rate of discharge from cell A, $V$ is the volume of water in cell A, $C_d$ is an empirical discharge coefficient, $b$ is the width of the water body, ℓ is the length of the water body, $g$ is gravitational acceleration.
For my use case, this simplifies down by subbing in values:
$$C_d = 1,\;b = 10m,\;ℓ = 10m,\;g=9.8\frac{m}{s^2}$$ $$ Q(V)=-\frac{19.6^{\frac{1}{2}}V^{\frac{3}{2}}}{150} $$
So I have the initial volume $V_0=100m^3$, and discharge rate as a function of volume $Q(V)$. But I need volume as a function of time $V(t)$.
I looked to this answer for guidance, since the math seems similar to what I'm trying to do. But I haven't quite figured out how to apply it correctly. Pretty sure I need to reformulate it somehow, then integrate over time. Just not sure what those steps would be.
I think your volume changes in time due to the flow: $$ \frac{dV}{dt} = - Q,$$ Plugging this into your original formula (and defining $k$ as a shorthand for the constants), this gives $$ \frac{dV}{dt} = k V^{3/2}.$$ An integration of this equation gives $$ k t = 2(V_0^{-1/2}-V^{-1/2}),$$ where $V(0)=V_0$. This provides the relationship between volume and time $$ V(t) = \Big(V_0^{-1/2} -\frac{kt}{2} \Big)^{-2}. $$ Then your flux versus time is $$ Q(t) = k \Big(V_0^{-1/2} -\frac{kt}{2} \Big)^{-3},$$ if I'm correct. These formulas are only valid until $t = 2V_0^{-1/2}/k$, when the initial volume should be entirely depleted. I guess this analysis is correct, because for $t=0$ we get $Q(0) = k V(0)^{3/2}$ as expected.
I am not sure what stage your project is at, but a reasonable start would be to model your flow as constant, so that $V(t) = V_0 - Q t$ and $Q(t)=Q$ until $t=V_0/Q$. Once this works, you can replace with a non-linear flow law.