Adjusted MMO to reflect 320 sub 60% and 365 post 90%

This commit is contained in:
Kilian Hofmann 2024-11-03 23:27:38 +01:00
parent a91493a744
commit 6967836c8a
33 changed files with 7473 additions and 851 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

16
V4/ci2mach_250_60.data Normal file

File diff suppressed because one or more lines are too long

16
V4/ci2mach_250_90.data Normal file

File diff suppressed because one or more lines are too long

16
V4/ci2mach_270_60.data Normal file

File diff suppressed because one or more lines are too long

16
V4/ci2mach_270_90.data Normal file

File diff suppressed because one or more lines are too long

16
V4/ci2mach_290_60.data Normal file

File diff suppressed because one or more lines are too long

16
V4/ci2mach_290_90.data Normal file

File diff suppressed because one or more lines are too long

16
V4/ci2mach_310_60.data Normal file

File diff suppressed because one or more lines are too long

16
V4/ci2mach_310_90.data Normal file

File diff suppressed because one or more lines are too long

15
V4/ci2mach_330_60.data Normal file

File diff suppressed because one or more lines are too long

15
V4/ci2mach_330_90.data Normal file

File diff suppressed because one or more lines are too long

13
V4/ci2mach_350_60.data Normal file

File diff suppressed because one or more lines are too long

13
V4/ci2mach_350_90.data Normal file

File diff suppressed because one or more lines are too long

11
V4/ci2mach_370_60.data Normal file

File diff suppressed because one or more lines are too long

11
V4/ci2mach_370_90.data Normal file

File diff suppressed because one or more lines are too long

8
V4/ci2mach_390_60.data Normal file

File diff suppressed because one or more lines are too long

8
V4/ci2mach_390_90.data Normal file

File diff suppressed because one or more lines are too long

7
V4/ci2mach_410_60.data Normal file

File diff suppressed because one or more lines are too long

7
V4/ci2mach_410_90.data Normal file

File diff suppressed because one or more lines are too long

5
V4/ci2mach_430_60.data Normal file

File diff suppressed because one or more lines are too long

5
V4/ci2mach_430_90.data Normal file

File diff suppressed because one or more lines are too long

10
V4/curve_params_60.data Normal file
View File

