]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGPropeller.h
Merge branch 'jmt/units-fix' into maint
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGPropeller.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGPropeller.h
4  Author:       Jon S. Berndt
5  Date started: 08/24/00
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 08/24/00  JSB  Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGPROPELLER_H
35 #define FGPROPELLER_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "FGThruster.h"
42 #include "math/FGTable.h"
43
44 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 DEFINITIONS
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47
48 #define ID_PROPELLER "$Id$"
49
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 FORWARD DECLARATIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 namespace JSBSim {
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 /** FGPropeller models a propeller given the tabular data for Ct and Cp,
61     indexed by the advance ratio "J". 
62
63 <h3>Configuration File Format:</h3>
64 @code
65 <propeller name="{string}">
66   <ixx> {number} </ixx>
67   <diameter unit="IN"> {number} </diameter>
68   <numblades> {number} </numblades>
69   <gearratio> {number} </gearratio>
70   <minpitch> {number} </minpitch>
71   <maxpitch> {number} </maxpitch>
72   <minrpm> {number} </minrpm>
73   <maxrpm> {number} </maxrpm>
74   <reversepitch> {number} </reversepitch>
75   <sense> {1 | -1} </sense>
76   <p_factor> {number} </p_factor>
77   <ct_factor> {number} </ct_factor>
78   <cp_factor> {number} </cp_factor>
79
80   <table name="C_THRUST" type="internal">
81     <tableData>
82       {numbers}
83     </tableData>
84   </table>
85
86   <table name="C_POWER" type="internal">
87     <tableData>
88       {numbers}
89     </tableData>
90   </table>
91
92 </propeller>
93 @endcode
94
95 <h3>Configuration Parameters:</h3>
96 <pre>
97     \<ixx>           - Propeller rotational inertia.
98     \<diameter>      - Propeller disk diameter.
99     \<numblades>     - Number of blades.
100     \<gearratio>     - Ratio of (engine rpm) / (prop rpm).
101     \<minpitch>      - Minimum blade pitch angle.
102     \<maxpitch>      - Maximum blade pitch angle.
103     \<minrpm>        - Minimum rpm target for constant speed propeller.
104     \<maxrpm>        - Maximum rpm target for constant speed propeller.
105     \<reversepitch>  - Blade pitch angle for reverse.
106     \<sense>         - Direction of rotation (1=clockwise as viewed from cockpit,
107                         -1=anti-clockwise as viewed from cockpit).
108     \<p_factor>      - P factor.
109     \<ct_factor>     - A multiplier for the coefficients of thrust.
110     \<cp_factor>     - A multiplier for the coefficients of power.
111 </pre>
112
113     Two tables are needed. One for coefficient of thrust (Ct) and one for
114     coefficient of power (Cp).  
115     <br>
116
117     Several references were helpful, here:<ul>
118     <li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
119      Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
120     <li>Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of
121     Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6
122     Airfoil Sections", NACA Report TN-640, 1938 (?)</li>
123     <li>Various NACA Technical Notes and Reports</li>
124     </ul>
125     @author Jon S. Berndt
126     @version $Id$
127     @see FGEngine
128     @see FGThruster
129 */
130
131 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 CLASS DECLARATION
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
134
135 class FGPropeller : public FGThruster {
136
137 public:
138   /** Constructor for FGPropeller.
139       @param exec a pointer to the main executive object
140       @param el a pointer to the thruster config file XML element
141       @param num the number of this propeller */
142   FGPropeller(FGFDMExec* exec, Element* el, int num = 0);
143
144   /// Destructor for FGPropeller - deletes the FGTable objects
145   ~FGPropeller();
146
147   /** Sets the Revolutions Per Minute for the propeller. Normally the propeller
148       instance will calculate its own rotational velocity, given the Torque
149       produced by the engine and integrating over time using the standard
150       equation for rotational acceleration "a": a = Q/I , where Q is Torque and
151       I is moment of inertia for the propeller.
152       @param rpm the rotational velocity of the propeller */
153   void SetRPM(double rpm) {RPM = rpm;}
154
155   /// Returns true of this propeller is variable pitch
156   bool IsVPitch(void) {return MaxPitch != MinPitch;}
157
158   /** This commands the pitch of the blade to change to the value supplied.
159       This call is meant to be issued either from the cockpit or by the flight
160       control system (perhaps to maintain constant RPM for a constant-speed
161       propeller). This value will be limited to be within whatever is specified
162       in the config file for Max and Min pitch. It is also one of the lookup
163       indices to the power and thrust tables for variable-pitch propellers.
164       @param pitch the pitch of the blade in degrees. */
165   void SetPitch(double pitch) {Pitch = pitch;}
166
167   void SetAdvance(double advance) {Advance = advance;}
168
169   /// Sets the P-Factor constant
170   void SetPFactor(double pf) {P_Factor = pf;}
171
172   /// Sets coefficient of thrust multiplier
173   void SetCtFactor(double ctf) {CtFactor = ctf;}
174
175   /// Sets coefficient of power multiplier
176   void SetCpFactor(double cpf) {CpFactor = cpf;}
177
178   /** Sets the rotation sense of the propeller.
179       @param s this value should be +/- 1 ONLY. +1 indicates clockwise rotation as
180                viewed by someone standing behind the engine looking forward into
181                the direction of flight. */
182   void SetSense(double s) { Sense = s;}
183
184   /// Retrieves the pitch of the propeller in degrees.
185   double GetPitch(void)         { return Pitch;         }
186
187   /// Retrieves the RPMs of the propeller
188   double GetRPM(void)     const { return RPM;           } 
189
190   /// Retrieves the propeller moment of inertia
191   double GetIxx(void)           { return Ixx;           }
192
193   /// Retrieves the coefficient of thrust multiplier
194   double GetCtFactor(void)      { return CtFactor;      }
195
196   /// Retrieves the coefficient of power multiplier
197   double GetCpFactor(void)      { return CpFactor;      }
198
199   /// Retrieves the propeller diameter
200   double GetDiameter(void)      { return Diameter;      }
201
202   /// Retrieves propeller thrust table
203   FGTable* GetCThrustTable(void) const { return cThrust;}
204   /// Retrieves propeller power table
205   FGTable* GetCPowerTable(void)  const { return cPower; }
206
207   /// Retrieves the Torque in foot-pounds (Don't you love the English system?)
208   double GetTorque(void)        { return vTorque(eX);    }
209
210   /** Retrieves the power required (or "absorbed") by the propeller -
211       i.e. the power required to keep spinning the propeller at the current
212       velocity, air density,  and rotational rate. */
213   double GetPowerRequired(void);
214
215   /** Calculates and returns the thrust produced by this propeller.
216       Given the excess power available from the engine (in foot-pounds), the thrust is
217       calculated, as well as the current RPM. The RPM is calculated by integrating
218       the torque provided by the engine over what the propeller "absorbs"
219       (essentially the "drag" of the propeller).
220       @param PowerAvailable this is the excess power provided by the engine to
221       accelerate the prop. It could be negative, dictating that the propeller
222       would be slowed.
223       @return the thrust in pounds */
224   double Calculate(double PowerAvailable);
225   FGColumnVector3 GetPFactor(void);
226   string GetThrusterLabels(int id, string delimeter);
227   string GetThrusterValues(int id, string delimeter);
228
229   void   SetReverseCoef (double c) { Reverse_coef = c; }
230   double GetReverseCoef (void) { return Reverse_coef; }
231   void   SetReverse (bool r) { Reversed = r; }
232   bool   GetReverse (void) { return Reversed; }
233   void   SetFeather (bool f) { Feathered = f; }
234   bool   GetFeather (void) { return Feathered; }
235   double GetThrustCoefficient(void) const {return ThrustCoeff;}
236
237 private:
238   int   numBlades;
239   double J;
240   double RPM;
241   double Ixx;
242   double Diameter;
243   double MaxPitch;
244   double MinPitch;
245   double MinRPM;
246   double MaxRPM;
247   double Pitch;
248   double P_Factor;
249   double Sense;
250   double Advance;
251   double ExcessTorque;
252   double D4;
253   double D5;
254   FGColumnVector3 vTorque;
255   FGTable *cThrust;
256   FGTable *cPower;
257   double CtFactor;
258   double CpFactor;
259   void Debug(int from);
260   double ReversePitch; // Pitch, when fully reversed
261   bool   Reversed;               // true, when propeller is reversed
262   double Reverse_coef; // 0 - 1 defines AdvancePitch (0=MIN_PITCH 1=REVERSE_PITCH)
263   bool   Feathered;    // true, if feather command
264 };
265 }
266 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
267 #endif
268