0

I'm given a spherical tank (radius R = 1m), completely filled with water. When I open the tank at the bottom, water flows out with a rate I = 1 litre per second. What I want is plotting the fill height h as a function of time t. I end up with an implicit equation, which can't be analytically solved for h (at least I'm told, but got no time for maths atm):

- pi/3 * h**3 + pi * R * h**2 + I*t - 4/3 * pi * R**3 = 0

Sympy doc and other threads say, plot_implicit is a function to plot implicit equation. Sounds promising.

That's what I have:

from sympy import plot_implicit, Eq, symbols, pi

R, I = 1, 1
t, h = symbols('t h')
plot_implicit(Eq(-pi/3*h**3 + pi*R*h**2 + I*t - 4/3*pi*R**3, 0)), (t, 0, 5000), (h, 0, 2))

However, that gives me a seemingly empty plot. When I zoom in, I just get a rectangle: plot w/ specified ranges

When I remove the range arguments, I get something just as nonsensical: plot w/o specified ranges

That's not at all what the factual graph should look like. What am I doing wrong?

1 Answer 1

1

The plot is there, it's just squeezed into a faint blue line on the left edge because your window is badly scaled. In your equation,

-pi/3*h**3 + pi*h**2 + t - 4/3*pi = 0 

the terms without t are something of order 0 to 10, because h is between 0 and 2. So within the window (h, 0, 2) there is no point in letting t go up to 5000. A reasonable window would be (t, 0, 5), (h, 0, 2):

enter image description here

This is a part of the graph which you see if not providing bounds at all; you called it "nonsensical", but it was correct. The thickening of the curve where it bends on the left is an artifact of the algorithm, but it can be reduced by increasing the depth parameter from the default of 0, as I have done below.

For some values of t (under 4) there are three solutions for h. You don't want negative h, but that still leaves two solutions for such t. For larger t, there is one solution, but you'll need to expand the window vertically to see it.

enter image description here

Made with

plot_implicit(Eq(-pi/3*h**3 + pi*R*h**2 + I*t - 4/3*pi*R**3, 0), (t, 0, 10), (h, 0, 4), depth=2)
Sign up to request clarification or add additional context in comments.

2 Comments

I see. I was just irritated, because the tank actually contains roughly 4000 litres of water, thus requiring just as much seconds to empty. I'd like to know, where this discrepancy in magnitude comes from. But anyway, thanks for clearing this up!
One cubic meter is 1000 litres.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.