//****************************************************************** // HEADER FILE for program hpvplot.cpp * // FILENAME: hpvplot.h * // PROGRAMMER: Dr.Iz (Urieli) * // DATE: 01/17/04 (updated 10/7/2007) * //****************************************************************** using namespace std; class HPvehicle { // human powered vehicle private: float cda, // [sq.m] - (coefficient of drag * frontal area) cr, // [-] - coefficient of rolling resistance mass; // [kg] - mass of hpv + rider public: float g, // [m/s/s] - acceleration due to gravity density, // [kg/cu.m] - air density wind_mph, // [mph] - wind velocity (positive for headwind) slope; // [-] - height/distance - (positive for uphill) //=============================================================== HPvehicle( // Constructor initialization float mass0 = 92.0, // [kg] - 15 kg bike, 80 kg rider typical float cda0 = 0.4, // [sq.m] - upright city bicycle float cr0 = 0.005) // [-] - high pressure tires on flat road { mass = mass0; cda = cda0; cr = cr0; cout << "hpv initialised as follows:\n" << " mass (hpv + rider): " << mass << "[kg]\n" << " cda (coeff.drag*area): " << cda << "[sq.m]\n" << " cr (coeff.rolling resist): " << cr << endl; g = 9.807; // [m/s/s] - standard acceleration due to gravity density = 1.18; // [kg/cu.m] - sea level standard air density wind_mph = slope = 0; cout << "local conditions initialised as follws:\n" << " gravity acceleration: " << g << "[m/s/s]\n" << " air density: " << density << "[kg/cu.m]\n" << " wind velocity: " << wind_mph << "[mph]\n" << " slope: " << slope << endl; cout << "-----------------------------------------------------\n"; } //=============================================================== float find_power(float vel_mph) { // applied power [watts] as function of velocity [mph] // pre: argument vel_mph and all private and public variables // have values // post: power (watts) has been evaluated and returned const float CONVERT = (4.0/9.0); // mph to meters/sec float vel, // velocity converted to m/s wvel, // wind velocity converted to m/s drag, // resistance due to wind drag [N] resist, // resistance due to rolling and slope [N] power; // applied power to wheels [watts] vel = CONVERT * vel_mph; wvel = CONVERT * wind_mph; drag = cda*density*(vel + wvel)*(vel + wvel)/2.0; resist = mass*g*(cr + slope); power = vel*(drag + resist); return power; } //=============================================================== float find_vel(float power, float lo_vel, float hi_vel, float epsilon); // "power" the required power applied to hpv // find the velocity (root of {find_power - power}) within // the bounds [lo_vel,hi_vel] within error bound "epsilon" //=============================================================== float dif_power(float vel, float power){ // returns difference in power - used in the find_vel method return (find_power(vel) - power); } //=============================================================== void funarrays(float lo_vel, float hi_vel, float vel[], float pow[], int n); // creates two coordinate arrays of n components: velocity (vel) // and power (pow), for (n-1) equally divided velocity intervals // between lo_vel and hi_vel. //=========================================================== void savearrays(float vel[], float pow[], int n); // save the two arrays on a data file in two columns // separated by tabs. The filename is entered from the keyboard. //=========================================================== }; //================================================================ int const SIZE = 100; // maximum size of the arrays // general function prototypes: float get_wind(void); // get the wind velocity from the keyboard float get_slope(void); // get the slope from the keyboard void getbike(float& mass, float& cda, float& cr); // get the bike data from a bikefile //====================================================================