]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGRocket.h
Merge branch 'next' of gitorious.org:fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGRocket.h
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 (jon@jsbsim.org) --------------
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 #include "input_output/FGXMLElement.h"
45
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 DEFINITIONS
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50 #define ID_ROCKET "$Id: FGRocket.h,v 1.18 2012/04/08 15:19:08 jberndt Exp $"
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 FORWARD DECLARATIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 namespace JSBSim {
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 /** Models a generic rocket engine.
63     The rocket engine is modeled given the following parameters:
64     <ul>
65         <li>Specific Impulse (in sec)</li>
66     </ul>
67     Additionally, the following control inputs, operating characteristics, and
68     location are required, as with all other engine types:
69     <ul>
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>
77     </ul>
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.
81     
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:
85
86 <pre>    
87  \<thrust_table name="propulsion/thrust_time" type="internal">
88    \<tableData>
89       0.0   0.00
90       0.2   0.91
91       8.0   0.97
92      16.0   0.99
93      20.0   1.00
94      21.0   1.00
95      24.0   0.95
96      32.0   0.85
97      40.0   0.78
98      48.0   0.72
99      50.0   0.71
100      52.0   0.71
101      56.0   0.73
102      64.0   0.78
103      72.0   0.82
104      80.0   0.81
105      88.0   0.73
106      96.0   0.69
107     104.0   0.59
108     112.0   0.46
109     120.0   0.09
110     132.0   0.00
111    \</tableData>
112  \</thrust_table>
113 </pre>
114
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.
120
121     @author Jon S. Berndt
122     $Id: FGRocket.h,v 1.18 2012/04/08 15:19:08 jberndt Exp $
123     @see FGNozzle,
124     FGThruster,
125     FGForce,
126     FGEngine,
127 */
128
129 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 CLASS DECLARATION
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
132
133 class FGRocket : public FGEngine
134 {
135 public:
136   /** Constructor.
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);
141
142   /** Destructor */
143   ~FGRocket(void);
144
145   /** Determines the thrust.*/
146   void Calculate(void);
147
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);
153
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);
159
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;}
163
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;}
169
170   double GetOxiFlowRate(void) const {return OxidizerFlowRate;}
171
172   double GetMixtureRatio(void) const {return MxR;}
173
174   double GetIsp(void) const {return Isp;}
175
176   void SetMixtureRatio(double mix) {MxR = mix;}
177
178   void SetIsp(double isp) {Isp = isp;}
179
180   std::string GetEngineLabels(const std::string& delimiter);
181   std::string GetEngineValues(const std::string& delimiter);
182
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;}
193
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;}
202
203   /** Returns the thrust variation, if any. */
204   double GetThrustVariation(void) const {return ThrustVariation;}
205
206   /** Returns the Total Isp variation, if any. */
207   double GetTotalIspVariation(void) const {return TotalIspVariation;}
208
209 private:
210   /** Returns the vacuum thrust.
211       @return The vacuum thrust in lbs. */
212   double GetVacThrust(void) const {return VacThrust;}
213
214   void bindmodel(void);
215
216   double Isp; // Vacuum Isp
217   double It;
218   double MxR; // Mixture Ratio
219   double BurnTime;
220   double ThrustVariation;
221   double TotalIspVariation;
222   double VacThrust;
223   double previousFuelNeedPerTank;
224   double previousOxiNeedPerTank;
225   double OxidizerExpended;
226   double TotalPropellantExpended;
227   double SLOxiFlowMax;
228   double PropFlowMax;
229   double OxidizerFlowRate;
230   double PropellantFlowRate;
231   bool Flameout;
232   double BuildupTime;
233   FGTable* ThrustTable;
234   FGFunction* isp_function;
235
236   void Debug(int from);
237 };
238 }
239 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240 #endif
241