diff --git a/initial_sizing/src/initialSizing.cpp b/initial_sizing/src/initialSizing.cpp index 9d72d9fba7c3349285e99fb3debdb269e0b32881..82ea992368d47309569c9dd3802820d9b7fe7491 100644 --- a/initial_sizing/src/initialSizing.cpp +++ b/initial_sizing/src/initialSizing.cpp @@ -35,7 +35,8 @@ namespace fs = std::filesystem; -initialSizing::initialSizing(const int argc, char *argv[], const std::string &toolName, const std::string &toolVersion): Module(argc, argv, toolName, toolVersion) { +initialSizing::initialSizing(const int argc, char *argv[], const std::string &toolName, +const std::string &toolVersion): Module(argc, argv, toolName, toolVersion) { rtIO_ = get_RuntimeIO(); std::string configuration = rtIO_->aircraft_configuration_type(); std::string approach = rtIO_->moduleConfig.at("program_settings/approach_selection/value"); diff --git a/initial_sizing/src/initialSizing.h b/initial_sizing/src/initialSizing.h index ccaccf47f615d08d5c0f17f07277099a03d01a4f..4db284c4671f3b4453bd8196bfd4d4ea623a54c4 100644 --- a/initial_sizing/src/initialSizing.h +++ b/initial_sizing/src/initialSizing.h @@ -31,7 +31,7 @@ /** * \brief systemsDesign module for sizing systems - * + * */ class initialSizing : public Module { public: diff --git a/initial_sizing/src/initialSizingDefines.h b/initial_sizing/src/initialSizingDefines.h index ff535ac678d72b2b253badb3588389282aadf0b8..5a9041aa09d8fec02e12a6c746dbaa083fb9d968 100644 --- a/initial_sizing/src/initialSizingDefines.h +++ b/initial_sizing/src/initialSizingDefines.h @@ -27,8 +27,8 @@ enum strategies{ ANALYTICAL, - DATABASE_INTERPOLATED, - DATABASE_REFERENCE + DATABASE_INTERPOLATED, + DATABASE_REFERENCE }; class ModuleConfig{ @@ -38,4 +38,3 @@ class ModuleConfig{ }; #endif // INITIALSIZING_SRC_INITIALSIZINGDEFINES_H_ - diff --git a/initial_sizing/src/main.cpp b/initial_sizing/src/main.cpp index 6b08342f58c5d6609d2afb1db72b20d343048a6a..e494a8fc3ee869d7137bd3ea404a9aca0b537ddb 100644 --- a/initial_sizing/src/main.cpp +++ b/initial_sizing/src/main.cpp @@ -56,7 +56,7 @@ int main(int argc, const char *argv[]) { } if (!fileExists(argumentLookup["-c"])) { cerr << "ERROR: Setting file " << argumentLookup["-c"] << " not found. Program termination!" << endl; - system("PAUSE"); //Waiting for input (to display error, since not written into log) + system("PAUSE"); // Waiting for input (to display error, since not written into log) exit(1); } node& configXML = aixml::openDocument(argumentLookup["-c"]); @@ -74,7 +74,7 @@ int main(int argc, const char *argv[]) { /* Generating the initialSizing object for the calculations */ initialSizing myInitialSizing(&myAcft, mySettings); myRuntimeInfo->out << "Start calculation ..." << endl; - //myInitialSizing.initialize(); + // myInitialSizing.initialize(); myInitialSizing.run(); myRuntimeInfo->out << "... calculation finished!" << endl; diff --git a/initial_sizing/src/maininitialSizing.cpp b/initial_sizing/src/maininitialSizing.cpp index 95518ebc4e8dd8b35b9bc4d21262de07af457e15..cbd2ff39fb9597099d4bb7e193172479b7c63c2b 100644 --- a/initial_sizing/src/maininitialSizing.cpp +++ b/initial_sizing/src/maininitialSizing.cpp @@ -23,8 +23,6 @@ #include "toolinfo.h" #include "initialSizing.h" - - int main(int argc, char *argv[]) { initialSizing initialSizing(argc, argv, TOOL_NAME, TOOL_VERSION); return initialSizing.execute(); diff --git a/initial_sizing/src/taw/TawInitialSizingConfig.h b/initial_sizing/src/taw/TawInitialSizingConfig.h index ec1f3b9370c3368d1664c2eac1b96e06cb6ac9fc..2f0a6b3d839eb65eeae17459b0c22dcc4e39f044 100644 --- a/initial_sizing/src/taw/TawInitialSizingConfig.h +++ b/initial_sizing/src/taw/TawInitialSizingConfig.h @@ -32,7 +32,7 @@ /* STANDARD SYSTEMS DESIGN CONFIG */ /** * \brief Storage class for non system specific values from configuration xml - * + * */ class TawInitialSizingConfig { public: diff --git a/initial_sizing/src/taw/TawInitialSizingData.h b/initial_sizing/src/taw/TawInitialSizingData.h index d885611a67a903193520ad7d5ef8099bce0bc997..76e566c44dd21bb1c52c7e0945ad0f70bb730d7f 100644 --- a/initial_sizing/src/taw/TawInitialSizingData.h +++ b/initial_sizing/src/taw/TawInitialSizingData.h @@ -41,7 +41,6 @@ class TawInitialSizingData { */ class cabin { public: - int numberPassengers = 0;/**< number of passengers*/ double massPassenger = 0.;/**< mass per passengers*/ double massLuggage = 0.;/**< Luggage mass per passengers*/ @@ -77,7 +76,6 @@ class TawInitialSizingData { double distalt = 0.; double contingency = 0.;/**< percentage of the reserved fuel*/ double Gamma = 0.; - }; missionParameters MissionInfo; @@ -87,10 +85,9 @@ class TawInitialSizingData { class carrierParameters { public: std::string energyCarrier; /**< energy carrier, i.e, kerosene, liquid hydrogen*/ - }; carrierParameters EnergyCarrier; - + /* FUNCTIONS FOR WRITING TO THE ACXML FILE */ /** @@ -124,7 +121,6 @@ class TawInitialSizingData { return new_node; }; - /** * @brief Create a endnode object and set its properties. * @@ -136,7 +132,8 @@ class TawInitialSizingData { * @return Endnode<T> Return the created endnode. */ template<typename T> - auto create_endnode(const T value, const std::string& unit, const std::string& node_path, const std::string& description) -> Endnode<T> { + auto create_endnode(const T value, const std::string& unit, const std::string& node_path, + const std::string& description) -> Endnode<T> { /* Create the node an set its properties */ Endnode<T> new_node{node_path, description}; new_node.set_value(value); @@ -145,7 +142,6 @@ class TawInitialSizingData { return new_node; }; - }; #endif // INITIALSIZING_SRC_TAWINITIALSIZINGDATA_H_ // NOLINT diff --git a/initial_sizing/src/taw/TawInitialSizingIOData.cpp b/initial_sizing/src/taw/TawInitialSizingIOData.cpp index 5c56ce32c7764cca034bce197b102f0c0c0a1725..cf6a46e9e5f652b8c41960ccca40a3f3479dd0ec 100644 --- a/initial_sizing/src/taw/TawInitialSizingIOData.cpp +++ b/initial_sizing/src/taw/TawInitialSizingIOData.cpp @@ -43,9 +43,6 @@ TawInitialSizingIOData::TawInitialSizingIOData(std::shared_ptr<RuntimeIO> rtIO, configuration.readAll(config); } - - - void TawInitialSizingIOData::readAccomodation(const node& acxml) { data.Accommodation.numberPassengers = EndnodeReadOnly<double>("/aircraft_exchange_file/requirements_and_specifications/design_specification/transport_task/passenger_definition/total_number_passengers").read(acxml).value(); data.Accommodation.massPassenger = EndnodeReadOnly<double>("/aircraft_exchange_file/requirements_and_specifications/design_specification/transport_task/passenger_definition/mass_per_passenger").read(acxml).value(); @@ -53,7 +50,6 @@ void TawInitialSizingIOData::readAccomodation(const node& acxml) { data.Accommodation.massCargo = EndnodeReadOnly<double>("/aircraft_exchange_file/requirements_and_specifications/design_specification/transport_task/cargo_definition/additional_cargo_mass").read(acxml).value(); } - void TawInitialSizingIOData::readMissionInfo(const node& acxml) { data.MissionInfo.range = EndnodeReadOnly<double>("/aircraft_exchange_file/requirements_and_specifications/requirements/top_level_aircraft_requirements/design_mission/range").read(acxml).value(); data.MissionInfo.contingency = EndnodeReadOnly<double>("/aircraft_exchange_file/requirements_and_specifications/requirements/top_level_aircraft_requirements/design_mission/contingency").read(acxml).value(); @@ -66,7 +62,6 @@ void TawInitialSizingIOData::readMissionInfo(const node& acxml) { data.MissionInfo.Gamma = EndnodeReadOnly<double>("/aircraft_exchange_file/requirements_and_specifications/requirements/top_level_aircraft_requirements/flight_envelope/climb_or_descend_segment_gradient").read(acxml).value(); } - void TawInitialSizingIOData::readEnergyCarrier(const node& acxml) { data.EnergyCarrier.energyCarrier = EndnodeReadOnly<std::string>("/aircraft_exchange_file/requirements_and_specifications/design_specification/energy_carriers/energy_carrier/type").read(acxml).value(); } @@ -87,7 +82,7 @@ void TawInitialSizingIOData::updateMTOM(double mo_iteration) { // Inertia std::string inertiaPath = basePath + "/inertia"; - + if (!(rtIO_->acxml.find(inertiaPath))) { rtIO_->acxml[inertiaPath]; } @@ -131,7 +126,7 @@ void TawInitialSizingIOData::updateMTOM(double mo_iteration) { // Center of Gravity std::string cogPath = basePath + "/center_of_gravity"; - + if (!(rtIO_->acxml.find(cogPath))) { rtIO_->acxml[cogPath]; } @@ -150,7 +145,6 @@ void TawInitialSizingIOData::updateMTOM(double mo_iteration) { z_cgNode.update(rtIO_->acxml); } - void TawInitialSizingIOData::updateOME(double final_mass_estimation) { std::string basePath = "aircraft_exchange_file/analysis/masses_cg_inertia/operating_mass_empty/mass_properties"; if (!(rtIO_->acxml.find(basePath))) { @@ -163,7 +157,7 @@ void TawInitialSizingIOData::updateOME(double final_mass_estimation) { // Inertia std::string inertiaPath = basePath + "/inertia"; - + if (!(rtIO_->acxml.find(inertiaPath))) { rtIO_->acxml[inertiaPath]; } @@ -207,7 +201,7 @@ void TawInitialSizingIOData::updateOME(double final_mass_estimation) { // Center of Gravity std::string cogPath = basePath + "/center_of_gravity"; - + if (!(rtIO_->acxml.find(cogPath))) { rtIO_->acxml[cogPath]; } @@ -226,7 +220,6 @@ void TawInitialSizingIOData::updateOME(double final_mass_estimation) { z_cgNode.update(rtIO_->acxml); } - void TawInitialSizingIOData::updateWS(double designWS) { std::string subPath = "aircraft_exchange_file/sizing_point"; if (!(rtIO_->acxml.find(subPath))) { @@ -237,7 +230,6 @@ void TawInitialSizingIOData::updateWS(double designWS) { wingLoading.update(rtIO_->acxml); } - void TawInitialSizingIOData::updateTW(double designTW) { std::string subPath = "aircraft_exchange_file/sizing_point"; if (!(rtIO_->acxml.find(subPath))) { @@ -279,6 +271,3 @@ void TawInitialSizingIOData::setGlobalReferencePoint() { zNode.set_boundaries(-std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()); zNode.update(rtIO_->acxml); } - - - diff --git a/initial_sizing/src/taw/TawInitialSizingIOData.h b/initial_sizing/src/taw/TawInitialSizingIOData.h index bdb1aa251f1b0ea4be2117a881f4a67d335b336e..5c77f1a235750df76c76183acdeaecd7e2191eaf 100644 --- a/initial_sizing/src/taw/TawInitialSizingIOData.h +++ b/initial_sizing/src/taw/TawInitialSizingIOData.h @@ -38,10 +38,10 @@ * \brief TawInitialSizingIOData class */ class TawInitialSizingIOData { -protected: + protected: std::shared_ptr<RuntimeIO> rtIO_; -public: + public: std::string aircraftType; /** Aircraft type (e.g. CeRAS) */ std::string aircraftModel; /** Aircraft model and version */ std::string aircraftName; /** Aircraft name = "type" - "model" */ @@ -63,7 +63,7 @@ public: * \return void */ void setGlobalReferencePoint(); - + /** * \brief Reads accommodation data from the acxml * \param acxml Aircraft XML diff --git a/initial_sizing/src/taw/analytical/TawAnalytical.cpp b/initial_sizing/src/taw/analytical/TawAnalytical.cpp index fad07df21e0ae2ea71880db6a18b33abf04c191b..0ade8336088bc97acc05cdef3ed410cd7d80d38b 100644 --- a/initial_sizing/src/taw/analytical/TawAnalytical.cpp +++ b/initial_sizing/src/taw/analytical/TawAnalytical.cpp @@ -30,7 +30,6 @@ #include "../../initialSizingDefines.h" #include "atmosphere/atmosphere.h" - TawAnalytical::TawAnalytical(std::shared_ptr<RuntimeIO> rtIO) : rtIO_(rtIO), report_(rtIO) {} void TawAnalytical::initialize() { @@ -80,7 +79,7 @@ void TawAnalytical::save() { void TawAnalytical::size() { myRuntimeInfo->out << "Start calculation ..." << std::endl; - + myRuntimeInfo->out << "Calculating payload ..." << std::endl; calculatePayloadAndCrew(); @@ -99,7 +98,7 @@ void TawAnalytical::size() { calculateCruise(); calculateLanding(); - + findIntersectionPoints_LTO(); findIntersectionPoints_CL(); @@ -107,7 +106,7 @@ void TawAnalytical::size() { findIntersectionPoints_CR(); findIntersectionPoints_CT(); - + findIntersectionPoints_TC(); getoptiCL(); @@ -125,45 +124,44 @@ void TawAnalytical::size() { } - void TawAnalytical::study() { // not implemented yet } - void TawAnalytical::calculatePayloadAndCrew() { // Calculate passenger weight - passengerWeight = data_->data.Accommodation.numberPassengers * (data_->data.Accommodation.massPassenger + data_->data.Accommodation.massLuggage); + passengerWeight = data_->data.Accommodation.numberPassengers * + (data_->data.Accommodation.massPassenger + data_->data.Accommodation.massLuggage); // Calculate cargo weight cargoWeight = data_->data.Accommodation.massCargo; // The ratios (0/0/0/0.1/0.9) represent the relative passenger distribution for the classes - // The ratios (10/14/28/35/40) represent how many crew members are needed for every 10, 14, 28, 35, 40 passengers in each class. - - numPresidentCrew = std::ceil(data_->data.Accommodation.numberPassengers * 0 / 10.0); + // The ratios (10/14/28/35/40) represent how many crew members are needed + // for every 10, 14, 28, 35, 40 passengers in each class. + + numPresidentCrew = std::ceil(data_->data.Accommodation.numberPassengers * 0 / 10.0); numFirstClassCrew = std::ceil(data_->data.Accommodation.numberPassengers * 0 / 14.0); numBusinessClassCrew = std::ceil(data_->data.Accommodation.numberPassengers * 0 / 28.0); numPremiumEconomyCrew = std::ceil(data_->data.Accommodation.numberPassengers * 0.1 / 35.0); numEconomyCrew = std::ceil(data_->data.Accommodation.numberPassengers * 0.9 / 40.0); - numCrew = numPresidentCrew + numFirstClassCrew + numBusinessClassCrew + numPremiumEconomyCrew + numEconomyCrew + data_->configuration.numberOfPilots; + numCrew = numPresidentCrew + numFirstClassCrew + numBusinessClassCrew + + numPremiumEconomyCrew + numEconomyCrew + data_->configuration.numberOfPilots; // Calculate crew weight crewWeight = (data_->data.Accommodation.massPassenger + data_->data.Accommodation.massLuggage) * numCrew; // Calculate total payload Payload = passengerWeight + cargoWeight; - + std::cout << "Passenger Weight: " << passengerWeight << std::endl; std::cout << "Crew Number: " << numCrew << std::endl; std::cout << "Crew Weight: " << crewWeight << std::endl; std::cout << "cargoWeight: " << cargoWeight << std::endl; std::cout << "Payload: " << Payload << std::endl; - } - void TawAnalytical::calculateFuelFraction() { // Access necessary data from TawInitialSizingIOData range = data_->data.MissionInfo.range; @@ -171,10 +169,9 @@ void TawAnalytical::calculateFuelFraction() { machNumber = data_->data.MissionInfo.machNumber; SFCKerosene = data_->configuration.SFCKerosene; LDInitialCruise = data_->configuration.LDInitialCruise; - LDInitialLoiter = data_->configuration.LDInitialLoiter; + LDInitialLoiter = data_->configuration.LDInitialLoiter; energyCarrier = data_->data.EnergyCarrier.energyCarrier; - ff_warmup = data_->configuration.ff_warmup; ff_taxi = data_->configuration.ff_taxi; ff_takeoff = data_->configuration.ff_takeoff; @@ -199,23 +196,25 @@ void TawAnalytical::calculateFuelFraction() { CruiseFuel = exp((-range * SFCKerosene) / (vCruise * LDInitialCruise)); distAlter = data_->data.MissionInfo.distalt; std::cout << "Alternate Distance: " << distAlter << std::endl; - AltFuel = exp((-distAlter * SFCKerosene) / (vCruise * LDInitialCruise)); + AltFuel = exp((-distAlter * SFCKerosene) / (vCruise * LDInitialCruise)); timeLoiter = data_->data.MissionInfo.loitertime; std::cout << "Loiter time: " << timeLoiter << std::endl; - LoiterFuel = exp((-timeLoiter * (0.85 * SFCKerosene)) / (LDInitialLoiter)); - + LoiterFuel = exp((-timeLoiter * (0.85 * SFCKerosene)) / (LDInitialLoiter)); + // Calculate fuel fraction based on fuel type (0: kerosene, 1: liquid hydrogen) if (energyCarrier == "kerosene") { // Calculate FuelFraction for kerosene FuelFraction = 1.02 * (1 - ((ff_warmup * ff_taxi * ff_takeoff * - ff_climb * ff_descent * CruiseFuel * (contingency + 1)) * ff_missedandclimb * AltFuel * LoiterFuel * ff_land)); + ff_climb * ff_descent * CruiseFuel * (contingency + 1)) * ff_missedandclimb * + AltFuel * LoiterFuel * ff_land)); std::cout << "Fuel Fraction (Kerosene): " << FuelFraction << std::endl; } else if (energyCarrier == "hydrogen") { // Calculate FuelFraction for liquid hydrogen FuelFraction = 1.05 * (1 / 2.8) * (1 - ((ff_warmup * ff_taxi * ff_takeoff * - ff_climb * ff_descent * CruiseFuel * (contingency + 1)) * ff_missedandclimb * AltFuel * LoiterFuel * ff_land)); + ff_climb * ff_descent * CruiseFuel * (contingency + 1)) * ff_missedandclimb * + AltFuel * LoiterFuel * ff_land)); std::cout << "Fuel Fraction (Liquid Hydrogen): " << FuelFraction << std::endl; } else { // Abort fuel fraction calculation for unsupported fuel types @@ -224,7 +223,6 @@ void TawAnalytical::calculateFuelFraction() { } } - void TawAnalytical::calculateMassEstimation() { // Constants mo_iteration = 5.5 * Payload; @@ -235,7 +233,6 @@ void TawAnalytical::calculateMassEstimation() { // Select the appropriate coefficient based on the fuel type c_fuel = (energyCarrier == "kerosene") ? c_kerosine : c_LH2; - // Perform the iterative calculations do { mo_iteration_previous = mo_iteration; @@ -268,7 +265,6 @@ bool TawAnalytical::checkConvergence(double mo_iteration, double mo_iteration_pr return std::abs(mo_iteration - mo_iteration_previous) < convergence_criteria; } - void TawAnalytical::calculateCDO() { // Read fricition coefficient double Cfeq = data_->configuration.Cfeq; @@ -302,10 +298,8 @@ void TawAnalytical::calculateTakeoff() { takeoffDataWS.push_back(mo_S); takeoffDataTW.push_back(T_W_TO); } - } - void TawAnalytical::calculateClimb() { double DeltaCD_HL = data_->configuration.DeltaCD_HL; AR = data_->configuration.AR; @@ -363,7 +357,7 @@ void TawAnalytical::calculateLanding() { landingDataWS.clear(); landingDataTW.clear(); - size_t size = cruiseDataTW.size(); + size_t size = cruiseDataTW.size(); for (size_t i = 0; i < size; ++i) { double moS_landing = ((std::pow(vApproach, 2))*densitySL*CLmaxL)/((std::pow(densitySL, 2))*2*g*(ml_mo)); @@ -372,7 +366,6 @@ void TawAnalytical::calculateLanding() { } } - void TawAnalytical::findIntersectionPoints_LTO() { // Iterate over the landing and takeoff data to find intersections @@ -388,11 +381,14 @@ void TawAnalytical::findIntersectionPoints_LTO() { double takeoffWS2 = takeoffDataWS[j + 1]; double takeoffTW2 = takeoffDataTW[j + 1]; - double denominator = (takeoffWS2 - takeoffWS1) * (landingTW2 - landingTW1) - (takeoffTW2 - takeoffTW1) * (landingWS2 - landingWS1); + double denominator = (takeoffWS2 - takeoffWS1) * (landingTW2 - landingTW1) - + (takeoffTW2 - takeoffTW1) * (landingWS2 - landingWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((takeoffWS2 - takeoffWS1) * (landingTW1 - takeoffTW1) - (takeoffTW2 - takeoffTW1) * (landingWS1 - takeoffWS1)) / denominator; - double ub = ((landingWS2 - landingWS1) * (landingTW1 - takeoffTW1) - (landingTW2 - landingTW1) * (landingWS1 - takeoffWS1)) / denominator; + double ua = ((takeoffWS2 - takeoffWS1) * (landingTW1 - takeoffTW1) - + (takeoffTW2 - takeoffTW1) * (landingWS1 - takeoffWS1)) / denominator; + double ub = ((landingWS2 - landingWS1) * (landingTW1 - takeoffTW1) - + (landingTW2 - landingTW1) * (landingWS1 - takeoffWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = landingWS1 + ua * (landingWS2 - landingWS1); @@ -404,9 +400,8 @@ void TawAnalytical::findIntersectionPoints_LTO() { } } - void TawAnalytical::findIntersectionPoints_CL() { - + // Iterate over the landing and climb data to find intersections for (size_t i = 0; i < landingDataWS.size() - 1; ++i) { double landingWS1 = landingDataWS[i]; @@ -420,11 +415,14 @@ void TawAnalytical::findIntersectionPoints_CL() { double climbWS2 = climbDataWS[j + 1]; double climbTW2 = climbDataTW[j + 1]; - double denominator = (climbWS2 - climbWS1) * (landingTW2 - landingTW1) - (climbTW2 - climbTW1) * (landingWS2 - landingWS1); + double denominator = (climbWS2 - climbWS1) * (landingTW2 - landingTW1) - + (climbTW2 - climbTW1) * (landingWS2 - landingWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((climbWS2 - climbWS1) * (landingTW1 - climbTW1) - (climbTW2 - climbTW1) * (landingWS1 - climbWS1)) / denominator; - double ub = ((landingWS2 - landingWS1) * (landingTW1 - climbTW1) - (landingTW2 - landingTW1) * (landingWS1 - climbWS1)) / denominator; + double ua = ((climbWS2 - climbWS1) * (landingTW1 - climbTW1) - + (climbTW2 - climbTW1) * (landingWS1 - climbWS1)) / denominator; + double ub = ((landingWS2 - landingWS1) * (landingTW1 - climbTW1) - + (landingTW2 - landingTW1) * (landingWS1 - climbWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = landingWS1 + ua * (landingWS2 - landingWS1); @@ -436,7 +434,6 @@ void TawAnalytical::findIntersectionPoints_CL() { } } - void TawAnalytical::findIntersectionPoints_CR() { // Iterate over the landing and cruise data to find intersections for (size_t i = 0; i < landingDataWS.size() - 1; ++i) { @@ -451,11 +448,14 @@ void TawAnalytical::findIntersectionPoints_CR() { double cruiseWS2 = cruiseDataWS[j + 1]; double cruiseTW2 = cruiseDataTW[j + 1]; - double denominator = (cruiseWS2 - cruiseWS1) * (landingTW2 - landingTW1) - (cruiseTW2 - cruiseTW1) * (landingWS2 - landingWS1); + double denominator = (cruiseWS2 - cruiseWS1) * (landingTW2 - landingTW1) - + (cruiseTW2 - cruiseTW1) * (landingWS2 - landingWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((cruiseWS2 - cruiseWS1) * (landingTW1 - cruiseTW1) - (cruiseTW2 - cruiseTW1) * (landingWS1 - cruiseWS1)) / denominator; - double ub = ((landingWS2 - landingWS1) * (landingTW1 - cruiseTW1) - (landingTW2 - landingTW1) * (landingWS1 - cruiseWS1)) / denominator; + double ua = ((cruiseWS2 - cruiseWS1) * (landingTW1 - cruiseTW1) - + (cruiseTW2 - cruiseTW1) * (landingWS1 - cruiseWS1)) / denominator; + double ub = ((landingWS2 - landingWS1) * (landingTW1 - cruiseTW1) - + (landingTW2 - landingTW1) * (landingWS1 - cruiseWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = landingWS1 + ua * (landingWS2 - landingWS1); @@ -467,7 +467,6 @@ void TawAnalytical::findIntersectionPoints_CR() { } } - void TawAnalytical::findIntersectionPoints_CT() { // Iterate over the climb and takeoff data to find intersections @@ -483,11 +482,14 @@ void TawAnalytical::findIntersectionPoints_CT() { double takeoffWS2 = takeoffDataWS[j + 1]; double takeoffTW2 = takeoffDataTW[j + 1]; - double denominator = (takeoffWS2 - takeoffWS1) * (climbTW2 - climbTW1) - (takeoffTW2 - takeoffTW1) * (climbWS2 - climbWS1); + double denominator = (takeoffWS2 - takeoffWS1) * (climbTW2 - climbTW1) - + (takeoffTW2 - takeoffTW1) * (climbWS2 - climbWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((takeoffWS2 - takeoffWS1) * (climbTW1 - takeoffTW1) - (takeoffTW2 - takeoffTW1) * (climbWS1 - takeoffWS1)) / denominator; - double ub = ((climbWS2 - climbWS1) * (climbTW1 - takeoffTW1) - (climbTW2 - climbTW1) * (climbWS1 - takeoffWS1)) / denominator; + double ua = ((takeoffWS2 - takeoffWS1) * (climbTW1 - takeoffTW1) - + (takeoffTW2 - takeoffTW1) * (climbWS1 - takeoffWS1)) / denominator; + double ub = ((climbWS2 - climbWS1) * (climbTW1 - takeoffTW1) - + (climbTW2 - climbTW1) * (climbWS1 - takeoffWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = climbWS1 + ua * (climbWS2 - climbWS1); @@ -499,7 +501,6 @@ void TawAnalytical::findIntersectionPoints_CT() { } } - void TawAnalytical::findIntersectionPoints_TC() { // Iterate over the takeoff and cruise data to find intersections @@ -515,11 +516,14 @@ void TawAnalytical::findIntersectionPoints_TC() { double cruiseWS2 = cruiseDataWS[j + 1]; double cruiseTW2 = cruiseDataTW[j + 1]; - double denominator = (cruiseWS2 - cruiseWS1) * (takeoffTW2 - takeoffTW1) - (cruiseTW2 - cruiseTW1) * (takeoffWS2 - takeoffWS1); + double denominator = (cruiseWS2 - cruiseWS1) * (takeoffTW2 - takeoffTW1) - + (cruiseTW2 - cruiseTW1) * (takeoffWS2 - takeoffWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((cruiseWS2 - cruiseWS1) * (takeoffTW1 - cruiseTW1) - (cruiseTW2 - cruiseTW1) * (takeoffWS1 - cruiseWS1)) / denominator; - double ub = ((takeoffWS2 - takeoffWS1) * (takeoffTW1 - cruiseTW1) - (takeoffTW2 - takeoffTW1) * (takeoffWS1 - cruiseWS1)) / denominator; + double ua = ((cruiseWS2 - cruiseWS1) * (takeoffTW1 - cruiseTW1) - + (cruiseTW2 - cruiseTW1) * (takeoffWS1 - cruiseWS1)) / denominator; + double ub = ((takeoffWS2 - takeoffWS1) * (takeoffTW1 - cruiseTW1) - + (takeoffTW2 - takeoffTW1) * (takeoffWS1 - cruiseWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = takeoffWS1 + ua * (takeoffWS2 - takeoffWS1); @@ -531,7 +535,6 @@ void TawAnalytical::findIntersectionPoints_TC() { } } - void TawAnalytical::getoptiCL() { double optimalCL = data_->configuration.optimalCL; double g = 9.81; @@ -554,7 +557,6 @@ void TawAnalytical::getoptiCL() { } } - void TawAnalytical::findIntersectionPoints_optiCL_Takeoff() { // Iterate over the optiCL and takeoff data to find intersections for (size_t i = 0; i < optiCLDataWS.size() - 1; ++i) { @@ -569,11 +571,14 @@ void TawAnalytical::findIntersectionPoints_optiCL_Takeoff() { double takeoffWS2 = takeoffDataWS[j + 1]; double takeoffTW2 = takeoffDataTW[j + 1]; - double denominator = (takeoffWS2 - takeoffWS1) * (optiCLTW2 - optiCLTW1) - (takeoffTW2 - takeoffTW1) * (optiCLWS2 - optiCLWS1); + double denominator = (takeoffWS2 - takeoffWS1) * (optiCLTW2 - optiCLTW1) - + (takeoffTW2 - takeoffTW1) * (optiCLWS2 - optiCLWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((takeoffWS2 - takeoffWS1) * (optiCLTW1 - takeoffTW1) - (takeoffTW2 - takeoffTW1) * (optiCLWS1 - takeoffWS1)) / denominator; - double ub = ((optiCLWS2 - optiCLWS1) * (optiCLTW1 - takeoffTW1) - (optiCLTW2 - optiCLTW1) * (optiCLWS1 - takeoffWS1)) / denominator; + double ua = ((takeoffWS2 - takeoffWS1) * (optiCLTW1 - takeoffTW1) - (takeoffTW2 - takeoffTW1) * + (optiCLWS1 - takeoffWS1)) / denominator; + double ub = ((optiCLWS2 - optiCLWS1) * (optiCLTW1 - takeoffTW1) - (optiCLTW2 - optiCLTW1) * + (optiCLWS1 - takeoffWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = optiCLWS1 + ua * (optiCLWS2 - optiCLWS1); @@ -585,7 +590,6 @@ void TawAnalytical::findIntersectionPoints_optiCL_Takeoff() { } } - void TawAnalytical::findIntersectionPoints_optiCL_Cruise() { // Iterate over the optiCL and cruise data to find intersections for (size_t i = 0; i < optiCLDataWS.size() - 1; ++i) { @@ -600,11 +604,14 @@ void TawAnalytical::findIntersectionPoints_optiCL_Cruise() { double cruiseWS2 = cruiseDataWS[j + 1]; double cruiseTW2 = cruiseDataTW[j + 1]; - double denominator = (cruiseWS2 - cruiseWS1) * (optiCLTW2 - optiCLTW1) - (cruiseTW2 - cruiseTW1) * (optiCLWS2 - optiCLWS1); + double denominator = (cruiseWS2 - cruiseWS1) * (optiCLTW2 - optiCLTW1) - + (cruiseTW2 - cruiseTW1) * (optiCLWS2 - optiCLWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((cruiseWS2 - cruiseWS1) * (optiCLTW1 - cruiseTW1) - (cruiseTW2 - cruiseTW1) * (optiCLWS1 - cruiseWS1)) / denominator; - double ub = ((optiCLWS2 - optiCLWS1) * (optiCLTW1 - cruiseTW1) - (optiCLTW2 - optiCLTW1) * (optiCLWS1 - cruiseWS1)) / denominator; + double ua = ((cruiseWS2 - cruiseWS1) * (optiCLTW1 - cruiseTW1) - (cruiseTW2 - cruiseTW1) * + (optiCLWS1 - cruiseWS1)) / denominator; + double ub = ((optiCLWS2 - optiCLWS1) * (optiCLTW1 - cruiseTW1) - (optiCLTW2 - optiCLTW1) * + (optiCLWS1 - cruiseWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = optiCLWS1 + ua * (optiCLWS2 - optiCLWS1); @@ -616,7 +623,6 @@ void TawAnalytical::findIntersectionPoints_optiCL_Cruise() { } } - void TawAnalytical::findIntersectionPoints_optiCL_Climb() { // Iterate over the optiCL and climb data to find intersections for (size_t i = 0; i < optiCLDataWS.size() - 1; ++i) { @@ -631,11 +637,14 @@ void TawAnalytical::findIntersectionPoints_optiCL_Climb() { double climbWS2 = climbDataWS[j + 1]; double climbTW2 = climbDataTW[j + 1]; - double denominator = (climbWS2 - climbWS1) * (optiCLTW2 - optiCLTW1) - (climbTW2 - climbTW1) * (optiCLWS2 - optiCLWS1); + double denominator = (climbWS2 - climbWS1) * (optiCLTW2 - optiCLTW1) - + (climbTW2 - climbTW1) * (optiCLWS2 - optiCLWS1); if (std::abs(denominator) > 1e-6) { - double ua = ((climbWS2 - climbWS1) * (optiCLTW1 - climbTW1) - (climbTW2 - climbTW1) * (optiCLWS1 - climbWS1)) / denominator; - double ub = ((optiCLWS2 - optiCLWS1) * (optiCLTW1 - climbTW1) - (optiCLTW2 - optiCLTW1) * (optiCLWS1 - climbWS1)) / denominator; + double ua = ((climbWS2 - climbWS1) * (optiCLTW1 - climbTW1) - + (climbTW2 - climbTW1) * (optiCLWS1 - climbWS1)) / denominator; + double ub = ((optiCLWS2 - optiCLWS1) * (optiCLTW1 - climbTW1) - + (optiCLTW2 - optiCLTW1) * (optiCLWS1 - climbWS1)) / denominator; if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { double intersectWS = optiCLWS1 + ua * (optiCLWS2 - optiCLWS1); @@ -647,7 +656,6 @@ void TawAnalytical::findIntersectionPoints_optiCL_Climb() { } } - void TawAnalytical::findDesignPoint() { // Function to find the maximum TW in a vector of intersection points auto findTW = [](const std::vector<std::pair<double, double>>& points) -> double { @@ -670,7 +678,7 @@ void TawAnalytical::findDesignPoint() { return 0.0; }; - // optimal CL data + // optimal CL data getoptiCL(); double TW_CL = findTW(intersectionPoints_CL); @@ -704,7 +712,7 @@ void TawAnalytical::findDesignPoint() { double TW_TC = findTW(intersectionPoints_TC); double ws_TC = findCorrespondingWS(intersectionPoints_TC, TW_TC); - // Determine the higher T/W between takeoff-climb and takeoff-cruise intersections to be + // Determine the higher T/W between takeoff-climb and takeoff-cruise intersections to be // interpolated with the highest point of T/W in takeoff-landing constraint double TW_temp = std::max(TW_CT, TW_TC); @@ -727,7 +735,7 @@ void TawAnalytical::findDesignPoint() { } else { // Perform linear interpolation between LTO and the higher of CT/TC double slope = (TW_LTO - TW_temp) / (ws_LTO - WS_temp); - designWS_ = (ws_LTO + WS_temp) / 2; // Midpoint as a starting guess + designWS_ = (ws_LTO + WS_temp) / 2; // Midpoint as a starting guess double interpolatedTW = TW_temp + slope * (designWS_ - WS_temp); // Update interpolated TW and WS based on interpolation @@ -737,7 +745,8 @@ void TawAnalytical::findDesignPoint() { designPoint = (TW_temp == TW_CT) ? "Takeoff and Climb" : "Takeoff and Cruise"; // Print out of range message - std::cout << "Optimal CL set in config file is out of range. Interpolation method was used to calculate the design point\n"; + std::cout << "Optimal CL set in config file is out of range. " + "Interpolation method was used to calculate the design point.\n"; } } diff --git a/initial_sizing/src/taw/analytical/TawAnalytical.h b/initial_sizing/src/taw/analytical/TawAnalytical.h index 3c2bc5e872e7f2275abe0a44a07b664266cf50f1..1c623e5e7cb430f82991ca7a22a7a1dd510debf7 100644 --- a/initial_sizing/src/taw/analytical/TawAnalytical.h +++ b/initial_sizing/src/taw/analytical/TawAnalytical.h @@ -20,8 +20,8 @@ * This file is part of UNICADO. */ -#ifndef INITIALSIZING_SRC_TAW_ANALYTICAL_TAWANALYTICAL_H_ -#define INITIALSIZING_SRC_TAW_ANALYTICAL_TAWANALYTICAL_H_ +#ifndef INITIALSIZING_SRC_TAW_ANALYTICAL_TAWANALYTICAL_H_ +#define INITIALSIZING_SRC_TAW_ANALYTICAL_TAWANALYTICAL_H_ #include <memory> #include <vector> @@ -32,7 +32,6 @@ #include "../TawInitialSizingIOData.h" #include "../TawInitialSizingData.h" - class TawAnalytical : public Strategy { public: explicit TawAnalytical(std::shared_ptr<RuntimeIO> rtIO); @@ -86,10 +85,8 @@ class TawAnalytical : public Strategy { std::vector<std::pair<double, double>> intersectionPoints_optiCL_Cruise; std::vector<std::pair<double, double>> intersectionPoints_optiCL_Takeoff; - double designWS_; double designTW_; - /* Reporting elements */ /** @@ -161,11 +158,10 @@ class TawAnalytical : public Strategy { double contingency = 0.; double CruiseFuel = 0.; double distAlter = 0.; - double AltFuel = 0.; + double AltFuel = 0.; double timeLoiter = 0.; - double LoiterFuel = 0.; + double LoiterFuel = 0.; double c_fuel = 0.; - }; -#endif // INITIALSIZING_SRC_TAW_ANALYTICAL_TAWANALYTICAL_H_ +#endif // INITIALSIZING_SRC_TAW_ANALYTICAL_TAWANALYTICAL_H_ \ No newline at end of file diff --git a/initial_sizing/src/taw/analytical/TawAnalyticalPlot.cpp b/initial_sizing/src/taw/analytical/TawAnalyticalPlot.cpp index 16500668a38f2bba423d846a9616dc263c6f8ec4..74ef70e73cb36f43019472ec89cf4c1d242b8969 100644 --- a/initial_sizing/src/taw/analytical/TawAnalyticalPlot.cpp +++ b/initial_sizing/src/taw/analytical/TawAnalyticalPlot.cpp @@ -25,7 +25,6 @@ #include <vector> #include <matplot/matplot.h> - void TawAnalytical::generatePlotData() { // Create figure auto fig = matplot::gcf(); @@ -33,27 +32,27 @@ void TawAnalytical::generatePlotData() { auto ax = fig->current_axes(); ax->hold(true); - - auto takeoffPlot = ax->plot(takeoffDataWS, takeoffDataTW, "-r"); + + auto takeoffPlot = ax->plot(takeoffDataWS, takeoffDataTW, "-r"); takeoffPlot->line_width(2.0); - auto climbPlot = ax->plot(climbDataWS, climbDataTW, "-k"); + auto climbPlot = ax->plot(climbDataWS, climbDataTW, "-k"); climbPlot->line_width(2.0); - auto cruisePlot = ax->plot(cruiseDataWS, cruiseDataTW, "-g"); + auto cruisePlot = ax->plot(cruiseDataWS, cruiseDataTW, "-g"); cruisePlot->line_width(2.0); - auto landingPlot = ax->plot(landingDataWS, landingDataTW, "-b"); + auto landingPlot = ax->plot(landingDataWS, landingDataTW, "-b"); landingPlot->line_width(2.0); - auto optiCLPlot = ax->plot(optiCLDataWS, optiCLDataTW, "-m"); + auto optiCLPlot = ax->plot(optiCLDataWS, optiCLDataTW, "-m"); optiCLPlot->line_width(2.0); std::vector<double> designWS_vec = {designWS_}; std::vector<double> designTW_vec = {designTW_}; auto designPlot = ax->plot(designWS_vec, designTW_vec, "ok"); - designPlot->marker_size(6.0); - designPlot->marker_face_color("k"); + designPlot->marker_size(6.0); + designPlot->marker_face_color("k"); ax->title("Sizing Chart"); ax->xlabel("Wing Loading (W/S)"); @@ -70,4 +69,3 @@ void TawAnalytical::generatePlotData() { std::cout << "Plot saved to: " << plotFilePath << std::endl; } - diff --git a/initial_sizing/src/taw/analytical/TawAnalyticalReport.cpp b/initial_sizing/src/taw/analytical/TawAnalyticalReport.cpp index d8b1bee039a6901c91c30f06842e1d3b0d1b3f3d..8802b446fdd72f9149f1079bc3db0b99a585cf01 100644 --- a/initial_sizing/src/taw/analytical/TawAnalyticalReport.cpp +++ b/initial_sizing/src/taw/analytical/TawAnalyticalReport.cpp @@ -30,31 +30,35 @@ void TawAnalytical::setHtmlBody() { // Add the plot image to the HTML report std::string plotFilePath = rtIO_->getPlotFilesDir() + "/WS_TW_Plot.svg"; report_.htmlReportStream() << "<div class=\"plot-container\">\n"; - report_.htmlReportStream() << "<img class=\"image-plot\" src=\"" + relativePath(rtIO_->getPlotFilesDir(), rtIO_->getReportDir()) + "/WS_TW_Plot.svg\">" << std::endl; + report_.htmlReportStream() << "<img class=\"image-plot\" src=\"" + relativePath(rtIO_->getPlotFilesDir(), + rtIO_->getReportDir()) + "/WS_TW_Plot.svg\">" << std::endl; report_.htmlReportStream() << "</div>" << std::endl; if (data_->configuration.designCase == true) { report_.htmlReportStream() << "<h2>Wing loading and Thrust-to-Weight-Ratio</h2>" << std::endl; report_.htmlReportStream() << "<table>" << std::endl; - report_.htmlReportStream() << "<tr><td>Wing Loading (W/S)</td><td>" << Rounding(designWS_, 0) << " kg/m^2</td></tr>" << std::endl; - report_.htmlReportStream() << "<tr><td>Thrust-to-Weight Ratio (T/W)</td><td> " << designTW_ << "</td></tr>" << std::endl; + report_.htmlReportStream() << "<tr><td>Wing Loading (W/S)</td><td>" << Rounding(designWS_, 0) + << " kg/m^2</td></tr>" << std::endl; + report_.htmlReportStream() << "<tr><td>Thrust-to-Weight Ratio (T/W)</td><td> " + << designTW_ << "</td></tr>" << std::endl; report_.htmlReportStream() << "</table>" << std::endl; report_.htmlReportStream() << "<h2>Mass Estimation</h2>" << std::endl; report_.htmlReportStream() << "<table>" << std::endl; - report_.htmlReportStream() << "<tr><td>Operating Mass Empty (OME)</td><td>" << Rounding(final_mass_estimation_, 0) << " kg</td></tr>" << std::endl; - report_.htmlReportStream() << "<tr><td>Maximum Take-Off Mass (MTOM)</td><td> " << Rounding(mo_iteration_, 0) << " kg</td></tr>" << std::endl; + report_.htmlReportStream() << "<tr><td>Operating Mass Empty (OME)</td><td>" + << Rounding(final_mass_estimation_, 0) << " kg</td></tr>" << std::endl; + report_.htmlReportStream() << "<tr><td>Maximum Take-Off Mass (MTOM)</td><td> " + << Rounding(mo_iteration_, 0) << " kg</td></tr>" << std::endl; report_.htmlReportStream() << "</table>" << std::endl; } else { report_.htmlReportStream() << "Study Mode: " << "</h1>" << std::endl; report_.htmlReportStream() << "<td>The program was run in study mode.</td>" << std::endl << "<td>The masses were not redetermined!</td>" << std::endl; - } + } } - void TawAnalytical::setTexBody() { if (data_->configuration.designCase == true) { - report_.texReportStream() + report_.texReportStream() << "\\section{Initial Sizing}" << std::endl << "\\begin{frame}" << std::endl << " \\frametitle{Initial Sizing ...}" << std::endl @@ -67,26 +71,31 @@ void TawAnalytical::setTexBody() { << " \\multicolumn{3}{l}{Selected Design Point}\\\\" << std::endl << " \\midrule[0.5pt]" << std::endl - << " \\textcolor{ilrdark}{$\\blacktriangleright$} Wing Loading & $W/S$ &" << Rounding(designWS_ , 0)<< " $kg/m^{2}$\\\\" << std::endl - << " \\textcolor{ilrdark}{$\\blacktriangleright$} Thrust to Weight & $T/W$ & " << designTW_ << " $-$\\\\" << std::endl + << " \\textcolor{ilrdark}{$\\blacktriangleright$} Wing Loading & $W/S$ &" + << Rounding(designWS_ , 0)<< " $kg/m^{2}$\\\\" << std::endl + << " \\textcolor{ilrdark}{$\\blacktriangleright$} Thrust to Weight & $T/W$ & " + << designTW_ << " $-$\\\\" << std::endl << " \\midrule[0.5pt]" << std::endl << " \\multicolumn{3}{l}{Initial Maximum Takeoff Mass}\\\\" << std::endl << " \\midrule[0.5pt]" << std::endl - << " \\textcolor{ilrdark}{$\\blacktriangleright$} $MTOM_0$ & & " << Rounding(mo_iteration_ , 0)<< " $kg$\\\\" << std::endl + << " \\textcolor{ilrdark}{$\\blacktriangleright$} $MTOM_0$ & & " + << Rounding(mo_iteration_ , 0)<< " $kg$\\\\" << std::endl << " \\end{tabular}" << std::endl << " \\end{table}" << std::endl << " \\end{minipage}" << std::endl << " \\begin{minipage}{0.5\\textwidth}" << std::endl << " \\tiny" << std::endl << " \\def\\svgwidth{5 cm}" << std::endl - << " \\import{" + win2lin(relativePath(rtIO_->getPlotDir(), rtIO_->getReportDir())) + "}{" + data_->configuration.theProgramName + "_MassBreakdown_plot.pdf_tex}" << std::endl + << " \\import{" + win2lin(relativePath(rtIO_->getPlotDir(), + << rtIO_->getReportDir())) + "}{" + data_->configuration.theProgramName + + << "_MassBreakdown_plot.pdf_tex}" << std::endl << " \\caption{\\footnotesize{Initial Sizing Plot}}" << std::endl << " \\end{minipage}" << std::endl << "\\end{figure}" << std::endl << "\\end{frame}" << std::endl; } else { - report_.texReportStream() + report_.texReportStream() << "\\begin{frame}" << std::endl << " \\frametitle{Study Mode}" << std::endl << std::endl @@ -95,7 +104,3 @@ void TawAnalytical::setTexBody() { << "\\end{frame}" << std::endl; } } - - - -