//********************************************************************* // PURPOSE: header file for balplot.cpp * // FILENAME: balplot.h * // PROGRAMMER: Dr.Iz (Urieli) * // DATE: 03/27/04 * //********************************************************************* using namespace std; class Balloon { // hot air balloon private: float volume, // [cu.m] - balloon volume mass; // [kg] - balloon empty mass public: float lapse, // [deg C/m] - temperature lapse rate temp0, // [deg C] - temperature at sea level pres0, // [Pa] - standard pressure at sea level rgas, // [J/kg K] - gas constant of air g; // [m/s/s] - acceleration due to gravity //=============================================================== Balloon( // Constructor initialization float volume0 = 1000.0, // [cu.m] float mass0 = 100.0) // [kg] - balloon empty mass { volume = volume0; mass = mass0; lapse = -6.5e-3; // [deg C/m] - temperature lapse rate temp0 = 15.0; // [deg C] - temperature at sea level pres0 = 101325.0; // [Pa] - standard pressure at sea level rgas = 287.0; // [J/kg K] - gas constant of air g = 9.807; // [m/s/s] - standard acceleration due to gravity cout << "balloon initialised as follows:\n" << " balloon volume: " << volume << "[cu.m]\n" << " balloon empty mass: " << mass << "[kg]\n"; cout << "standard atmospheric conditions:\n" << " temperature lapse rate: " << lapse << "[deg C/m]\n" << " temperature at sea level: " << temp0 << "[deg C]\n" << " standard pressure at sea level: " << pres0 << "[Pa]\n"; } //=============================================================== float find_payload(float altitude); // prototype // determine balloon payload [kg] as function of altitude [m] // pre: all private and public variables & altitude have values // post: value of payload is returned // if altitude negative or >11,000m payload is not evaluated // and payload mass of zero is returned // Dr.Iz (Urieli) 03/25/04 //=============================================================== float find_altitude(float req_payload, float lo_alt, float hi_alt, float epsilon); // find the altitude (root of {find_payload - req_payload}) within // [lo_alt,hi_alt] within error bound "epsilon" using bisection // pre: req_payload (required payload) has a value // float bounds [lo_alt, hi_alt] have values // epsilon (allowable error in root) has a value // post: either the root "mid_alt" has been determined within a // tolerance epsilon and has been returned // or a warning message has been displayed //=============================================================== float dif_payload(float altitude, float req_payload){ // pre: arguments altitude and req_payload have values // post: difference of actual and required payload is returned return (find_payload(altitude) - req_payload); } //=============================================================== void funarrays(float lo_alt, float hi_alt, float alt[], float pay[], int n); // creates two coordinate arrays of n components: altitude (alt) // and payload (pay), for (n-1) equally divided altitude intervals // between lo_alt and hi_alt. //=========================================================== void savearrays(float alt[], float pay[], int n); // save the two arrays on a data file in two columns // separated by tabs. The filename is entered from the keyboard. //=========================================================== }; //================================================================ void get_balloon(float& volume, float& mass); // get the basic balloon data from a balloon-file // pre: text data file exists (else program aborts) // post: reference arguments volume and mass have values //=============================================================== int const SIZE = 100; // maximum size of the arrays //================================================================