Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel\(\rightarrow\)Restart) and then run all cells (in the menubar, select Cell\(\rightarrow\)Run All).

Make sure you fill in any place that says YOUR CODE HERE or “YOUR ANSWER HERE”, as well as your name and collaborators below:

The leaking tank#

The height of a leaking tank is defined by the following differential equation

\(\frac{dh}{dt} = -26.56 \frac{A}{B} \sqrt{h}\) where \(B\) is the cross-sectional area of the tank, and \(A\) is the cross-sectional area of the hole where the leak occurs. The constant -26.56 has units of \(\sqrt{(cm/s^2)}\).

In this equation,

Assuming that the tank is 2m in diameter, the hole is 1 cm in diameter, and the liquid level in the tank is initially at 2.25 m, our objective is to estimate when the tank will be empty.

Analytical solution#

This differential equation can be analytically solved by separation of variables and integration. Find an analytical solution and plot it. Solve this analytically to find the time when ℎ=0 .

Integral solution#

If you separate the variables in the differential equation, and then integrate both sides, the time integral will be trivial and you can then solve for the time to empty the tank by using the `quad` function to evaluate the integral on \(h\) by setting the integral limits from the initial height to zero.

Do that and compute the time to empty the tank.

Numerical solution#

Compute and plot a solution to the ODE using scipy.integrate.solve_ivp. Note that this problem is a little problematic as the height approaches zero. If there are any errors where the integration algorithm predicts that the height goes negative (the function approaches zero, and the derivative is negative, so this could happen), there is an error in the sqrt function and the integration terminates. Nevertheless, try this and plot your solution. Estimate the time to empty the tank based on your solution.

Discuss what you learned from this exercise#

You should write a paragraph comparing and contrasting these approaches.

%run ~/f23-06623/f23.py
%pdf