| 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 ([email protected]) ------------- |
| 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 | FORWARD DECLARATIONS |
| 46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 47 | |
| 48 | namespace JSBSim { |
| 49 | |
| 50 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 51 | CLASS DOCUMENTATION |
| 52 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 53 | |
| 54 | /** FGPropeller models a propeller given the tabular data for Ct (thrust) and |
| 55 | Cp (power), indexed by the advance ratio "J". |
| 56 | |
| 57 | ### Configuration File Format |
| 58 | |
| 59 | ~~~{.xml} |
| 60 | <sense> {1 | -1} </sense> |
| 61 | <p_factor> {number} </p_factor> |
| 62 | <propeller name="{string}" version="{string}"> |
| 63 | <ixx> {number} </ixx> |
| 64 | <diameter unit="IN"> {number} </diameter> |
| 65 | <numblades> {number} </numblades> |
| 66 | <gearratio> {number} </gearratio> |
| 67 | <minpitch> {number} </minpitch> |
| 68 | <maxpitch> {number} </maxpitch> |
| 69 | <minrpm> {number} </minrpm> |
| 70 | <maxrpm> {number} </maxrpm> |
| 71 | <constspeed> {number} </constspeed> |
| 72 | <reversepitch> {number} </reversepitch> |
| 73 | <ct_factor> {number} </ct_factor> |
| 74 | <cp_factor> {number} </cp_factor> |
| 75 | |
| 76 | <table name="C_THRUST" type="internal"> |
| 77 | <tableData> |
| 78 | {numbers} |
| 79 | </tableData> |
| 80 | </table> |
| 81 | |
| 82 | <table name="C_POWER" type="internal"> |
| 83 | <tableData> |
| 84 | {numbers} |
| 85 | </tableData> |
| 86 | </table> |
| 87 | |
| 88 | <table name="CT_MACH" type="internal"> |
| 89 | <tableData> |
| 90 | {numbers} |
| 91 | </tableData> |
| 92 | </table> |
| 93 | |
| 94 | <table name="CP_MACH" type="internal"> |
| 95 | <tableData> |
| 96 | {numbers} |
| 97 | </tableData> |
| 98 | </table> |
| 99 | |
| 100 | </propeller> |
| 101 | ~~~ |
| 102 | |
| 103 | ### Configuration Parameters |
| 104 | |
| 105 | <pre> |
| 106 | \<ixx> - Propeller rotational inertia. |
| 107 | \<diameter> - Propeller disk diameter. |
| 108 | \<numblades> - Number of blades. |
| 109 | \<gearratio> - Ratio of (engine rpm) / (prop rpm). |
| 110 | \<minpitch> - Minimum blade pitch angle. |
| 111 | \<maxpitch> - Maximum blade pitch angle. |
| 112 | \<minrpm> - Minimum rpm target for constant speed propeller. |
| 113 | \<maxrpm> - Maximum rpm target for constant speed propeller. |
| 114 | \<constspeed> - 1 = constant speed mode, 0 = manual pitch mode. |
| 115 | \<reversepitch> - Blade pitch angle for reverse. |
| 116 | \<sense> - Direction of rotation (1=clockwise as viewed from cockpit, |
| 117 | -1=anti-clockwise as viewed from cockpit). Sense is |
| 118 | specified in the parent tag of the propeller. |
| 119 | \<p_factor> - P factor. It is specified in the parent tag of |
| 120 | the propeller. |
| 121 | \<ct_factor> - A multiplier for the coefficients of thrust. |
| 122 | \<cp_factor> - A multiplier for the coefficients of power. |
| 123 | </pre> |
| 124 | |
| 125 | Two tables are needed. One for coefficient of thrust (Ct) and one for |
| 126 | coefficient of power (Cp). |
| 127 | |
| 128 | Two tables are optional. They apply a factor to Ct and Cp based on the |
| 129 | helical tip Mach. |
| 130 | |
| 131 | The parameters <sense> and <p_factor> must be specified at the parent level i.e. |
| 132 | in the <thruster> element. This allows to specify different sense and P factor |
| 133 | values for each propeller of the model while using the same definition file for |
| 134 | all the propellers. |
| 135 | |
| 136 | In addition to thrust, the propeller applies two moments to the aircraft: |
| 137 | - The torque that tends to roll the aircraft in the direction opposite to the |
| 138 | propeller rotation, |
| 139 | - and the gyroscopic moment. |
| 140 | |
| 141 | It should be noted that historically the gyroscopic moment had an incorrect |
| 142 | sign. The correct sign can be obtained by specifying a **version** attribute |
| 143 | higher than 1.0 to the propeller definition |
| 144 | ~~~.xml |
| 145 | <propeller name="a_prop" version="1.1"> |
| 146 | <!-- propeller definition --> |
| 147 | </propeller> |
| 148 | ~~~ |
| 149 | For backward compatibility, the absence of the **version** attribute will result |
| 150 | in the gyroscopic moment to be computed with the legacy incorrect sign. |
| 151 | |
| 152 | Several references were helpful, here: |
| 153 | + Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", |
| 154 | Wiley & Sons, 1979 ISBN 0-471-03032-5 |
| 155 | + Edwin Hartman, David Biermann, "The Aerodynamic Characteristics of |
| 156 | Full Scale Propellers Having 2, 3, and 4 Blades of Clark Y and R.A.F. 6 |
| 157 | Airfoil Sections", NACA Report TN-640, 1938 (?) |
| 158 | + Various NACA Technical Notes and Reports |
| 159 | |
| 160 | @author Jon S. Berndt |
| 161 | @see FGEngine |
| 162 | @see FGThruster |
| 163 | */ |
| 164 | |
| 165 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 166 | CLASS DECLARATION |
| 167 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 168 | |
| 169 | class FGPropeller : public FGThruster { |
| 170 | |
| 171 | public: |
| 172 | /** Constructor for FGPropeller. |
| 173 | @param exec a pointer to the main executive object |
| 174 | @param el a pointer to the thruster config file XML element |
| 175 | @param num the number of this propeller */ |
| 176 | FGPropeller(FGFDMExec* exec, Element* el, int num = 0); |
| 177 | |
| 178 | /// Destructor for FGPropeller - deletes the FGTable objects |
| 179 | ~FGPropeller(); |
| 180 | |
| 181 | /// Reset the initial conditions. |
| 182 | void ResetToIC(void); |
| 183 | |
| 184 | /** Sets the Revolutions Per Minute for the propeller. Normally the propeller |
| 185 | instance will calculate its own rotational velocity, given the Torque |
| 186 | produced by the engine and integrating over time using the standard |
| 187 | equation for rotational acceleration \f$a\f$: \f$a = Q/I\f$ , where |
| 188 | \f$Q\f$ is Torque and \f$I\f$ is moment of inertia for the propeller. |
| 189 | @param rpm the rotational velocity of the propeller */ |
| 190 | void SetRPM(double rpm) {RPM = rpm;} |
| 191 | |
| 192 | /** Sets the Revolutions Per Minute for the propeller using the engine gear |
| 193 | ratio */ |
| 194 | void SetEngineRPM(double rpm) {RPM = rpm/GearRatio;} |
| 195 | |
| 196 | /// Returns true of this propeller is variable pitch |
| 197 | bool IsVPitch(void) const {return MaxPitch != MinPitch;} |
| 198 | |
| 199 | /** This commands the pitch of the blade to change to the value supplied. |
| 200 | This call is meant to be issued either from the cockpit or by the flight |
| 201 | control system (perhaps to maintain constant RPM for a constant-speed |
| 202 | propeller). This value will be limited to be within whatever is specified |
| 203 | in the config file for Max and Min pitch. It is also one of the lookup |
| 204 | indices to the power and thrust tables for variable-pitch propellers. |
| 205 | @param pitch the pitch of the blade in degrees. */ |
| 206 | void SetPitch(double pitch) {Pitch = pitch;} |
| 207 | |
| 208 | /** Set the propeller pitch. |
| 209 | @param advance the pitch command in percent (0.0 - 1.0) |
| 210 | */ |
| 211 | void SetAdvance(double advance) {Advance = advance;} |
| 212 | |
| 213 | /// Sets the P-Factor constant |
| 214 | void SetPFactor(double pf) {P_Factor = pf;} |
| 215 | |
| 216 | /// Sets propeller into constant speed mode, or manual pitch mode |
| 217 | void SetConstantSpeed(int mode) {ConstantSpeed = mode;} |
| 218 | |
| 219 | /// Sets coefficient of thrust multiplier |
| 220 | void SetCtFactor(double ctf) {CtFactor = ctf;} |
| 221 | |
| 222 | /// Sets coefficient of power multiplier |
| 223 | void SetCpFactor(double cpf) {CpFactor = cpf;} |
| 224 | |
| 225 | /** Sets the rotation sense of the propeller. |
| 226 | @param s this value should be +/- 1 ONLY. +1 indicates clockwise rotation as |
| 227 | viewed by someone standing behind the engine looking forward into |
| 228 | the direction of flight. */ |
| 229 | void SetSense(double s) { Sense = s;} |
| 230 | |
| 231 | /// Retrieves the pitch of the propeller in degrees. |
| 232 | double GetPitch(void) const { return Pitch; } |
| 233 | |
| 234 | /// Retrieves the RPMs of the propeller |
| 235 | double GetRPM(void) const { return RPM; } |
| 236 | |
| 237 | /// Calculates the RPMs of the engine based on gear ratio |
| 238 | double GetEngineRPM(void) const { return RPM * GearRatio; } |
| 239 | |
| 240 | /// Retrieves the propeller moment of inertia |
| 241 | double GetIxx(void) const { return Ixx; } |
| 242 | |
| 243 | /// Retrieves the coefficient of thrust multiplier |
| 244 | double GetCtFactor(void) const { return CtFactor; } |
| 245 | |
| 246 | /// Retrieves the coefficient of power multiplier |
| 247 | double GetCpFactor(void) const { return CpFactor; } |
| 248 | |
| 249 | /// Retrieves the propeller diameter |
| 250 | double GetDiameter(void) const { return Diameter; } |
| 251 | |
| 252 | /// Retrieves propeller thrust table |
| 253 | FGTable* GetCThrustTable(void) const { return cThrust;} |
| 254 | /// Retrieves propeller power table |
| 255 | FGTable* GetCPowerTable(void) const { return cPower; } |
| 256 | |
| 257 | /// Retrieves propeller thrust Mach effects factor |
| 258 | FGTable* GetCtMachTable(void) const { return CtMach; } |
| 259 | /// Retrieves propeller power Mach effects factor |
| 260 | FGTable* GetCpMachTable(void) const { return CpMach; } |
| 261 | |
| 262 | /// Retrieves the Torque in foot-pounds (Don't you love the English system?) |
| 263 | double GetTorque(void) const { return vTorque(eX); } |
| 264 | |
| 265 | /** Retrieves the power required (or "absorbed") by the propeller - |
| 266 | i.e. the power required to keep spinning the propeller at the current |
| 267 | velocity, air density, and rotational rate. */ |
| 268 | double GetPowerRequired(void); |
| 269 | |
| 270 | /** Calculates and returns the thrust produced by this propeller. |
| 271 | Given the excess power available from the engine (in foot-pounds), the thrust is |
| 272 | calculated, as well as the current RPM. The RPM is calculated by integrating |
| 273 | the torque provided by the engine over what the propeller "absorbs" |
| 274 | (essentially the "drag" of the propeller). |
| 275 | @param PowerAvailable this is the excess power provided by the engine to |
| 276 | accelerate the prop. It could be negative, dictating that the propeller |
| 277 | would be slowed. |
| 278 | @return the thrust in pounds */ |
| 279 | double Calculate(double EnginePower); |
| 280 | /// Retrieves the P-Factor constant |
| 281 | FGColumnVector3 GetPFactor(void) const; |
| 282 | /// Generate the labels for the thruster standard CSV output |
| 283 | std::string GetThrusterLabels(int id, const std::string& delimeter); |
| 284 | /// Generate the values for the thruster standard CSV output |
| 285 | std::string GetThrusterValues(int id, const std::string& delimeter); |
| 286 | /** Set the propeller reverse pitch. |
| 287 | @param c the reverse pitch command in percent (0.0 - 1.0) |
| 288 | */ |
| 289 | void SetReverseCoef (double c) { Reverse_coef = c; } |
| 290 | /// Retrieves the reverse pitch command. |
| 291 | double GetReverseCoef (void) const { return Reverse_coef; } |
| 292 | /// If true, sets the propeller in reversed position. |
| 293 | void SetReverse (bool r) { Reversed = r; } |
| 294 | /// Returns true if the propeller is in reverse position. |
| 295 | bool GetReverse (void) const { return Reversed; } |
| 296 | /// If true, sets the propeller in feathered position. |
| 297 | void SetFeather (bool f) { Feathered = f; } |
| 298 | /// Returns true if the propeller is in feathered position. |
| 299 | bool GetFeather (void) const { return Feathered; } |
| 300 | /// Retrieves the thrust coefficient |
| 301 | double GetThrustCoefficient(void) const {return ThrustCoeff;} |
| 302 | /// Retrieves the Mach number at the propeller tips. |
| 303 | double GetHelicalTipMach(void) const {return HelicalTipMach;} |
| 304 | /// Returns a non-zero value if the propeller is constant speed. |
| 305 | int GetConstantSpeed(void) const {return ConstantSpeed;} |
| 306 | /// Set the propeller induced velocity |
| 307 | void SetInducedVelocity(double Vi) {Vinduced = Vi;} |
| 308 | /// Get the propeller induced velocity. |
| 309 | double GetInducedVelocity(void) const {return Vinduced;} |
| 310 | |
| 311 | private: |
| 312 | int numBlades; |
| 313 | double J; |
| 314 | double RPM; |
| 315 | double Ixx; |
| 316 | double Diameter; |
| 317 | double MaxPitch; |
| 318 | double MinPitch; |
| 319 | double MinRPM; |
| 320 | double MaxRPM; |
| 321 | double Pitch; |
| 322 | double P_Factor; |
| 323 | double Sense, Sense_multiplier; |
| 324 | double Advance; |
| 325 | double ExcessTorque; |
| 326 | double D4; |
| 327 | double D5; |
| 328 | double HelicalTipMach; |
| 329 | double Vinduced; |
| 330 | FGColumnVector3 vTorque; |
| 331 | FGTable *cThrust; |
| 332 | FGTable *cPower; |
| 333 | FGTable *CtMach; |
| 334 | FGTable *CpMach; |
| 335 | double CtFactor; |
| 336 | double CpFactor; |
| 337 | int ConstantSpeed; |
| 338 | void Debug(int from); |
| 339 | double ReversePitch; // Pitch, when fully reversed |
| 340 | bool Reversed; // true, when propeller is reversed |
| 341 | double Reverse_coef; // 0 - 1 defines AdvancePitch (0=MIN_PITCH 1=REVERSE_PITCH) |
| 342 | bool Feathered; // true, if feather command |
| 343 | }; |
| 344 | } |
| 345 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 346 | #endif |
| 347 |