| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | Header: FGRocket.h |
| 4 | Author: Jon S. Berndt |
| 5 | Date started: 09/12/2000 |
| 6 | |
| 7 | ------------- Copyright (C) 2000 Jon S. Berndt ([email protected]) -------------- |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify it under |
| 10 | the terms of the GNU Lesser General Public License as published by the Free Software |
| 11 | Foundation; either version 2 of the License, or (at your option) any later |
| 12 | version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 17 | details. |
| 18 | |
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | |
| 23 | Further information about the GNU Lesser General Public License can also be found on |
| 24 | the world wide web at http://www.gnu.org. |
| 25 | |
| 26 | HISTORY |
| 27 | -------------------------------------------------------------------------------- |
| 28 | 09/12/2000 JSB Created |
| 29 | |
| 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 31 | SENTRY |
| 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 33 | |
| 34 | #ifndef FGROCKET_H |
| 35 | #define FGROCKET_H |
| 36 | |
| 37 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 38 | INCLUDES |
| 39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 40 | |
| 41 | #include "FGEngine.h" |
| 42 | #include "math/FGTable.h" |
| 43 | #include "math/FGFunction.h" |
| 44 | |
| 45 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 46 | FORWARD DECLARATIONS |
| 47 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 48 | |
| 49 | namespace JSBSim { |
| 50 | |
| 51 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 52 | CLASS DOCUMENTATION |
| 53 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 54 | |
| 55 | /** Models a generic rocket engine. |
| 56 | The rocket engine is modeled given the following parameters: |
| 57 | <ul> |
| 58 | <li>Specific Impulse (in sec)</li> |
| 59 | </ul> |
| 60 | Additionally, the following control inputs, operating characteristics, and |
| 61 | location are required, as with all other engine types: |
| 62 | <ul> |
| 63 | <li>Throttle setting (in percent, from 0 to 1.0)</li> |
| 64 | <li>Maximum allowable throttle setting</li> |
| 65 | <li>Minimum working throttle setting</li> |
| 66 | <li>Sea level fuel flow at maximum thrust</li> |
| 67 | <li>Sea level oxidizer flow at maximum thrust</li> |
| 68 | <li>X, Y, Z location in structural coordinate frame</li> |
| 69 | <li>Pitch and Yaw</li> |
| 70 | </ul> |
| 71 | The nozzle exit pressure (p2) is returned via a |
| 72 | call to FGNozzle::GetPowerRequired(). This exit pressure is used |
| 73 | to get the at-altitude thrust level. |
| 74 | |
| 75 | One can model the thrust of a solid rocket by providing a normalized thrust table |
| 76 | as a function of time. For instance, the space shuttle solid rocket booster |
| 77 | normalized thrust value looks roughly like this: |
| 78 | |
| 79 | <pre> |
| 80 | \<thrust_table name="propulsion/thrust_time" type="internal"> |
| 81 | \<tableData> |
| 82 | 0.0 0.00 |
| 83 | 0.2 0.91 |
| 84 | 8.0 0.97 |
| 85 | 16.0 0.99 |
| 86 | 20.0 1.00 |
| 87 | 21.0 1.00 |
| 88 | 24.0 0.95 |
| 89 | 32.0 0.85 |
| 90 | 40.0 0.78 |
| 91 | 48.0 0.72 |
| 92 | 50.0 0.71 |
| 93 | 52.0 0.71 |
| 94 | 56.0 0.73 |
| 95 | 64.0 0.78 |
| 96 | 72.0 0.82 |
| 97 | 80.0 0.81 |
| 98 | 88.0 0.73 |
| 99 | 96.0 0.69 |
| 100 | 104.0 0.59 |
| 101 | 112.0 0.46 |
| 102 | 120.0 0.09 |
| 103 | 132.0 0.00 |
| 104 | \</tableData> |
| 105 | \</thrust_table> |
| 106 | </pre> |
| 107 | |
| 108 | The left column is time, the right column is normalized thrust. Inside the |
| 109 | FGRocket class code, the maximum thrust is calculated, and multiplied by this |
| 110 | table. The Rocket class also tracks burn time. All that needs to be done is |
| 111 | for the rocket engine to be throttle up to 1. At that time, the solid rocket |
| 112 | fuel begins burning and thrust is provided. |
| 113 | |
| 114 | @author Jon S. Berndt |
| 115 | @see FGNozzle, |
| 116 | FGThruster, |
| 117 | FGForce, |
| 118 | FGEngine, |
| 119 | */ |
| 120 | |
| 121 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 122 | CLASS DECLARATION |
| 123 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 124 | |
| 125 | class FGRocket : public FGEngine |
| 126 | { |
| 127 | public: |
| 128 | /** Constructor. |
| 129 | @param exec pointer to JSBSim parent object, the FDM Executive. |
| 130 | @param el a pointer to the XML Element instance representing the engine. |
| 131 | @param engine_number engine number */ |
| 132 | FGRocket(FGFDMExec* exec, Element *el, int engine_number, struct FGEngine::Inputs& input); |
| 133 | |
| 134 | /** Destructor */ |
| 135 | ~FGRocket(void); |
| 136 | |
| 137 | /** Determines the thrust.*/ |
| 138 | void Calculate(void); |
| 139 | |
| 140 | /** The fuel need is calculated based on power levels and flow rate for that |
| 141 | power level. It is also turned from a rate into an actual amount (pounds) |
| 142 | by multiplying it by the delta T and the rate. |
| 143 | @return Total fuel requirement for this engine in pounds. */ |
| 144 | double CalcFuelNeed(void); |
| 145 | |
| 146 | /** The oxidizer need is calculated based on power levels and flow rate for that |
| 147 | power level. It is also turned from a rate into an actual amount (pounds) |
| 148 | by multiplying it by the delta T and the rate. |
| 149 | @return Total oxidizer requirement for this engine in pounds. */ |
| 150 | double CalcOxidizerNeed(void); |
| 151 | |
| 152 | /** Gets the total impulse of the rocket. |
| 153 | @return The cumulative actual total impulse of the rocket up to this time.*/ |
| 154 | double GetTotalImpulse(void) const {return It;} |
| 155 | |
| 156 | /** Gets the total impulse of the rocket. |
| 157 | @return The cumulative vacuum total impulse of the rocket up to this time.*/ |
| 158 | double GetVacTotalImpulse(void) const {return ItVac;} |
| 159 | |
| 160 | /** Gets the flame-out status. |
| 161 | The engine will "flame out" if the throttle is set below the minimum |
| 162 | sustainable-thrust setting. |
| 163 | @return true if engine has flamed out. */ |
| 164 | bool GetFlameout(void) {return Flameout;} |
| 165 | |
| 166 | double GetOxiFlowRate(void) const {return OxidizerFlowRate;} |
| 167 | |
| 168 | double GetMixtureRatio(void) const {return MxR;} |
| 169 | |
| 170 | double GetIsp(void) const {return Isp;} |
| 171 | |
| 172 | void SetMixtureRatio(double mix) {MxR = mix;} |
| 173 | |
| 174 | void SetIsp(double isp) {Isp = isp;} |
| 175 | |
| 176 | std::string GetEngineLabels(const std::string& delimiter); |
| 177 | std::string GetEngineValues(const std::string& delimiter); |
| 178 | |
| 179 | /** Sets the thrust variation for a solid rocket engine. |
| 180 | Solid propellant rocket motor thrust characteristics are typically |
| 181 | defined at 70 degrees F temperature. At any other temperature, |
| 182 | performance will be different. Warmer propellant grain will |
| 183 | burn quicker and at higher thrust. Total motor impulse is |
| 184 | not changed for change in thrust. |
| 185 | @param var the variation in percent. That is, a 2 percent |
| 186 | variation would be specified as 0.02. A positive 2% variation |
| 187 | in thrust would increase the thrust by 2%, and shorten the burn time. */ |
| 188 | void SetThrustVariation(double var) {ThrustVariation = var;} |
| 189 | |
| 190 | /** Sets the variation in total motor energy. |
| 191 | The total energy present in a solid rocket motor can be modified |
| 192 | (such as might happen with manufacturing variations) by setting |
| 193 | the total Isp variation. |
| 194 | @param var the variation in percent. That is, a 2 percent |
| 195 | variation would be specified as 0.02. This variation will |
| 196 | affect the total thrust, but not the burn time.*/ |
| 197 | void SetTotalIspVariation(double var) {TotalIspVariation = var;} |
| 198 | |
| 199 | /** Returns the thrust variation, if any. */ |
| 200 | double GetThrustVariation(void) const {return ThrustVariation;} |
| 201 | |
| 202 | /** Returns the Total Isp variation, if any. */ |
| 203 | double GetTotalIspVariation(void) const {return TotalIspVariation;} |
| 204 | |
| 205 | private: |
| 206 | /** Returns the vacuum thrust. |
| 207 | @return The vacuum thrust in lbs. */ |
| 208 | double GetVacThrust(void) const {return VacThrust;} |
| 209 | |
| 210 | void bindmodel(FGPropertyManager* pm); |
| 211 | |
| 212 | double Isp; // Vacuum Isp |
| 213 | double It; // Total actual Isp |
| 214 | double ItVac; // Total Vacuum Isp |
| 215 | double MxR; // Mixture Ratio |
| 216 | double BurnTime; |
| 217 | double ThrustVariation; |
| 218 | double TotalIspVariation; |
| 219 | double VacThrust; |
| 220 | double previousFuelNeedPerTank; |
| 221 | double previousOxiNeedPerTank; |
| 222 | double OxidizerExpended; |
| 223 | double TotalPropellantExpended; |
| 224 | double SLOxiFlowMax; |
| 225 | double PropFlowMax; |
| 226 | double OxidizerFlowRate; |
| 227 | double PropellantFlowRate; |
| 228 | bool Flameout; |
| 229 | double BuildupTime; |
| 230 | FGTable* ThrustTable; |
| 231 | FGFunction* isp_function; |
| 232 | FGFDMExec* FDMExec; |
| 233 | |
| 234 | void Debug(int from); |
| 235 | }; |
| 236 | } |
| 237 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 238 | #endif |