Water Rocket 4 - Program "rockfile"

In the previous exercise we extended the water rocket analysis to include evaluation of the upward velocity of the rocket throughout the flight. In this exercise we complete the analysis by evaluating the height attained by the rocket throughout the flight, from liftoff and until it crashes back to earth. Once more we summarize the relevant equations presented in the previous exercise as follows:

The basic rocket force equation:

The thrust force in terms of the water expelled through the nozzle:

Bernoulli's equation, relating the pressure applied by the compressd air to the velocity of the exhausting water:

Substituting equation 3 into equation 2 and simplifying:

The adiabatic expansion process relating the pressure to the volume of the compressed air, which was developed in the section on Adiabatic Expansion Analysis:

The volume variation of the compressed air due to the water escaping through the nozzle is given by:

The total mass of the rocket (ignoring the mass of the compressed air) is given by:

The frictional drag force is given by:

The acceleration a (and thus the velocity u) is obtained by rewriting equation 1 above as follows:

We now complete the analysis by adding the equation for the height as follows:


where h is the height attained by the rocket [m]

Unlike the nonlinear differential equations for volume V and velocity u (equations 7 and 10), equation 11 can be directly integrated using the Trapezoidal method which we developed in Lab 5. This leads to the following numerical solution for height attained:

This leads to the algorithm for evaluating both the velocity and the height attained as functions of time as the basis for the new method findvelht as follows:

Thus the only change that we find is in the last three lines. Note that u1 refers to the velocity u(t+)

The Computer Program "rockfile"

This program relies on Chapters 6 through 8 of our text, including the concepts of passing arguments by reference (Sections 6.1, 6.2) and the reading and writing of text data files (Section 8.2).

There are three distinct parts to this exercise, all of which are extensions of the previous exercise (rockfor), and they should be solved and debugged separately in the following sequence:

1. Using the vi editor, create a text datafile containing your personal rocket input data values (based on measurements done on your team rocket), and named yourname.data, thus for example the file which your instructor is using follows
urieli.data
43.0  591.0  0.4  0.3  4.0  0.3  8.0
################################################
The small urieli root beer water rocket -10/16/06
The above data items are (in sequence):
mass [gm] - solid mass (rocket + payload)
vtotal [cc] - total volume (water + air)
dnoz [cm] - diameter of nozzle
fill - fill ratio (water/total volume)
pgage [atm] - charge gage pressure [atmospheres]
cdrag - Coefficient of drag
dbottle [cm] - outside diameter of bottle
################################################

Notice that the file has the data items followed by lines of explanatory information. These should include your name as well as the date when you created the data file. You will need to write a function getrocket which should both get the data from the file and assign them to the respective variables in the main function, and then read and display all the remaining lines of information.

2. Develop a new method findvelht to replace the method findvelo of the previous exercise in order to evaluate both the upward velocity and the height attained as functions of time in accordance with the above algorithm. The basic structure of this method is shown in the the following structure flow diagram:

3. Notice that the program also creates a text datafile of (time, velocity, height) values in your home directory which will subsequently be used for off-line plotting. Thus the main function should create, write-to, and ultimately close a data file named rocket.out using the various file commands that we learn about in lab7. This third part of the exercise will give you experience in transferring files from condor to your local computer using the FTP (File Transfer Protocol) program, editing local textfiles with the Wordpad program, and plotting data using the MATLAB application program.

A typical execution is shown below together with the output data file rocket.out. Note that since the input data defining the rocket is read from the input data file, only two data items are input by the user, as shown in italics. Please be sure to enter your data in the same order as this solution shown below (which is available to test in the programs directory of condor) since the exercises are checked automatically using a data file for input. As in the previous exercise, your program will be separated into two files, the program file rockfile.cpp and the header file rockfile.h. Both of these files together with the input data file should all be in your home directory before 10:00 am of the due date.

 get rocket data from the "urieli.data" file
data read:
43, 591, 0.4, 0.3
4, 0.3, 8
################################################
The small urieli root beer water rocket -10/16/06
The above data items are (in sequence):
mass [gm] - solid mass (rocket + payload)
vtotal [cc] - total volume (water + air)
dnoz [cm] - diameter of nozzle
fill - fill ratio (water/total volume)
pgage [atm] - charge gage pressure [atmospheres]
cdrag - Coefficient of drag
dbottle [cm] - outside diameter of bottle
################################################
Water rocket initialized as follows:
Solid mass[gm]: 43, total volume[liters]: 0.591
absolute charge pressure[kPa]: 500
initial air charge volume[liters]: 0.4137
Nozzle free flow area [sq.cm]: 0.125664
Bottle cross sect. area [sq.cm]: 50.2655
Density - water: 1000kg/m^3, outside air: 1.2kg/m^3
Ratio of specific heat capacities for air (k): 1.4
Drag coefficient: 0.3
gravity acceleration: 9.807m/s^2
enter the max time to test (sec)
6
value entered is 6(s)
enter the number of points to evaluate
21
21 points entered
   time(s)     velocity(m/s)     height(m)
      0.00           0.00           0.00
      0.30          11.66           1.68
      0.60          29.60           7.61
      0.90          22.44          15.36
      1.20          17.02          21.23
      1.50          12.72          25.71
      1.80           9.05          29.00
      2.10           5.70          31.09
      2.40           2.69          32.46
      2.70          -0.30          32.71
      3.00          -3.21          32.21
      3.30          -6.01          30.85
      3.60          -8.60          28.69
      3.90         -10.97          25.59
      4.20         -13.01          21.92
      4.50         -14.69          18.13
      4.80         -16.10          13.77
      5.10         -17.33           8.09
      5.40         -18.24           3.27
      5.70         -19.00          -2.52
      6.00         -19.58          -8.02
rocket.out
    0.0000               0.0000          0.0000
    0.3000              11.6613          1.6850
    0.6000              29.5986          7.6092
    0.9000              22.4417         15.3604
    1.2000              17.0247         21.2308
    1.5000              12.7197         25.7057
    1.8000               9.0538         29.0012
    2.1000               5.7049         31.0881
    2.4000               2.6946         32.4647
    2.7000              -0.3017         32.7064
    3.0000              -3.2112         32.2077
    3.3000              -6.0067         30.8535
    3.6000              -8.6003         28.6913
    3.9000             -10.9662         25.5877
    4.2000             -13.0083         21.9183
    4.5000             -14.6883         18.1251
    4.8000             -16.1030         13.7688
    5.1000             -17.3331          8.0896
    5.4000             -18.2419          3.2690
    5.7000             -19.0034         -2.5212
    6.0000             -19.5830         -8.0214

Once the output datafile is available in your home directory then you should use the FTP program to fetch the file and save it on the local computer disk. At this stage you should be able to examine the file, and any out-of-range data lines can be edited out. Finally you should read the file into the MATLAB application and plot both the upward velocity and the height attained vs elapsed time, as shown below. The final graph can be printed on the Laserprinter in the lab.

A few words about the graph. When I tried to plot the above file with 21 points it gave very unsatisfactory results. After experimenting a while I decided on 500 points, which resulted in the above plot. The very jagged cumulative height plot is a result of using a very unconventional numerical quadrature technique to solve the set of three differential equations, when in fact we should be using a standard differential equation solving method. Experiment with your own rocket graph until you are satisfied with the results.

A printout of your graph should be submitted in the box outside Room 265 (Stocker) by 10:00 am of the due date.

Wow - 0.6 seconds thrust for 6 seconds flight attaining a maximum height of 33 meters (100 ft) - isn't this exciting?!