MATLAB PROBLEM: The equation describing the water height h in a spherical tank w
ID: 3575946 • Letter: M
Question
MATLAB PROBLEM:
The equation describing the water height h in a spherical tank with a drain at the bottom is dh pi(2rh - h^2) middot dh/dt = -C_dA Squareroot 2gh where A is the cross sectional area of the drain hole and C_d is a constant equal to 0.5. Suppose the tank s radius is r = 3 m and the circular drain hole has a radius of 2 cm. Assume that the initial water height is h(0) = 5 m. Use g = 9.81 m/s^2. Use the Euler method with a time step of 0.1 seconds to estimate the time it takes for the tank to completely empty.Explanation / Answer
%dh/dt = -Cd*A*sqrt(2gh)/(pi*(2*r*h-h^2));
Cd = 0.5;
r = 3;
h0 = 5.0;
g = 9.81;
A = pi*0.02*0.02;
f = @(h) -1.0*Cd*A*sqrt(2*g*h)/(pi*(2*r*h-h^2));
hs = [h0];
fs = f(h0);
step_size = 0.1;
t = [0];
while hs(end)>0
t(end+1) = t(end) + step_size;
hs(end+1) = hs(end) + step_size*f(hs(end));
end
disp(['Time taken for height to be zero= ', num2str(t(end)/(60.0*60.0))], ' hours');
plot(t, hs);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.