@ -0,0 +1,10 @@
0.004549867339759197,8.327579505570739e-05,0.534;0.005215714081842818,4.619332039987734e-05,0.55;0.005728100955320029,9.962097117206772e-06,0.57;0.006266107172471102,-2.8080687329597438e-05,0.591;0.006676144767971221,-6.2074723761554e-05,0.612;0.006983833085494273,-9.38315733427973e-05,0.634;0.0069844735690861234,-0.00011887686237190085,0.659;0.006371146481533925,-0.0001355080881025448,0.695;0.005015114620876508,-0.00010962215568495758,0.732;0.0037869232851516508,-8.277591347639665e-05,0.762;0.002968129061335069,-6.487841867068892e-05,0.783;0.002354033393472633,-5.145529756640832e-05,0.798;0.0023540333934726344,-5.145529756640843e-05,0.801;0.002149334837518493,-4.6980923864981554e-05,0.806;0.0019446362815643539,-4.250655016355493e-05,0.81;0.001842287003587277,-4.026936331284127e-05,0.812
0.004703199111647245,8.74336014883685e-05,0.555;0.005266824672472185,4.7579255877430667e-05,0.577;0.005932799511274173,5.4877234157798665e-06,0.598;0.006189377238167863,-2.7655061643016665e-05,0.623;0.006548304243038646,-6.30350335525274e-05,0.647;0.0060629457771373815,-8.37150072980184e-05,0.683;0.0050914602650246115,-9.502060795407545e-05,0.725;0.00399162184110578,-8.725028717782299e-05,0.759;0.0030704783393121463,-6.71156055214025e-05,0.782;0.002354033393472633,-5.145529756640832e-05,0.798;0.0023540333934726296,-5.1455297566408255e-05,0.802;0.002149334837518485,-4.698092386498132e-05,0.807;0.0020469855595414248,-4.474373701426829e-05,0.81;0.0020469855595414248,-4.474373701426829e-05,0.81;0.002149334837518498,-4.698092386498181e-05,0.81;0.0018422870035872895,-4.0269363312841546e-05,0.814
0.00475430970227662,8.881953696592132e-05,0.583;0.005471523228426311,4.310488217600412e-05,0.606;0.005881688920644809,4.101787938226613e-06,0.632;0.005626648354371534,-2.286412067282427e-05,0.667;0.0047064015296064896,-3.7792843657148536e-05,0.711;0.0036580579864721225,-4.366376082080463e-05,0.75;0.002891014836876751,-4.94256195666472e-05,0.78;0.0026354618837299924,-5.6355296954415266e-05,0.795;0.0023540333934726296,-5.1455297566408255e-05,0.802;0.0025587319494267784,-5.592967126783524e-05,0.803;0.0021493348375184918,-4.698092386498151e-05,0.809;0.0021493348375184918,-4.698092386498151e-05,0.809;0.0024563826714497036,-5.3692484417121725e-05,0.807;0.0021493348375184857,-4.698092386498136e-05,0.811;0.0022516841154955575,-4.921811071569483e-05,0.811;0.001842287003587293,-4.026936331284175e-05,0.816
0.0049591363549491025,7.933610545867478e-05,0.614;0.0050367629662809036,4.384707513135007e-05,0.647;0.004372453384817716,2.082085611733203e-05,0.691;0.0032475080040985185,1.0366506834434887e-05,0.737;0.0021991644609641566,4.495589670778574e-06,0.776;0.001662183017560043,2.465911671017306e-06,0.795;0.0017135498016261326,-6.1662684630704784e-06,0.802;0.001381010720739421,-2.6522045526171594e-06,0.809;0.0014322494080871403,-6.275326880884155e-06,0.811;0.0014322494080871403,-6.275326880884155e-06,0.811;0.0013555194737839393,-5.8497011943044965e-06,0.813;0.0017138059950628673,-1.6184384074711623e-05,0.812;0.001227678948851375,-6.810010985278175e-06,0.818;0.0018673939603876745,-2.2044693253692463e-05,0.813;0.0010485997365711004,-4.147198447985061e-06,0.821;0.0011765683582220243,-8.195946462831802e-06,0.821
0.004985908569088292,3.2443024042155e-05,0.66;0.0040146792504122675,1.111930777445644e-05,0.712;0.0027617652480421352,4.713706506406176e-06,0.758;0.002071452032749907,-1.473777926013604e-06,0.786;0.00199497829188348,-1.1066267851076905e-05,0.798;0.0017904078326477105,-1.1600951955470904e-05,0.805;0.0017392972420183614,-1.2986887433024585e-05,0.808;0.0018416465199954336,-1.522407428373805e-05,0.807;0.0023022823192514284,-2.779594401485836e-05,0.805;0.0019185045510170145,-2.065875777613859e-05,0.81;0.0024558702845762217,-3.3656253193838845e-05,0.806;0.0023791403502730125,-3.3230627507259105e-05,0.808;0.0020720925163418003,-2.6519066955118856e-05,0.811;0.0026094582499010207,-3.9516562372819624e-05,0.807;0.0018162833697583163,-2.343062873124592e-05,0.816
0.0036823963629622875,4.615256073268567e-06,0.729;0.0023271330826151702,4.4684165592864607e-07,0.776;0.001943739604535754,-7.443145522809667e-06,0.796;0.002071836322905062,-1.650095134347754e-05,0.801;0.0020463450759495715,-1.969844798516467e-05,0.805;0.001943995797972505,-1.7461261134451486e-05,0.806;0.0026093301531826536,-3.4507504566999015e-05,0.802;0.0022255523849482243,-2.7370318328278688e-05,0.807;0.0028652673964845122,-4.260500059669266e-05,0.802;0.002686188184204224,-3.9942188059399235e-05,0.805;0.002200061137992735,-3.056781496996593e-05,0.811;0.003453871817391448,-5.922561834266033e-05,0.8;0.003453871817391448,-5.922561834266033e-05,0.8
0.0020458326890764543,3.3778323810759986e-07,0.785;0.00199497829188348,-1.1066267851076905e-05,0.798;0.0016113286203674232,-8.93813941817747e-06,0.808;0.001943995797972505,-1.7461261134451486e-05,0.806;0.0016625673077151413,-1.2561261746444449e-05,0.81;0.0020208538289940747,-2.289594462685167e-05,0.809;0.0017394253387367315,-1.7995945238845176e-05,0.813;0.0011509490145481614,-6.384385298698173e-06,0.82;0.00230241041596981,-3.28050018206795e-05,0.81;0.0019186326477353963,-2.5667815581959532e-05,0.815;0.00232802975964366,-3.4616562984812674e-05,0.811
0.0017647884889738445,-9.789390791337222e-06,0.804;0.001636947964041291,-1.0749700582311178e-05,0.809;0.0022766629755775767,-2.5984382850725166e-05,0.804;0.0017905359293660808,-1.6610009761291607e-05,0.81;0.002353521006599155,-3.141906634312564e-05,0.807;0.002276791072295947,-3.099344065654586e-05,0.809;0.0014836161921532459,-1.490750701497223e-05,0.818;0.003044474705483169,-5.027687093980688e-05,0.804
0.002455742187857865,-2.8647195388018643e-05,0.801;0.002097583763297289,-2.3321570313431652e-05,0.807;0.0025326002188794383,-3.4081878880419e-05,0.804;0.0021744417943188703,-2.8756253805832305e-05,0.81;0.0033259031957405152,-5.517687032781334e-05,0.8;0.002942125427506095,-4.8039684089093314e-05,0.805;0.003581840439042383,-6.327436635750739e-05,0.8
0.002404631597228508,-3.003313086557211e-05,0.804;0.0032746645083928053,-5.155374799954661e-05,0.798;0.0029932360181354435,-4.665374861153963e-05,0.802;0.004375015319185086,-7.93602999990808e-05,0.791;0.004682063153116312,-8.60718605512215e-05,0.788

