This week we learn about arrays which will completely change our approach to programming. Our program is a rewrite of the previous program (hpvfile) which should be modified in structure to include arrays.
In the main function we declare two arrays having a maximum size of 100 values each - one for the velocity values (vel), and one for the applied power values (pow). The main function should then invoke three new functions associated with the HPvehicle class to do the following tasks:
All this is shown in the flow diagram below:

Consider the output of a typical execution of program hpvarray. Notice that in spite of the significant structural change the program output is identical to that of the previous program (hpvfile). Notice that for this execution I decided to find the maximum velocity (no wind, no slope) of the Cheetah under one horsepower (746 watts) of applied power. This turned out to be 63.7mph under sea level conditions. The record breaking speed of 68.7mph was done by Chris Huber in Colorado, at an altitude of 8000 feet, where the air density is significantly less.
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
0
value entered is 0.000[mph]
enter slope (height/distance) - positive for uphill
0
value entered is 0.000
new local conditions:
wind velocity = 0.000[mph]
slope = 0.000
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 7.747
7.368 16.209
11.053 26.100
14.737 38.136
18.421 53.032
22.105 71.502
25.789 94.262
29.474 122.026
33.158 155.510
36.842 195.427
40.526 242.494
44.211 297.424
47.895 360.933
51.579 433.736
55.263 516.548
58.947 610.083
62.632 715.056
66.316 832.183
70.000 962.178
20 rows of data written to "hpv.out" file
find velocity as a function of applied power
enter applied power [watts]
746
enter required accuracy in velocity [mph]
0.1
required accuracy is 0.100[mph]
for applied power of 746.000[watts]
steady state velocity is 63.677[mph]
|
Both the source code file hpvarray.cpp and the header file hpvarray.h should be in your home directory by 10:00 am of the due date.