]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGRocket.h
Synchronized with JSBSim/CVS
[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
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 DEFINITIONS
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49 #define ID_ROCKET "$Id: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $"
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 FORWARD DECLARATIONS
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 namespace JSBSim {
56
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 CLASS DOCUMENTATION
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60
61 /** Models a generic rocket engine.
62     The rocket engine is modeled given the following parameters:
63     <ul>
64         <li>Specific Impulse (in sec)</li>
65     </ul>
66     Additionally, the following control inputs, operating characteristics, and
67     location are required, as with all other engine types:
68     <ul>
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>
76     </ul>
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.
80     
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:
84
85 <pre>    
86  \<thrust_table name="propulsion/thrust_time" type="internal">
87    \<tableData>
88       0.0   0.00
89       0.2   0.91
90       8.0   0.97
91      16.0   0.99
92      20.0   1.00
93      21.0   1.00
94      24.0   0.95
95      32.0   0.85
96      40.0   0.78
97      48.0   0.72
98      50.0   0.71
99      52.0   0.71
100      56.0   0.73
101      64.0   0.78
102      72.0   0.82
103      80.0   0.81
104      88.0   0.73
105      96.0   0.69
106     104.0   0.59
107     112.0   0.46
108     120.0   0.09
109     132.0   0.00
110    \</tableData>
111  \</thrust_table>
112 </pre>
113
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.
119
120     @author Jon S. Berndt
121     $Id: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $
122     @see FGNozzle,
123     FGThruster,
124     FGForce,
125     FGEngine,
126 */
127
128 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129 CLASS DECLARATION
130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
131
132 class FGRocket : public FGEngine
133 {
134 public:
135   /** Constructor.
136       @param exec pointer to JSBSim parent object, the FDM Executive.
137       @param el a pointer to the XML Element instance representing the engine.
138       @param engine_number engine number */
139   FGRocket(FGFDMExec* exec, Element *el, int engine_number, struct FGEngine::Inputs& input);
140
141   /** Destructor */
142   ~FGRocket(void);
143
144   /** Determines the thrust.*/
145   void Calculate(void);
146
147   /** The fuel need is calculated based on power levels and flow rate for that
148       power level. It is also turned from a rate into an actual amount (pounds)
149       by multiplying it by the delta T and the rate.
150       @return Total fuel requirement for this engine in pounds. */
151   double CalcFuelNeed(void);
152
153   /** The oxidizer need is calculated based on power levels and flow rate for that
154       power level. It is also turned from a rate into an actual amount (pounds)
155       by multiplying it by the delta T and the rate.
156       @return Total oxidizer requirement for this engine in pounds. */
157   double CalcOxidizerNeed(void);
158
159   /** Gets the total impulse of the rocket.
160       @return The cumulative actual total impulse of the rocket up to this time.*/
161   double GetTotalImpulse(void) const {return It;}
162
163   /** Gets the total impulse of the rocket.
164       @return The cumulative vacuum total impulse of the rocket up to this time.*/
165   double GetVacTotalImpulse(void) const {return ItVac;}
166
167   /** Gets the flame-out status.
168       The engine will "flame out" if the throttle is set below the minimum
169       sustainable-thrust setting.
170       @return true if engine has flamed out. */
171   bool GetFlameout(void) {return Flameout;}
172
173   double GetOxiFlowRate(void) const {return OxidizerFlowRate;}
174
175   double GetMixtureRatio(void) const {return MxR;}
176
177   double GetIsp(void) const {return Isp;}
178
179   void SetMixtureRatio(double mix) {MxR = mix;}
180
181   void SetIsp(double isp) {Isp = isp;}
182
183   std::string GetEngineLabels(const std::string& delimiter);
184   std::string GetEngineValues(const std::string& delimiter);
185
186   /** Sets the thrust variation for a solid rocket engine. 
187       Solid propellant rocket motor thrust characteristics are typically
188       defined at 70 degrees F temperature. At any other temperature,
189       performance will be different. Warmer propellant grain will
190       burn quicker and at higher thrust.  Total motor impulse is
191       not changed for change in thrust.
192       @param var the variation in percent. That is, a 2 percent
193       variation would be specified as 0.02. A positive 2% variation
194       in thrust would increase the thrust by 2%, and shorten the burn time. */
195   void SetThrustVariation(double var) {ThrustVariation = var;}
196
197   /** Sets the variation in total motor energy.
198       The total energy present in a solid rocket motor can be modified
199       (such as might happen with manufacturing variations) by setting
200       the total Isp variation. 
201       @param var the variation in percent. That is, a 2 percent
202       variation would be specified as 0.02. This variation will 
203       affect the total thrust, but not the burn time.*/
204   void SetTotalIspVariation(double var) {TotalIspVariation = var;}
205
206   /** Returns the thrust variation, if any. */
207   double GetThrustVariation(void) const {return ThrustVariation;}
208
209   /** Returns the Total Isp variation, if any. */
210   double GetTotalIspVariation(void) const {return TotalIspVariation;}
211
212 private:
213   /** Returns the vacuum thrust.
214       @return The vacuum thrust in lbs. */
215   double GetVacThrust(void) const {return VacThrust;}
216
217   void bindmodel(void);
218
219   double Isp; // Vacuum Isp
220   double It;    // Total actual Isp
221   double ItVac; // Total Vacuum Isp
222   double MxR; // Mixture Ratio
223   double BurnTime;
224   double ThrustVariation;
225   double TotalIspVariation;
226   double VacThrust;
227   double previousFuelNeedPerTank;
228   double previousOxiNeedPerTank;
229   double OxidizerExpended;
230   double TotalPropellantExpended;
231   double SLOxiFlowMax;
232   double PropFlowMax;
233   double OxidizerFlowRate;
234   double PropellantFlowRate;
235   bool Flameout;
236   double BuildupTime;
237   FGTable* ThrustTable;
238   FGFunction* isp_function;
239
240   void Debug(int from);
241 };
242 }
243 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 #endif
245