8.1 Filling a Water Tank: Two Cases
205
8.1 Filling a Water Tank: Two Cases
If “ordinary differential equation” is not among your favorite expressions, then this
section is for you.
Consider a 25 L tank that will be filled with water in two different ways. In the
first case, the water volume that enters the tank per time (rate of volume increase) is
piecewise constant, while in the second case, it is continuously increasing.
For each of these two cases, we are asked to develop a code that can predict (i.e.,
compute) how the total water volume V in the tank will develop with time t over a
period of 3 s. Our calculations must be based on the information given: the initial
volume of water (1L in both cases), and the volume of water entering the tank per
time.
8.1.1 Case 1: Piecewise Constant Rate
In this simpler case, there is initially 1 L of water in the tank, i.e.,
V (0) = 1 L,
while the rates of volume increase are given as:
r = 1 L s
−1 ,
0 s < t < 1 s ,
r = 3 L s
−1 ,
1 s ≤ t < 2 s ,
r = 7 L s
−1 ,
2 s ≤ t ≤ 3 s .
Before turning to the programming, we should work out the exact solution by hand
for this problem, since that is rather straight forward. Such a solution will of course
be useful for verifying our implementation. In fact, comparing program output to
these hand calculations should suffice for this particular problem.
Exact Solution by Hand Our reasoning goes like this: For each of the given subintervals (on the time axis), the total volume V of water in the tank will increase
linearly. Thus, if we compute V after 1, 2 and 3 s, we will have what we need. We
get
V (0) = 1 L ,
V (1) = 1 L + (1 s)(1 L s
−1 ) = 2 L ,
V (2) = 2 L + (1 s)(3 L s
−1 ) = 5 L ,
V (3) = 5 L + (1 s)(7 L s
−1 ) = 12 L .
We also have what is required for plotting the exact solution, since we can just tell
Python to plot the computed V values against t for t = 0, 1, 2, 3, and let Python fill
205
8.1 Filling a Water Tank: Two Cases
If “ordinary differential equation” is not among your favorite expressions, then this
section is for you.
Consider a 25 L tank that will be filled with water in two different ways. In the
first case, the water volume that enters the tank per time (rate of volume increase) is
piecewise constant, while in the second case, it is continuously increasing.
For each of these two cases, we are asked to develop a code that can predict (i.e.,
compute) how the total water volume V in the tank will develop with time t over a
period of 3 s. Our calculations must be based on the information given: the initial
volume of water (1L in both cases), and the volume of water entering the tank per
time.
8.1.1 Case 1: Piecewise Constant Rate
In this simpler case, there is initially 1 L of water in the tank, i.e.,
V (0) = 1 L,
while the rates of volume increase are given as:
r = 1 L s
−1 ,
0 s < t < 1 s ,
r = 3 L s
−1 ,
1 s ≤ t < 2 s ,
r = 7 L s
−1 ,
2 s ≤ t ≤ 3 s .
Before turning to the programming, we should work out the exact solution by hand
for this problem, since that is rather straight forward. Such a solution will of course
be useful for verifying our implementation. In fact, comparing program output to
these hand calculations should suffice for this particular problem.
Exact Solution by Hand Our reasoning goes like this: For each of the given subintervals (on the time axis), the total volume V of water in the tank will increase
linearly. Thus, if we compute V after 1, 2 and 3 s, we will have what we need. We
get
V (0) = 1 L ,
V (1) = 1 L + (1 s)(1 L s
−1 ) = 2 L ,
V (2) = 2 L + (1 s)(3 L s
−1 ) = 5 L ,
V (3) = 5 L + (1 s)(7 L s
−1 ) = 12 L .
We also have what is required for plotting the exact solution, since we can just tell
Python to plot the computed V values against t for t = 0, 1, 2, 3, and let Python fill
