//************************************************************* // Filename: shutarray.h * // Programmer: Dr.Iz (Urieli) * // Date: 09/29/03 * //************************************************************* using namespace std; class Shuttle { // space shuttle upward velocity and height from liftoff. // After separation we follow the empty booster shells. private: float m_total, // [kg] shuttle + fuel + payload at liftoff m_fuel, // [kg] solid fuel in boosters at liftoff v_boost, // [m/s] ejection velocity booster rockets q_boost, // [kg/s] ejection mass flow booster rockets v_orbit, // [m/s] ejection velocity orbiter engines q_orbit; // [kg/s] ejection mass flow orbiter engines public: float gravity; // [m/s^2] gravity acceleration //=================================================================== Shuttle(float mt = 2034681.0) // [kg] assuming 20,000kg payload { // Constructor initialization: m_total = mt; m_fuel = 1004250.0; // [kg] total initial solid fuel v_boost = 2817.0; // [m/s] ejection velocity boosters q_boost = 8369.0; // [kg/s] ejection mass flow boosters v_orbit = 3636.0; // [m/s] ejection velocity q_orbit = 1378.0; // [kg/s] ejection mass flow boosters gravity = 9.807; // [m/s^2] acceleration due to gravity cout << "Shuttle initialized as follows:\n" << " total mass at liftoff: " << m_total << "[kg]\n"; cout << " mass of solid fuel at liftoff: " << m_fuel << "[kg]\n"; cout << " booster ejection fuel velocity: " << v_boost << "[m/s],\n" << " mass flow rate: " << q_boost << "[kg/s]\n"; cout << " orbiter ejection fuel velocity: " << v_orbit << "[m/s],\n" << " mass flow rate: " << q_orbit << "[kg/s]\n"; cout << " initial gravity acceleration: " << setprecision(3) << gravity << "[m/s^2]\n" << setprecision(1); } //=================================================================== float find_velocity(float etime) { // [m/s] upward velocity of shuttle from liftoff // pre: all private and public variables above have values // argument etime (elapsed time) has a value // post: value of upward velocity (velo) has been returned // Note: On separation we follow the empty boosters. float booster, // velocity component due to booster orbiter, // velocity component due to orbiter velo, // net upward velocity of shuttle system vchar; // characteristic velocity of shuttle and boosters float tb = m_fuel/q_boost; // time to "brennschluss" if(etime < tb) { booster = v_boost*log(m_total/(m_total - q_boost*etime)); orbiter = v_orbit*log(m_total/(m_total - q_orbit*etime)); velo = orbiter + booster - gravity*etime; } else { booster = v_boost*log(m_total/(m_total - m_fuel)); orbiter = v_orbit*log(m_total/(m_total - q_orbit*tb)); vchar = orbiter + booster; velo = vchar - gravity*etime; } return velo; // [m/s] } //=========================================================== float find_height(float etime); // height [m] of shuttle from liftoff // etime [s] - elapsed time from liftoff. // Note: On separation we follow the empty boosters. //=========================================================== void funarrays(float etime, int n, float time[], float vel[], float height[]); // creates three coordinate arrays of n components: time, velocity // and height, for equally divided time intervals between liftoff // and the elapsed time interval. //=========================================================== void printarrays(float time[], float vel[], float height[], int n); // prints three columns of the corresponding array elements //=========================================================== void savearrays(float time[], float vel[], float height[], int n); // save the three arrays on a data file in three columns // separated by tabs. The filename is entered from the keyboard. //=========================================================== }; //================================================================ void get_mass(float& mass); // get the Shuttle total initial mass from the \"shuttle.mass\" file\n"; // pre: text data file "shuttle.mass" exists (else program aborts) // post: reference argument mass has a value //======================================================================== void minmax(float y[], int n, float& ymin, float& ymax); // finds minimum and maximum elements of y array //======================================================================== int const SIZE = 100; // maximum size of the arrays