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

This commit is contained in:
2024-11-03 23:27:38 +01:00
parent a91493a744
commit 6967836c8a
33 changed files with 7473 additions and 851 deletions
+2 -104
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 ;
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.