There are two distinct parts to this exercise, both simple extensions of the previous program exercise balloop, and they should be solved and debugged separately:
1. A text datafile named bal500.data contains the basic private data of a small balloon. We wish to write a function get_balloon which will get the data from the file, and use the Constructor of class Balloon to assign this data to the private variables of our balloon Object. The format of the file bal500.data follows:
Notice that the file has two data items followed
by four lines of explanatory information on the data. The function
get_balloon should both get the data into the respective variables
and then read and display all the remaining lines of information.
Refer to the week7 directory for details.
(Notice also that the input data file bal500.data is used here only as an example. Using the vi editor you should create and name your own data file using the volume and empty mass that you used in the first balloon exercise.)
2. The second extension of program balloop allows the program to create a text datafile of (altitude, payload) values in your home directory which will subsequently be used for off-line plotting. Thus you will modify the main function to enable creating, writing to, and closing a data file using the various file commands that we learn about in lab7. The second part of this exercise will give you experience in transferring files from condor to your local computer using the SFTP (Secure File Transfer Protocol) program, editing local textfiles with the Wordpad program, and plotting data using the MATLAB application program.
The structure flow diagram of balfile follows:
The following is a complete typical program execution output:
get balloon data from the "bal500.data" file data read: 500, 50 ################newballoon data: First item: volume of the balloon [cu.m] Second item: empty mass of the balloon [kg] ########################################### balloon initialised as follows: balloon volume: 500[cu.m] balloon empty mass: 50[kg] standard atmospheric conditions: temperature lapse rate: -0.0065[deg C/m] temperature at sea level: 15[deg C] standard pressure at sea level: 101325[Pa] determine a sequence of (altitude,payload) points enter low and high bounds of altitude [m]: 0 13000 altitude bounds are [0.0,13000.0] [m] enter the number of points to evaluate 14 number of points entered is 14 altitude[m] payload[kg] 0.0 89.7 1000.0 86.4 2000.0 82.3 3000.0 77.4 4000.0 71.9 5000.0 66.0 6000.0 59.7 7000.0 53.1 8000.0 46.4 9000.0 39.7 10000.0 33.0 11000.0 26.3 WARNING! Altitude 12000.0[m] out of range 12000.0 0.0 WARNING! Altitude 13000.0[m] out of range 13000.0 0.0 14 rows of data written to "balloon.out" file find altitude as a function of required payload enter the required payload [kg]: 80 required payload entered is 80.0[kg] enter required accuracy in altitude [m] 1 required accuracy is 1.0[m] WARNING! Altitude 13000.0[m] out of range for a required payload of 80.0[kg] altitude attained is 2486.3[m]
Notice the line of the output in which it is
stated that 14 rows of data have been written to the data file
named balloon.out. 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.
A printout of the datafile balloon.out is shown below.
0.0 89.7 1000.0 86.4 2000.0 82.3 3000.0 77.4 4000.0 71.9 5000.0 66.0 6000.0 59.7 7000.0 53.1 8000.0 46.4 9000.0 39.7 10000.0 33.0 11000.0 26.3 12000.0 0.0 13000.0 0.0
Once the datafile is available in your home
directory then you should use the SFTP
program to "get" 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 payload vs altitude, as shown in the example plot below. The final graph can be printed on the Laserprinter in the computer printer lab. Notice on the graph that the horizontal line representing your required payload should be included, together with the balloon and atmospheric data.
As before, your program will be separated into two files, the program file balfile.cpp and the header file balfile.h. Both of these files should be in your home directory before the due date. The printout of the graph should be submitted in the box outside room 265 by 10:00am on the due date.