In the first program exercise (hpv), every time you wanted to evaluate a [velocity,power]
coordinate point you had to invoke the program. It would be much
more convenient to obtain and display a sequence of [velocity,
power] points over an entire range of values. This should be done
using an indexed loop. In this exercise there are two modifications
to be done to the main function module only of program hpvroot.cpp.
None of the functions or methods invoked by the main function
should be modified.
1. You will need to separate your program into two files, the program file hpvloop.cpp and the header file hpvloop.h. In order to see how this is done, we have taken our pendulum case study example gfun.cpp from the week3 directory, and separated it into a program file gfun1.cpp and a header file gfun1.h.
2. The program will invoke the real function find_power over a range of values in a for loop. The paradigm for this exercise is the program sin.cpp in the week6 directory, in which we display two columns of n coordinate points using a for loop. Subsequently the coast-down velocity is evaluated, as in the previous exercise.
Thus a typical execution of the program will lead to the following output:
evaluate power vs velocity as a function of wind and slope hpv initialised as follows: mass (hpv + rider): 92[kg] cda (coeff.drag*area): 0.4[sq.m] cr (coeff.rolling resist): 0.005 local conditions initialised as follws: gravity acceleration: 9.807[m/s/s] air density: 1.18[kg/cu.m] wind velocity: 0[mph] slope: 0 ----------------------------------------------------- enter wind velocity [mph] - positive for headwind -1 value entered is -1[mph] enter slope (height/distance) - positive for uphill -0.02 value entered is -0.02 new local conditions: wind velocity = -1[mph] slope = -0.02 enter low and high velocity bounds [mph] 1 25 values entered are [1,25] [mph] enter the number of points to evaluate 13 number of points is 13 velocity (mph) power (W) 1.000 -6.015 3.000 -17.796 5.000 -28.417 7.000 -36.884 9.000 -42.201 11.000 -43.374 13.000 -39.409 15.000 -29.311 17.000 -12.086 19.000 13.261 21.000 47.724 23.000 92.298 25.000 147.977 evaluate coastdown velocity enter required accuracy in coastdown velocity [mph] 0.1 required accuracy is 0.100[mph] coastdown velocity is 18.016[mph]
As in previous exercises notice that the various items of data entry to this program are written in Italics script. In order to enable this program to be graded, this sequence of data entry should be strictly adhered to.
Both the source code file hpvloop.cpp and the header file hpvloop.h should be in your home directory by 10.00 a.m. of the due date.