Space Shuttle - 4 (Program "shutfile")

There are two distinct parts to this exercise, all of which are simple extensions of the previous exercise (shutfor), and they should be solved and debugged separately:

1. A text datafile named shuttle.mass contains a typical value for the total initial mass(kg) of the Space Shuttle prior to liftoff. We wish to write a function get_mass which will get the mass from the file, and use the Constructor of class Shuttle to assign this value to the private variable m_total of our shuttle Object. The format of the file follows:

shuttle.mass
2034681.0
#####################################
Initial total Shuttle mass in kg
(default value for 20,000kg payload)
#####################################

Notice that the file has the data item followed by four lines of explanatory information on the data. The function get_mass should both get the data and assign it to the respective variable in the main function, and then read and display all the remaining lines of information. Refer to sections 9.2 and 9.3 in Shiflet.
(Note: The input data file shuttle.mass is used here only as an example. Using the vi editor you should create and name your own data file using the inital mass that you used in the first exercise shuttle.)

2. The second extension of the previous exercise (shutfor) allows the program to create a text datafile of (time, velocity, height) values in your home directory which will subsequently be used for off-line plotting. Thus you will modify the main function of program shutfor to enable creating, writing to, and closing a data file named shuttle.out using the various file commands that we learn about in lab7. This second 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.

The structure flow diagram of shutfile follows:

The following is a complete typical program execution output:

Evaluate upward velocity as function of elapsed time
 get shuttle mass from the "shuttle.mass" file
mass read: 2034681.0kg
#####################################
Initial total Shuttle mass in kg
(default value for 20,000kg payload)
#####################################
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         917.0
      40.0         214.0        3966.7
      60.0         360.8        9662.6
      80.0         542.1       18628.2
     100.0         766.9       31637.7
     120.0        1047.9       49680.2
     140.0         851.8       68672.9
     160.0         655.7       83752.9
     180.0         459.5       94896.0
     200.0         263.4      102134.7
     220.0          67.2      105426.4
     240.0        -128.9      104825.7
     260.0        -325.0      100275.7
     280.0        -521.2       91813.2
     300.0        -717.3       79441.5
     320.0        -913.5       63102.3
     340.0       -1109.6       42875.0
     360.0       -1305.7       18716.0
     380.0       -1501.9       -9366.9
20 rows of data written to "shuttle.out" file

Notice the two items of data entry to this program shown in Italics script. The only difference between the above output and that of program shutfor is the last line, in which it is stated that 20 lines of data have been written to the shuttle.out file. This file will be saved in your home directory, and contains the data that we wish to use for plotting. Each column of data in the datafile is separated by a horizontal tab symbol, so that it can be read into a spreadsheet or graphing program.
The content of the datafile shuttle.out follows:

shuttle.out
    0.0                0.0              0.0
   20.0               95.3            917.0
   40.0              214.0           3966.7
   60.0              360.8           9662.6
   80.0              542.1          18628.2
  100.0              766.9          31637.7
  120.0             1047.9          49680.2
  140.0              851.8          68672.9
  160.0              655.7          83752.9
  180.0              459.5          94896.0
  200.0              263.4         102134.7
  220.0               67.2         105426.4
  240.0             -128.9         104825.7
  260.0             -325.0         100275.7
  280.0             -521.2          91813.2
  300.0             -717.3          79441.5
  320.0             -913.5          63102.3
  340.0            -1109.6          42875.0
  360.0            -1305.7          18716.0
  380.0            -1501.9          -9366.9

Once the 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 height vs elapsed time, as shown below. The final graph can be printed on the Laserprinter in the lab. Notice on the graph that the horizontal line representing the required height is included (in this example it is: 40,000 m), allowing one to read off the graph the time required to attain the required height.

As before, your program will be separated into two files, the program file shutfile.cpp and the header file shutfile.h, which should be identical to shutfor.h. Both of these files should be in your home directory, and the printout of the graph should be submitted to Stocker room 265 by 10:00 a.m. of the due date.

Telnet: "condor"