10
V4/curve_params_90.data Normal file
View File

@ -0,0 +1,10 @@
0.0020391716597208966,0.0002608087891407925,0.534;0.0027050184018045276,0.00022372631448496213,0.55;0.0032174052752817366,0.00018749509120229168,0.57;0.0037554114924328,0.00014945230675548772,0.591;0.004165449087932918,0.00011545827032353112,0.612;0.004473137405455987,8.370142074228733e-05,0.634;0.004473777889047835,5.865613171318383e-05,0.659;0.003860450801495621,4.202490598254047e-05,0.695;0.003016805814315409,3.167961511745713e-05,0.732;0.002249762664720042,2.5917756371614527e-05,0.762;0.001764019908663645,2.0264956043586326e-05,0.783;0.001380498333865939,1.7384026670665756e-05,0.798;0.001457356364887524,1.1949343178265048e-05,0.801;0.001329515839954967,1.098903338729108e-05,0.806;0.0011760559713485449,1.1840284760450908e-05,0.81;0.0010993260370453248,1.226591044703107e-05,0.812
0.0026792709614122854,0.00023054693345491675,0.555;0.003242896522237225,0.0001906925878439788,0.577;0.003908871361039228,0.0001486010553823278,0.598;0.004165449087932919,0.00011545827032353114,0.623;0.0045243760928037075,8.00782984140202e-05,0.647;0.0040390176269024134,5.93983246685302e-05,0.683;0.0030675321147896496,4.8092724012472825e-05,0.725;0.002147029096587851,4.3182116639790356e-05,0.759;0.0015845564062282528,3.7954941998341685e-05,0.782;0.001098685553453477,3.7311199476134425e-05,0.798;0.0012011629281489225,3.0064954819600188e-05,0.802;0.0010733224032163562,2.9104645028626548e-05,0.807;0.001022211812587013,2.771870955107274e-05,0.81;0.001022211812587013,2.771870955107274e-05,0.81;0.001150180434237935,2.366996153622612e-05,0.81;0.000868751943980594,2.856996092423256e-05,0.814
0.0035245812059313225,0.0001757744728443307,0.583;0.004241794732081024,0.00013005981805441313,0.606;0.00465196042429952,9.105672381663569e-05,0.632;0.004396919858026252,6.409081520558452e-05,0.667;0.0034766730332612037,4.916209222126033e-05,0.711;0.0024283294901268457,4.329117505760398e-05,0.75;0.0016612863405314723,3.752931631176157e-05,0.78;0.0014057333873846894,3.059963892399432e-05,0.795;0.0012011629281489225,3.0064954819600188e-05,0.802;0.0014827195151246443,2.015589762577284e-05,0.803;0.0011245610905640804,2.5481522700359486e-05,0.809;0.0011245610905640804,2.5481522700359486e-05,0.809;0.0014572282681691617,1.695840098408545e-05,0.807;0.0011757997779117972,2.185840037209249e-05,0.811;0.001303768399562737,1.7809652357245306e-05,0.811;0.0009199906313283172,2.4946838595965375e-05,0.816
0.004446749481471902,0.00011556732874134511,0.614;0.0045243760928037075,8.00782984140202e-05,0.647;0.0038600665113405156,5.705207940000247e-05,0.691;0.00273512113062132,4.65977301171051e-05,0.737;0.0016867775874869638,4.07268129534487e-05,0.776;0.001149796144082838,3.869713495368779e-05,0.795;0.0012011629281489225,3.0064954819600188e-05,0.802;0.0008686238472622149,3.3579018730053436e-05,0.809;0.000919862534609942,2.995589640178614e-05,0.811;0.000919862534609942,2.995589640178614e-05,0.811;0.0008431326003067354,3.038152208836594e-05,0.813;0.0012014191215856582,2.004683920795892e-05,0.812;0.0007152920753741745,2.9421212297392212e-05,0.818;0.0013550070869104626,1.4186530028978241e-05,0.813;0.000536212863093898,3.2084024834685286e-05,0.821;0.0006641814847448274,2.8035276819838494e-05,0.821
0.00447352169561109,6.867424732482539e-05,0.66;0.0035022923769350636,4.7350531057126834e-05,0.712;0.002249378374564928,4.094492978907674e-05,0.758;0.001559065159272748,3.475744535665496e-05,0.786;0.0014825914184062716,2.5164955431593618e-05,0.798;0.0012780209591704967,2.4630271327199904e-05,0.805;0.0012269103685411597,2.3244335849645755e-05,0.808;0.0013292596465182276,2.100714899893245e-05,0.807;0.0017898954457742323,8.435279267811819e-06,0.805;0.001406117677539805,1.557246550653198e-05,0.81;0.0019434834110990202,2.574970088831512e-06,0.806;0.0018667534767958039,3.0005957754114947e-06,0.808;0.0015597056428645923,9.71215632755174e-06,0.811;0.0020970713764238216,-3.2853390901493156e-06,0.807;0.0013038964962811162,1.2800594551424482e-05,0.816
0.0031700094894850906,4.084647935593877e-05,0.729;0.0018147462091378933,3.6678064938601775e-05,0.776;0.0014313527310585545,2.878807775986061e-05,0.796;0.0015594494494278527,1.9730271939193067e-05,0.801;0.001533958202472361,1.6532775297505944e-05,0.805;0.0014316089244952926,1.8769962148219233e-05,0.806;0.00209694327970543,1.7237187156720706e-06,0.802;0.001713165511471017,8.860904954391862e-06,0.807;0.0023528805230073045,-6.373777314022186e-06,0.802;0.002173801310727022,-3.71096477672888e-06,0.805;0.001687674264515526,5.663408312704698e-06,0.811;0.0029414849439142517,-2.299439505999014e-05,0.8;0.0029414849439142517,-2.299439505999014e-05,0.8
0.0015334458155988875,3.656900652078852e-05,0.785;0.0014825914184062716,2.5164955431593618e-05,0.798;0.0010989417468902291,2.729308386449263e-05,0.808;0.0014316089244952926,1.8769962148219233e-05,0.806;0.001150180434237935,2.366996153622612e-05,0.81;0.0015084669555168744,1.3335278655818599e-05,0.809;0.001227038465259537,1.8235278043824927e-05,0.813;0.0006385621410709679,2.984683798397191e-05,0.82;0.0017900235424926053,3.426221461991047e-06,0.81;0.0014062457742581855,1.0563407700711094e-05,0.815;0.0018156428861664565,1.6146602978577143e-06,0.811
0.0012524016154966393,2.6441832491333264e-05,0.804;0.0011245610905640804,2.5481522700359486e-05,0.809;0.0017642761021003641,1.024684043194558e-05,0.804;0.001278149055888873,1.962121352137899e-05,0.81;0.0018411341331219576,4.812156939544642e-06,0.807;0.0017644041988187367,5.237782626124829e-06,0.809;0.0009712293186760369,2.132371626769834e-05,0.818;0.0025320878320059647,-1.4045647657136312e-05,0.804
0.0019433553143806488,7.584027894652228e-06,0.801;0.0015851968898200825,1.290965296923889e-05,0.807;0.0020202133454022306,2.149344402251688e-06,0.804;0.0016620549208416723,7.474969476838016e-06,0.81;0.002813516322263316,-1.8945647045143033e-05,0.8;0.0024297385540288895,-1.1808460806422797e-05,0.805;0.0030694535655651817,-2.7043143074836956e-05,0.8
0.0018922447237512997,6.198092417098515e-06,0.804;0.0027622776349155898,-1.5322524716875825e-05,0.798;0.002480849144658245,-1.0422525328869318e-05,0.802;0.0038626284457078846,-4.312907671641051e-05,0.791;0.0041696762796391085,-4.9840637268551016e-05,0.788

