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 "math/FGFunction.h"
44 #include "input_output/FGXMLElement.h"
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 #define ID_ROCKET "$Id: FGRocket.h,v 1.18 2012/04/08 15:19:08 jberndt Exp $"
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 /** Models a generic rocket engine.
63 The rocket engine is modeled given the following parameters:
65 <li>Specific Impulse (in sec)</li>
67 Additionally, the following control inputs, operating characteristics, and
68 location are required, as with all other engine types:
70 <li>Throttle setting (in percent, from 0 to 1.0)</li>
71 <li>Maximum allowable throttle setting</li>
72 <li>Minimum working throttle setting</li>
73 <li>Sea level fuel flow at maximum thrust</li>
74 <li>Sea level oxidizer flow at maximum thrust</li>
75 <li>X, Y, Z location in structural coordinate frame</li>
76 <li>Pitch and Yaw</li>
78 The nozzle exit pressure (p2) is returned via a
79 call to FGNozzle::GetPowerRequired(). This exit pressure is used
80 to get the at-altitude thrust level.
82 One can model the thrust of a solid rocket by providing a normalized thrust table
83 as a function of time. For instance, the space shuttle solid rocket booster
84 normalized thrust value looks roughly like this:
87 \<thrust_table name="propulsion/thrust_time" type="internal">
115 The left column is time, the right column is normalized thrust. Inside the
116 FGRocket class code, the maximum thrust is calculated, and multiplied by this
117 table. The Rocket class also tracks burn time. All that needs to be done is
118 for the rocket engine to be throttle up to 1. At that time, the solid rocket
119 fuel begins burning and thrust is provided.
121 @author Jon S. Berndt
122 $Id: FGRocket.h,v 1.18 2012/04/08 15:19:08 jberndt Exp $
129 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
133 class FGRocket : public FGEngine
137 @param exec pointer to JSBSim parent object, the FDM Executive.
138 @param el a pointer to the XML Element instance representing the engine.
139 @param engine_number engine number */
140 FGRocket(FGFDMExec* exec, Element *el, int engine_number, struct FGEngine::Inputs& input);
145 /** Determines the thrust.*/
146 void Calculate(void);
148 /** The fuel need is calculated based on power levels and flow rate for that
149 power level. It is also turned from a rate into an actual amount (pounds)
150 by multiplying it by the delta T and the rate.
151 @return Total fuel requirement for this engine in pounds. */
152 double CalcFuelNeed(void);
154 /** The oxidizer need is calculated based on power levels and flow rate for that
155 power level. It is also turned from a rate into an actual amount (pounds)
156 by multiplying it by the delta T and the rate.
157 @return Total oxidizer requirement for this engine in pounds. */
158 double CalcOxidizerNeed(void);
160 /** Gets the total impulse of the rocket.
161 @return The cumulative total impulse of the rocket up to this time.*/
162 double GetTotalImpulse(void) const {return It;}
164 /** Gets the flame-out status.
165 The engine will "flame out" if the throttle is set below the minimum
166 sustainable-thrust setting.
167 @return true if engine has flamed out. */
168 bool GetFlameout(void) {return Flameout;}
170 double GetOxiFlowRate(void) const {return OxidizerFlowRate;}
172 double GetMixtureRatio(void) const {return MxR;}
174 double GetIsp(void) const {return Isp;}
176 void SetMixtureRatio(double mix) {MxR = mix;}
178 void SetIsp(double isp) {Isp = isp;}
180 std::string GetEngineLabels(const std::string& delimiter);
181 std::string GetEngineValues(const std::string& delimiter);
183 /** Sets the thrust variation for a solid rocket engine.
184 Solid propellant rocket motor thrust characteristics are typically
185 defined at 70 degrees F temperature. At any other temperature,
186 performance will be different. Warmer propellant grain will
187 burn quicker and at higher thrust. Total motor impulse is
188 not changed for change in thrust.
189 @param var the variation in percent. That is, a 2 percent
190 variation would be specified as 0.02. A positive 2% variation
191 in thrust would increase the thrust by 2%, and shorten the burn time. */
192 void SetThrustVariation(double var) {ThrustVariation = var;}
194 /** Sets the variation in total motor energy.
195 The total energy present in a solid rocket motor can be modified
196 (such as might happen with manufacturing variations) by setting
197 the total Isp variation.
198 @param var the variation in percent. That is, a 2 percent
199 variation would be specified as 0.02. This variation will
200 affect the total thrust, but not the burn time.*/
201 void SetTotalIspVariation(double var) {TotalIspVariation = var;}
203 /** Returns the thrust variation, if any. */
204 double GetThrustVariation(void) const {return ThrustVariation;}
206 /** Returns the Total Isp variation, if any. */
207 double GetTotalIspVariation(void) const {return TotalIspVariation;}
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;
226 double TotalPropellantExpended;
229 double OxidizerFlowRate;
230 double PropellantFlowRate;
233 FGTable* ThrustTable;
234 FGFunction* isp_function;
236 void Debug(int from);
239 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%