Created
January 22, 2018 20:39
-
-
Save dpasca/cfbd5782339671646722b70b893d8d86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================================================== | |
/// FM_LiftDrag.cpp | |
/// | |
/// Created by Davide Pasca - 2017/6/12 | |
/// See the file "license.txt" that comes with this project for | |
/// copyright info. | |
//================================================================== | |
#include "stdafx.h" | |
#include "FM_Utils.h" | |
#include "FM_LiftDrag.h" | |
//#define USE_HFFM_FALCOM_REFERENCE | |
#define TEMP_NICE_F16_CL_AOA0 | |
//================================================================== | |
namespace FM | |
{ | |
static constexpr float SSONIC_MACH_REF_VAL = 1.2f; | |
//================================================================== | |
LiftDrag::LiftDrag() | |
{ | |
{ // F-16 | |
auto &m = mModels[TYPE_F16]; | |
// see: http://www.kdu.ac.lk/proceedings/irc2015/2015/eng-012.pdf | |
m.mRefSurfaceArea = 27.87f; | |
#ifdef USE_HFFM_FALCOM_REFERENCE | |
// see: http://www.dept.aoe.vt.edu/~mason/Mason_f/F16S04.pdf | |
// http://www.checksix-fr.com/downloads/falcon4/Topolo/zip/H-F-F-M-manual.pdf (p.15) | |
m.mCL_Subso.AddLinearMapKeyVal( 0 , 0 ); | |
m.mCL_Subso.AddLinearMapKeyVal( 30, 1.8f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 35, 1.9f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 40, 1.8f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 50, 1.2f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 60, 0 ); // stall | |
// Mach 1.4 | |
m.mCL_Super.AddLinearMapKeyVal( 0 , 0 ); | |
m.mCL_Super.AddLinearMapKeyVal( 16, 0.8f ); | |
m.mCL_Super.AddLinearMapKeyVal( 50, 0.8f ); | |
m.mCL_Super.AddLinearMapKeyVal( 60, 0 ); // negligible ? | |
// drag | |
// see: https://en.wikipedia.org/wiki/Drag_coefficient | |
m.mCD_Subso.AddLinearMapKeyVal( 0 , 0.044f ); // F-4 (ssonic) | |
m.mCD_Subso.AddLinearMapKeyVal( 90, 1.05f ); // cube (ssonic) | |
#else | |
// see: http://www.kdu.ac.lk/proceedings/irc2015/2015/eng-012.pdf | |
// Mach 0.6 | |
#ifdef TEMP_NICE_F16_CL_AOA0 | |
m.mCL_Subso.AddLinearMapKeyVal( 0 , -0.05f ); | |
#else | |
m.mCL_Subso.AddLinearMapKeyVal( 0 , -0.2f ); | |
#endif | |
m.mCL_Subso.AddLinearMapKeyVal( 10, 0.55f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 20, 1.15f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 30, 1.55f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 40, 1.60f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 60, 0 ); // stall | |
// Mach 1.2 | |
#ifdef TEMP_NICE_F16_CL_AOA0 | |
m.mCL_Super.AddLinearMapKeyVal( 0 , -0.05f ); | |
#else | |
m.mCL_Super.AddLinearMapKeyVal( 0 , -0.25f ); | |
#endif | |
m.mCL_Super.AddLinearMapKeyVal( 10, 0.30f ); | |
m.mCL_Super.AddLinearMapKeyVal( 20, 0.80f ); | |
m.mCL_Super.AddLinearMapKeyVal( 30, 1.10f ); | |
m.mCL_Super.AddLinearMapKeyVal( 40, 1.25f ); | |
m.mCL_Super.AddLinearMapKeyVal( 60, 0 ); // negligible ? | |
m.mCD_Subso.AddLinearMapKeyVal( 0 , 0.040f ); | |
m.mCD_Subso.AddLinearMapKeyVal( 10, 0.050f ); | |
m.mCD_Subso.AddLinearMapKeyVal( 20, 0.300f ); | |
m.mCD_Subso.AddLinearMapKeyVal( 30, 0.600f ); | |
m.mCD_Subso.AddLinearMapKeyVal( 40, 1.050f ); | |
m.mCD_Subso.AddLinearMapKeyVal( 50, 2.000f ); // closing value | |
m.mCD_Super.AddLinearMapKeyVal( 0 , 0.100f ); | |
m.mCD_Super.AddLinearMapKeyVal( 10, 0.150f ); | |
m.mCD_Super.AddLinearMapKeyVal( 20, 0.450f ); | |
m.mCD_Super.AddLinearMapKeyVal( 30, 0.900f ); | |
m.mCD_Super.AddLinearMapKeyVal( 40, 1.400f ); | |
m.mCD_Super.AddLinearMapKeyVal( 50, 2.000f ); // closing value | |
#endif | |
// assume we get 70% of lift when inverted | |
m.mLiftCoeForNegAlpha = -0.7f; | |
} | |
#if 0 | |
// see: http://www.globalsecurity.org/military/systems/aircraft/f-15-specs.htm | |
m.mRefSurfaceArea = 56.0f; | |
#endif | |
{ // small missile | |
auto &m = mModels[TYPE_SMALL_MISSILE]; | |
// NOTE: using the wetted area | |
// see: http://www.f-16.net/forum/viewtopic.php?f=38&t=28234&start=60 | |
// http://www.f-16.net/forum/viewtopic.php?f=38&t=28234&sid=b61f53615527f000a59471c719c60141&start=60 | |
m.mRefSurfaceArea = 2.5f; | |
// NOTE: kind of based on below | |
m.mCL_Subso.AddLinearMapKeyVal( 0 , 0.0f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 30, 0.1f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 40, 0.1f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 60, 0.5f ); | |
m.mCL_Subso.AddLinearMapKeyVal( 90, 0.0f ); // stall | |
// Mach 1.4 | |
m.mCL_Super.AddLinearMapKeyVal( 0 , 0.0f ); | |
m.mCL_Super.AddLinearMapKeyVal( 30, 0.1f ); | |
m.mCL_Super.AddLinearMapKeyVal( 60, 0.5f ); | |
m.mCL_Super.AddLinearMapKeyVal( 90, 0.0f ); // ngligible ? | |
// assume flighting inverted has no reduced effect on lift | |
m.mLiftCoeForNegAlpha = -1.0f; | |
// drag | |
// see: http://www.zaretto.com/sites/zaretto.com/files/missile-aerodynamic-data/AIM120C5-Performance-Assessment-rev2.pdf | |
m.mCD_Subso.AddLinearMapKeyVal( 0 , 0.004f ); | |
m.mCD_Subso.AddLinearMapKeyVal( 30, 0.030f ); | |
m.mCD_Subso.AddLinearMapKeyVal( 90, 0.300f ); | |
} | |
} | |
//================================================================== | |
static float sampleLDLinearMap( | |
const LinearMap &subsoMap, | |
const LinearMap &superMap, | |
const float negAlphaCoe, | |
float alpha, | |
float mach ) | |
{ | |
const auto &useMap = (mach >= SSONIC_MACH_REF_VAL && !superMap.empty()) | |
? superMap | |
: subsoMap; | |
const auto coe = alpha >= 0 ? 1.f : negAlphaCoe; | |
return coe * useMap.SampleLinearMap( fabs( alpha ) ); | |
} | |
//================================================================== | |
float LiftDrag::ModelEntry::CalcCL( float alpha, float mach ) const | |
{ | |
return sampleLDLinearMap( mCL_Subso, mCL_Super, mLiftCoeForNegAlpha, alpha, mach ); | |
} | |
//================================================================== | |
float LiftDrag::ModelEntry::CalcCD( float alpha, float mach ) const | |
{ | |
return sampleLDLinearMap( mCD_Subso, mCD_Super, mDragCoeForNegAlpha, alpha, mach ); | |
} | |
//================================================================== | |
float LiftDrag::ModelEntry::CalcLDFactor( float speed, float altitudeM ) const | |
{ | |
const auto rho = FMUT::CalcAirDesnity( altitudeM ); | |
return 0.5f * rho * (speed * speed) * mRefSurfaceArea; | |
} | |
//================================================================== | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================================================== | |
/// FM_LiftDrag.h | |
/// | |
/// Created by Davide Pasca - 2017/6/7 | |
/// See the file "license.txt" that comes with this project for | |
/// copyright info. | |
//================================================================== | |
#ifndef FM_LIFTDRAG_H | |
#define FM_LIFTDRAG_H | |
#include "LinearMap.h" | |
//================================================================== | |
namespace FM | |
{ | |
//================================================================== | |
class LiftDrag | |
{ | |
public: | |
enum Type | |
{ | |
TYPE_F16, | |
TYPE_SMALL_MISSILE, | |
TYPE_N, | |
}; | |
class ModelEntry | |
{ | |
friend class LiftDrag; | |
private: | |
LinearMap mCL_Subso; | |
LinearMap mCL_Super; | |
LinearMap mCD_Subso; | |
LinearMap mCD_Super; | |
// coefficient for negative lift | |
// ...only an approximation. Ideally we'd get actual data | |
// like for positive alpha.. | |
float mLiftCoeForNegAlpha = -1; | |
float mDragCoeForNegAlpha = 1; | |
float mRefSurfaceArea = 1; | |
public: | |
float CalcCL( float alpha, float mach ) const; | |
float CalcCD( float alpha, float mach ) const; | |
float CalcLDFactor( float speed, float altitudeM ) const; | |
}; | |
private: | |
ModelEntry mModels[TYPE_N]; | |
public: | |
LiftDrag(); | |
const ModelEntry &GetLiftDragModel( Type type ) const | |
{ | |
return mModels[ type ]; | |
} | |
}; | |
//================================================================== | |
} | |
#endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment