1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 Date started: 09/12/2000
7 ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) --------------
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
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
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.
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.
27 --------------------------------------------------------------------------------
28 09/12/2000 JSB Created
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 #include "math/FGTable.h"
43 #include "input_output/FGXMLElement.h"
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 #define ID_ROCKET "$Id: FGRocket.h,v 1.14 2010/08/21 18:08:25 jberndt Exp $"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 /** Models a generic rocket engine.
62 The rocket engine is modeled given the following parameters:
64 <li>Specific Impulse (in sec)</li>
66 Additionally, the following control inputs, operating characteristics, and
67 location are required, as with all other engine types:
69 <li>Throttle setting (in percent, from 0 to 1.0)</li>
70 <li>Maximum allowable throttle setting</li>
71 <li>Minimum working throttle setting</li>
72 <li>Sea level fuel flow at maximum thrust</li>
73 <li>Sea level oxidizer flow at maximum thrust</li>
74 <li>X, Y, Z location in structural coordinate frame</li>
75 <li>Pitch and Yaw</li>
77 The nozzle exit pressure (p2) is returned via a
78 call to FGNozzle::GetPowerRequired(). This exit pressure is used
79 to get the at-altitude thrust level.
81 One can model the thrust of a solid rocket by providing a normalized thrust table
82 as a function of time. For instance, the space shuttle solid rocket booster
83 normalized thrust value looks roughly like this:
86 \<thrust_table name="propulsion/thrust_time" type="internal">
114 The left column is time, the right column is normalized thrust. Inside the
115 FGRocket class code, the maximum thrust is calculated, and multiplied by this
116 table. The Rocket class also tracks burn time. All that needs to be done is
117 for the rocket engine to be throttle up to 1. At that time, the solid rocket
118 fuel begins burning and thrust is provided.
120 @author Jon S. Berndt
121 $Id: FGRocket.h,v 1.14 2010/08/21 18:08:25 jberndt Exp $
130 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
134 class FGRocket : public FGEngine
138 @param exec pointer to JSBSim parent object, the FDM Executive.
139 @param el a pointer to the XML Element instance representing the engine.
140 @param engine_number engine number */
141 FGRocket(FGFDMExec* exec, Element *el, int engine_number);
146 /** Determines the thrust.*/
147 void Calculate(void);
149 /** Gets the total impulse of the rocket.
150 @return The cumulative total impulse of the rocket up to this time.*/
151 double GetTotalImpulse(void) const {return It;}
153 /** Gets the flame-out status.
154 The engine will "flame out" if the throttle is set below the minimum
155 sustainable-thrust setting.
156 @return true if engine has flamed out. */
157 bool GetFlameout(void) {return Flameout;}
159 double GetOxiFlowRate(void) const {return OxidizerFlowRate;}
161 std::string GetEngineLabels(const std::string& delimiter);
162 std::string GetEngineValues(const std::string& delimiter);
164 /** Sets the thrust variation for a solid rocket engine.
165 Solid propellant rocket motor thrust characteristics are typically
166 defined at 70 degrees F temperature. At any other temperature,
167 performance will be different. Warmer propellant grain will
168 burn quicker and at higher thrust. Total motor impulse is
169 not changed for change in thrust.
170 @param var the variation in percent. That is, a 2 percent
171 variation would be specified as 0.02. A positive 2% variation
172 in thrust would increase the thrust by 2%, and shorten the burn time. */
173 void SetThrustVariation(double var) {ThrustVariation = var;}
175 /** Sets the variation in total motor energy.
176 The total energy present in a solid rocket motor can be modified
177 (such as might happen with manufacturing variations) by setting
178 the total Isp variation.
179 @param var the variation in percent. That is, a 2 percent
180 variation would be specified as 0.02. This variation will
181 affect the total thrust, but not the burn time.*/
182 void SetTotalIspVariation(double var) {TotalIspVariation = var;}
184 /** Returns the thrust variation, if any. */
185 double GetThrustVariation(void) const {return ThrustVariation;}
187 /** Returns the Total Isp variation, if any. */
188 double GetTotalIspVariation(void) const {return TotalIspVariation;}
191 /** Reduces the fuel in the active tanks by the amount required.
192 This function should be called from within the
193 derived class' Calculate() function before any other calculations are
194 done. This base class method removes fuel from the fuel tanks as
195 appropriate, and sets the starved flag if necessary. */
196 void ConsumeFuel(void);
198 /** The fuel need is calculated based on power levels and flow rate for that
199 power level. It is also turned from a rate into an actual amount (pounds)
200 by multiplying it by the delta T and the rate.
201 @return Total fuel requirement for this engine in pounds. */
202 double CalcFuelNeed(void);
204 /** The oxidizer need is calculated based on power levels and flow rate for that
205 power level. It is also turned from a rate into an actual amount (pounds)
206 by multiplying it by the delta T and the rate.
207 @return Total oxidizer requirement for this engine in pounds. */
208 double CalcOxidizerNeed(void);
210 /** Returns the vacuum thrust.
211 @return The vacuum thrust in lbs. */
212 double GetVacThrust(void) const {return VacThrust;}
214 void bindmodel(void);
216 double Isp; // Vacuum Isp
218 double MxR; // Mixture Ratio
220 double ThrustVariation;
221 double TotalIspVariation;
223 double previousFuelNeedPerTank;
224 double previousOxiNeedPerTank;
225 double OxidizerExpended;
227 double OxidizerFlowRate;
228 double PropellantFlowRate;
231 FGTable* ThrustTable;
233 void Debug(int from);
236 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%