View File

@ -17,119 +17,17 @@ int main() {
std::cout << "Weight (kg, no t)?: ";
std::cin >> weight;
std::cout << "Tip tank quantity (percent): ";
std::cout << "Total fuel (kg, not t)?: ";
std::cin >> tipTankPercent;
std::cout << "CI (0 to 999)?: ";
std::cin >> ci;
std::cout << std::endl << std::endl << "BEGIN Step-By-Step" << std::endl << std::endl;
// Bound data
auto [lowerFl, upperFl, ratioFl] = boundAltitude(altitude);
std::cout << "Lower Altitude Bound: " << lowerFl << std::endl;
std::cout << "Upper Altitude Bound: " << upperFl << std::endl;
std::cout << "Ratio: " << ratioFl << std::endl << std::endl;
auto [lowerWgt, upperWgt, ratioWgt] = boundWeight(weight);
std::cout << "Lower Weight Bound: " << lowerWgt << std::endl;
std::cout << "Upper Weight Bound: " << upperWgt << std::endl;
std::cout << "Ratio: " << ratioWgt << std::endl << std::endl;
float ratioMMO = boundMMO(tipTankPercent);
// Check validity
if (altitude < MIN_FL * 100) {
std::cerr << "Too low, min Altitude: " << MIN_FL * 100 << std::endl;
exit(1);
}
if (altitude > MAX_FL * 100) {
std::cerr << "Too high, max Altitude: " << MAX_FL * 100 << std::endl;
exit(1);
}
if (weight < MIN_WGT * 1000) {
std::cerr << "Too light, min weight: " << MIN_WGT * 1000 << std::endl;
exit(1);
}
if (weight > MAX_WGT * 1000) {
std::cerr << "Too heavy, max weight: " << MAX_WGT * 1000 << std::endl;
exit(1);
}
if (tipTankPercent < 0 || tipTankPercent > 100) {
std::cerr << "Invalid quantity" << std::endl;
exit(1);
}
if (ci < 0) {
std::cerr << "CI must be greater or equal to 0" << std::endl;
exit(1);
}
if (ci > 999) {
std::cerr << "CI must be lesser or equal to 999" << std::endl;
exit(1);
}
// Grab table, convert altitude and weight to index
int lowerFlIndex = flightLevel2Index(lowerFl);
int upperFlIndex = flightLevel2Index(upperFl);
int lowerWgtIndex = weight2Index(lowerWgt);
int upperWgtIndex = weight2Index(upperWgt);
// Get boundary values
const float* lowerFlLowerWgtCis85 = ci2Mach_85[lowerFlIndex][lowerWgtIndex];
const float* lowerFlUpperWgtCis85 = ci2Mach_85[lowerFlIndex][upperWgtIndex];
const float* upperFlLowerWgtCis85 = ci2Mach_85[upperFlIndex][lowerWgtIndex];
const float* upperFlUpperWgtCis85 = ci2Mach_85[upperFlIndex][upperWgtIndex];
const float* lowerFlLowerWgtCis87 = ci2Mach_87[lowerFlIndex][lowerWgtIndex];
const float* lowerFlUpperWgtCis87 = ci2Mach_87[lowerFlIndex][upperWgtIndex];
const float* upperFlLowerWgtCis87 = ci2Mach_87[upperFlIndex][lowerWgtIndex];
const float* upperFlUpperWgtCis87 = ci2Mach_87[upperFlIndex][upperWgtIndex];
// Check if we can even fly here (higher FL and weights are NULL due to perf limits)
if (lowerFlLowerWgtCis85 == NULL || lowerFlUpperWgtCis85 == NULL || upperFlLowerWgtCis85 == NULL || upperFlUpperWgtCis85 == NULL ||
lowerFlLowerWgtCis87 == NULL || lowerFlUpperWgtCis87 == NULL || upperFlLowerWgtCis87 == NULL || upperFlUpperWgtCis87 == NULL) {
std::cerr << "Outside operational regime. Check weight/altitude" << std::endl;
exit(1);
}
// Get machs
float lowerFlLowerWgtMach85 = lowerFlLowerWgtCis85[ci];
float lowerFlUpperWgtMach85 = lowerFlUpperWgtCis85[ci];
float upperFlLowerWgtMach85 = upperFlLowerWgtCis85[ci];
float upperFlUpperWgtMach85 = upperFlUpperWgtCis85[ci];
float lowerFlLowerWgtMach87 = lowerFlLowerWgtCis87[ci];
float lowerFlUpperWgtMach87 = lowerFlUpperWgtCis87[ci];
float upperFlLowerWgtMach87 = upperFlLowerWgtCis87[ci];
float upperFlUpperWgtMach87 = upperFlUpperWgtCis87[ci];
// Lin interp
float ratioedLowerFlMach85 = interp(lowerFlLowerWgtMach85, lowerFlUpperWgtMach85, ratioWgt);
float ratioedUpperFlMach85 = interp(upperFlLowerWgtMach85, upperFlUpperWgtMach85, ratioWgt);
float ratioedMach85 = interp(ratioedLowerFlMach85, ratioedUpperFlMach85, ratioFl);
float ratioedLowerFlMach87 = interp(lowerFlLowerWgtMach87, lowerFlUpperWgtMach87, ratioWgt);
float ratioedUpperFlMach87 = interp(upperFlLowerWgtMach87, upperFlUpperWgtMach87, ratioWgt);
float ratioedMach87 = interp(ratioedLowerFlMach87, ratioedUpperFlMach87, ratioFl);
float ratioedMach = roundTo(interp(ratioedMach85, ratioedMach87, ratioMMO), 3);
std::cout << "Mach for CI " << ci << ": " << ratioedMach << std::endl << std::endl;
std::cout << "END Step-By-Step" << std::endl << std::endl << std::endl;
std::cout << "BEGIN All-In-One" << std::endl << std::endl;
auto start = std::chrono::high_resolution_clock::now();
float aioMach = ci2mach(altitude, weight, tipTankPercent, ci);
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
std::cout << "Mach for CI " << ci << ": " << aioMach << std::endl << std::endl;
std::cout << "END All-In-One, " << duration.count() << "ns" << std::endl ;
std::cout << "Took " << duration.count() << "ns" << std::endl ;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -60,10 +60,15 @@ std::tuple<int, int, float> boundWeight(int weight) {
return {(int)lower, (int)upper, ratio};
}
float boundMMO(int tipTankPercent) {
return tipTankPercent <= MIN_TIP ? 0 :
tipTankPercent >= MAX_TIP ? 1 :
(tipTankPercent - MIN_TIP) / TIP_STP;
/// @brief Bounding function for MMO based on total fuel
/// @param totalFuel Total fuel in kilogrammes
/// @return Ratio between .85 and .87 MMO
float boundMMO(float totalFuel) {
float percent = (int)round(1.57613580e-02 * totalFuel - 1.51221174e+02);
return percent <= MIN_TIP ? 0 :
percent >= MAX_TIP ? 1 :
(percent - MIN_TIP) / TIP_STP;
}
/// @brief Conversion from FL to index of file
@ -92,19 +97,37 @@ float interp(float lower, float upper, float ratio) {
/// @brief Calculate mach for a given CI and aircraft state
/// @param altitude Altitude in feet
/// @param weight Weight in kilogrammes
/// @param tipTankPercent Lowest tip tank quantity (left/right) in percent
/// @param totalFuel Total fuel in kilogrammes
/// @param ci CI
/// @return Mach corresponding to CI. Returns -1 if not possible
float ci2mach(float altitude, float weight, float tipTankPercent, int ci) {
auto [lowerFl, upperFl, ratioFl] = boundAltitude(altitude);
auto [lowerWgt, upperWgt, ratioWgt] = boundWeight(weight);
float ratioMMO = boundMMO(tipTankPercent);
float ci2mach(float altitude, float weight, float totalFuel, int ci) {
auto bAlt = boundAltitude(altitude);
auto lowerFl = std::get<0>(bAlt);
auto upperFl = std::get<1>(bAlt);
auto ratioFl = std::get<2>(bAlt);
auto bWgt = boundWeight(weight);
auto lowerWgt = std::get<0>(bWgt);
auto upperWgt = std::get<1>(bWgt);
auto ratioWgt = std::get<2>(bWgt);
float ratioMMO = boundMMO(totalFuel);
// Outside of data
//FIXME: Find some sort of data to bridge 11k to 25k feet
if (altitude < 25000)
return -1;
int lowerFlIndex = flightLevel2Index(lowerFl);
int upperFlIndex = flightLevel2Index(upperFl);
int lowerWgtIndex = weight2Index(lowerWgt);
int upperWgtIndex = weight2Index(upperWgt);
// Outside of the maximum indicies
if (lowerFlIndex > 10 || upperFlIndex > 10 || lowerWgtIndex > 16 || upperWgtIndex > 16) {
return -1;
}
const float* lowerFlLowerWgtCis85 = ci2Mach_85[lowerFlIndex][lowerWgtIndex];
const float* lowerFlUpperWgtCis85 = ci2Mach_85[lowerFlIndex][upperWgtIndex];
const float* upperFlLowerWgtCis85 = ci2Mach_85[upperFlIndex][lowerWgtIndex];
@ -114,11 +137,6 @@ float ci2mach(float altitude, float weight, float tipTankPercent, int ci) {
const float* upperFlLowerWgtCis87 = ci2Mach_87[upperFlIndex][lowerWgtIndex];
const float* upperFlUpperWgtCis87 = ci2Mach_87[upperFlIndex][upperWgtIndex];
if (lowerFlLowerWgtCis85 == NULL || lowerFlUpperWgtCis85 == NULL || upperFlLowerWgtCis85 == NULL || upperFlUpperWgtCis85 == NULL ||
lowerFlLowerWgtCis87 == NULL || lowerFlUpperWgtCis87 == NULL || upperFlLowerWgtCis87 == NULL || upperFlUpperWgtCis87 == NULL) {
return -1;
}
float lowerFlLowerWgtMach85 = lowerFlLowerWgtCis85[ci];
float lowerFlUpperWgtMach85 = lowerFlUpperWgtCis85[ci];
float upperFlLowerWgtMach85 = upperFlLowerWgtCis85[ci];
@ -128,6 +146,12 @@ float ci2mach(float altitude, float weight, float tipTankPercent, int ci) {
float upperFlLowerWgtMach87 = upperFlLowerWgtCis87[ci];
float upperFlUpperWgtMach87 = upperFlUpperWgtCis87[ci];
// Outside operational limits
if (upperFlUpperWgtMach87 < 0 || upperFlUpperWgtMach85 < 0 || upperFlLowerWgtMach87 < 0 || upperFlLowerWgtMach85 < 0 ||
lowerFlUpperWgtMach87 < 0 || lowerFlUpperWgtMach85 < 0 || lowerFlLowerWgtMach87 < 0 || lowerFlLowerWgtMach85 < 0) {
return -1;
}
float ratioedLowerFlMach85 = interp(lowerFlLowerWgtMach85, lowerFlUpperWgtMach85, ratioWgt);
float ratioedUpperFlMach85 = interp(upperFlLowerWgtMach85, upperFlUpperWgtMach85, ratioWgt);
float ratioedMach85 = interp(ratioedLowerFlMach85, ratioedUpperFlMach85, ratioFl);

File diff suppressed because it is too large Load Diff