Space Shuttle - 2 (Program "shutloop")

In the previous exercise you used the 'brute force' method to obtain enough (time,velocity) coordinate pairs for a suitable plot of the velocity curve. Thus each time you executed the program you obtained a single coordinate pair. Furthermore you had to painstakingly plot the velocity curve by hand, count squares in order to evaluate the cumulative area required for the height plot, and plot the height curve by hand. This was a time consuming task however you probably derived a great feeling of satisfaction in completing it.
In this exercise you will extend your program in two ways. The function find_velo is only valid for the first phase of the flight from launch until the "Brennschluss"(burnout) condition of the booster rockets. For elapsed times greater than Brennschluss we will extend the function to follow the booster shells which separate from the Shuttle Vehicle. After separation, gravity forces reduce the velocity of the booster shells, and they ultimately fall into the sea for subsequent recovery (splashdown). The equations follow:

Let

where 	tb   is the time to "Brennschluss" of the booster rockets (s)
	Mfb   is the initial total amount of fuel in the booster rockets (kg)
	qb  is the ejection rate of the exhausting fuel in the booster rockets (kg/s)

thus if the elapsed time t is less than tb, the velocity equation applies as in the previous exercise:

where	V   is the upward velocity (m/s)
	t   is the elapsed time (s).
          qb   is the ejection rate of the exhausting fuel in the booster (kg/s)
   	Mt   is the total initial mass of the Space Shuttle Vehicle (including the solid booster fuel) (kg)
	qo   is the ejection rate of the exhausting fuel in the orbiter (kg/s)
	gm   is the effective mean value of gravitational acceleration (m/s/s)
	log( )   is the natural logarithm function - in the C language it is available in the math library. 	

However if t is greater than tb, then the velocity equation becomes:

where Vc is the so-called 'Characteristic Velocity' of the Shuttle Vehicle at "Brennschluss" (burnout), given by:


With this new set of velocity equations the velocity plot becomes typically as is shown below. Note that we have arbitrarily chosen an elapsed time of 380 seconds to illustrate the effect of elapsed time t >tb. When the velocity becomes zero then the booster shell has reached its maximum height and starts falling downwards.

After obtaining the velocity curve as shown above, we can now consider extending the program to evaluate the height attained by the booster rockets, until splashdown. The height is obtained by numerically evaluating the area under the upward velocity curve, using the 'Trapezoidal' method, which you will develop in Lab 5. Note that in Lab 5 we developed the method by integrating the sine function as follows:

In this exercise we wish to integrate the above upward velocity function in order to evaluate the height reached by the booster rockets as follows:

Notice the similarity. Once you have mastered the method in Lab 5 you will be able to easily transpose the code to the current exercise.

There are three parts to this exercise, evaluating a sequence of n upward velocity values of the shuttle from liftoff until a specified elapsed time, using the trapezoidal method to evaluate the cumulative height at each of these points, and modifying the "find_velo" function to follow the booster rockets after "Brennschluss" (burnout). One approach to developing this program is to first copy your "shuttle.cpp" program to a new file "shutloop.cpp", and then modify "shutloop.cpp" using the vi editor as follows:

cp shuttle.cpp shutloop.cpp
vi shutloop.cpp

The first modification should be within the function find_velo to account for "Brennschluss" (burnout). Once this mod is done it is a good idea to compile, debug, and test the program over a range of values of elapsed time before continuing.
Subsequently in the main function introduce a while loop to evaluate upward velocity over a sequence of values, and finally when this mod has been debugged and tested, do the final mod in the while loop to evaluate the height over the range of values using the trapezoidal method. Use the number of points entered from the keyboard (minus one) to determine the number of intervals of the Trapezoidal Method.

A typical program execution output follows:

 Evaluate upward velocity as function of elapsed time
 for 20,000kg payload, initial total mass is 2,034,681[kg]
 enter your initial total mass of shuttle [kg]: 
2034681
Shuttle initialised as follows:
 total mass at liftoff: 2034681.0[kg]
 mass of solid fuel at liftoff: 1004250.0[kg]
 booster ejection fuel velocity: 2817.0[m/s],
       mass flow rate: 8369.0[kg/s]
 orbiter ejection fuel velocity: 3636.0[m/s],
       mass flow rate: 1378.0[kg/s]
 initial gravity acceleration: 9.8[m/s^2]
enter elapsed time from liftoff [s]: 
380
value entered is 380.0 seconds
enter the number of points to evaluate
20
number of points is 20
elapsed time(s) velocity(m/s)  height(m)
       0.0           0.0           0.0
      20.0          95.3         952.7
      40.0         214.0        4045.0
      60.0         360.8        9792.4
      80.0         542.1       18821.8
     100.0         766.9       31912.5
     120.0        1047.9       50061.1
     140.0         851.8       69058.3
     160.0         655.7       84132.7
     180.0         459.5       95284.3
     200.0         263.4      102513.1
     220.0          67.2      105819.2
     240.0        -128.9      105202.4
     260.0        -325.0      100662.8
     280.0        -521.2       92200.4
     300.0        -717.3       79815.2
     320.0        -913.5       63507.3
     340.0       -1109.6       43276.5
     360.0       -1305.7       19122.9
     380.0       -1501.9       -8953.5

Notice the various items of data entry to this program are written in Italics script. In order to enable this program to be graded automatically, this sequence of data entry should be strictly adhered to.

The source code file shutloop.cpp should be in your home directory by 10:00 a.m. of the due date.

Telnet: "condor"