Write a program that determines the water height h, as a function of time. The volume in the tank is
V = (1/3)* pi * h*h * (3R - h)
and the velocity of water flowing through the drain is:
dv/dt = -pi * r*r *SQRT(2gh).
Let R(radius of tank) = 30 ft., r(radius of drainpipe) = 0.3 ft, initial h(water in tank) = 50 ft., g(gravitational constant) = 115.8 ft/(min*min), delta t = 0.5 min., final h = 1 ft. Use Euler's method and solve for h and print the results for each interval.
Note: The purpose of this algorithm is to print a calibration table that shows the volume of water in the tank at a given time. It would be useful to have your program flexible for different tanks, i.e., get all necessary information from the user.
Thanks! I had hoped to be able to see this and reason this out, but I can't. I am taking C++ independent study this summer and it is eating my lunch. My instructor cannot spend much time helping me due to other duties and he said to get help where ever I can. He knows that I am not a programmer. If you or anyone else can help me to understand this, or better yet, apply this to code. I would greatly appreciate it.
That's my problem too. I thought when I saw simo110's answer I would be able to reason it out, but it is over my head. As soon as I find someone who can help me with this, I'll post it in psuedo code. Thanks.
Try a google for "Euler's Method", there should be a bunch of results and I'd hope one or two suggested algorithms.
I could have been more help 20 years ago when i was doing math at uni, but I've not had to use any of this for so long the memory fades...
"Euler's Method" is introduced in the " wiki enlish"!
But my method is the differential!
You can read the book "Mathmatic Analysis" wrote by Г.М.Хихтенгольц (russion) for the useful information!
But read this book is a trouble,it can make you crazy if you want to learn it in detail!
I pooled all of my resources and found two people knowledgeable in calculus. They agreed with simo110's calculations. (simo110, thank you so much!) So, the pseudo code would go as follows:
R (radius of the tank), r (radius of the drainpipe) and h (water in the tank) would all be user prompts. From there I'm thinking I would want to do a while statement to loop it until h = 1 foot. To display with the results, I'm thinking that I would want to use an array with one column showing the elapsed time incremented every 0.5 minutes and the other column displaying the water height at that time. To calculate the height, I would use the last line of simo110's calculations. Take the initial height (50) plus the result of the calculation
r*r*SQRT(2gh)/(h*h - 2*h*R)
would equal the new height. (The calculation results in a negative number. That's why it is added.) Record that, change the time interval and recalculate with the new height in place of the original height (which was 50). Repeat (while) until the height reaches 1 foot.
Can anyone help me with writing the code for this?