There are three distinct parts to this exercise, all of which are simple extensions of the previous exercise (hpvloop), and they should be solved and debugged separately:
1. A data file named Cheetah.data contains
the basic private data of the Cheetah
hpv, which broke the world speed record for a human powered vehicle
in 1992 - 68.7mph! We wish to write a function getbike which
will get the data from the file, and use the Constructor of class
HPvehicle to assign this data to the private variables of our
hpv Object. The format of the file Cheetah.data follows:
Notice that the file has three data items followed by six lines of explanatory information on the data. The function getbike 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.
2. Extend the root finding technique to enable you to determine the steady state velocity attained if you apply a specified power to the pedals. Essentially this requires reformulating the power equation that we developed in a previous exercise in terms of a difference function as follows:
Thus the required velocity is the root of the difference function Δ(V). This difference function should be interpreted as follows: "The value of V that makes the difference function Δ(V) = 0 is the value of the steady state velocity resulting from a steady power P applied at the pedals." Note that function find_root has now been renamed find_vel, and has been augmented to accept the required power power as an argument. It represents the value of the steady power applied to the pedals, and is read from the keyboard in the main function module to be used in the new function dif_power, as shown. Note also that you need not rewrite the function find_power since the new function dif_power will invoke function find_power without change, as shown in the following structure diagram of hpvfile:
3. The third extension of program 5 (hpvloop) will let the program create a datafile of (velocity, power) 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. This second part of the 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 following is a complete typical program execution output:
get bike data from the "Cheetah.data" file data read: 95.000, 0.046, 0.005 ============================= Cheetah data, Colorado, 1992. total mass = 95.0 kg CdA = 0.046 sq.m Cr = 0.005 ============================= hpv initialised as follows: mass (hpv + rider): 95.000[kg] cda (coeff.drag*area): 0.046[sq.m] cr (coeff.rolling resist): 0.005 local conditions initialised as follws: gravity acceleration: 9.807[m/s/s] air density: 1.180[kg/cu.m] wind velocity: 0.000[mph] slope: 0.000 ----------------------------------------------------- enter wind velocity [mph] - positive for headwind -1 value entered is -1.000[mph] enter slope (height/distance) - positive for uphill -0.02 value entered is -0.020 new local conditions: wind velocity = -1.000[mph] slope = -0.020 evaluate power vs velocity enter low and high velocity bounds [mph] 0 70 values entered are [0.000,70.000] [mph] enter the number of points to evaluate 20 number of points is 20 velocity (mph) power (W) 0.000 -0.000 3.684 -22.820 7.368 -45.054 11.053 -65.988 14.737 -84.906 18.421 -101.094 22.105 -113.837 25.789 -122.420 29.474 -126.128 33.158 -124.247 36.842 -116.060 40.526 -100.854 44.211 -77.913 47.895 -46.523 51.579 -5.968 55.263 44.466 58.947 105.494 62.632 177.831 66.316 262.192 70.000 359.292 20 rows of data written to "hpv.out" file find velocity as a function of applied power enter applied power [watts] 60 enter required accuracy in velocity [mph] 0.1 required accuracy is 0.100[mph] for applied power of 60.000[watts] steady state velocity is 56.294[mph]
Notice the various items of data entry to this program shown in Italics script. Your teacher has used his own input data for this example, being a one mph tailwind and a downhill slope of 0.02 (or 2%). Even though he was only able to produce 60 watts of power (typical of a laid back professor), he was still able to reach a steady state velocity of 56mph! Use your own data for the execution run, as specified in the first programming exercise (hpv)
Notice the line in which it is stated that 20 lines of data have been written to the hpv.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.
A printout of the datafile hpv.out is shown below.
0.000 -0.000 3.684 -22.820 7.368 -45.054 11.053 -65.988 14.737 -84.906 18.421 -101.094 22.105 -113.837 25.789 -122.420 29.474 -126.128 33.158 -124.247 36.842 -116.060 40.526 -100.854 44.211 -77.913 47.895 -46.523 51.579 -5.968 55.263 44.466 58.947 105.494 62.632 177.831 66.316 262.192 70.000 359.292
Once the datafile is available in your home directory then you should use the SFTP 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 power vs velocity, 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 actual applied power is included, allowing one to read off the graph the value of velocity attained at that power.
As before, your program will be separated into two files, the program file hpvfile.cpp and the header file hpvfile.h. Both of these files should be in your home directory by 10:00 am of the due date. Furthermore, the printout of the graph should be submitted in the box outside Stocker Room 265 by 10:00 am of the due date.