From 14f5295a36f495db709226ed6e1ebde05220aab9 Mon Sep 17 00:00:00 2001 From: heappy <christopher.ruwisch@gmail.com> Date: Wed, 20 Nov 2024 16:32:53 +0100 Subject: [PATCH] removed hardcoded values from mass methods + added parameters inside data for replacement --- .../cantilever/cantileverWingDesignTaw.cpp | 38 ++++++--------- wing_design/src/taw/tawWingDesignData.cpp | 46 +++++++++++++++++-- wing_design/src/taw/tawWingDesignData.h | 7 ++- 3 files changed, 61 insertions(+), 30 deletions(-) diff --git a/wing_design/src/taw/cantilever/cantileverWingDesignTaw.cpp b/wing_design/src/taw/cantilever/cantileverWingDesignTaw.cpp index b2f57e1f..12fbb32d 100644 --- a/wing_design/src/taw/cantilever/cantileverWingDesignTaw.cpp +++ b/wing_design/src/taw/cantilever/cantileverWingDesignTaw.cpp @@ -216,17 +216,10 @@ void Wing::standard_design() { config->high_lift_device_type_trailing_edge.value()); data->control_devices = devices; data->control_devices_deflections = deflections; - /* Set control device deflections for user defined control devices */ - // if (config->control_device_mode.value().compare("mode_0") == 0) { - // for (auto item : config->user_defined_control_devices) { - // data->control_devices_deflections.push_back( - // {item.deflection_full_negative.value(), item.deflection_full_positive.value()}); - // } - // } /* Check control device boundaries - if inside fuselage */ - if ((config->control_device_mode.value().compare("mode_0") == 0) && - (rtIO->aircraft_configuration_type().compare("tube_and_wing") == 0)) { + if ((config->control_device_mode.value() == "mode_0") && + (rtIO->aircraft_configuration_type() == "tube_and_wing")) { double eta_fuselage_max = geom2::measure::width_max(data->fuselage) / geom2::measure::span(data->wing); for (auto& device : data->control_devices) { size_t sec_id = 0; @@ -248,8 +241,8 @@ bool Wing::is_wing_kinked_check() { myRuntimeInfo->out << "Wing kink check ..." << std::endl; /* Check if mounting is low & landing gear mounted on wing */ - if (data->specification_wing_mounting.value().compare("low") == 0 && - data->specification_landing_gear_mounting.value().compare("wing_mounted") == 0) { + if (data->specification_wing_mounting.value()== "low" && + data->specification_landing_gear_mounting.value() == "wing_mounted") { myRuntimeInfo->out << "Wing is kinked ... [TRUE]" << std::endl; return true; } else { @@ -262,7 +255,7 @@ double Wing::get_max_thickness_to_chord_ratio() { // Get maximum thickness to chord ratio based on wing profile and thickness mode // If user - get maximum thickness from elements // Else use max_thickness to chord ratio from sweep calculation method - if (config->wing_profile_and_thickness_calculation_mode.value().compare("mode_0") == 0) { + if (config->wing_profile_and_thickness_calculation_mode.value() == "mode_0") { std::vector<double> to_check; for (auto item : config->user_thickness_to_chord) { to_check.push_back(item.value()); @@ -646,8 +639,7 @@ void Wing::flops_mass() { const double W3 = A6 * (1.0 - 0.3 * config->flops_fcomp.value()) * pow(wing_area_sqrft, A7); // Wing bending material weight intertia relief adjustment - bool wing_mounted_engines = true; /* needs to be updated */ - const int NEW = 2; + const int NEW = data->specification_number_of_wing_mounted_engines; const double CAYE = 1.0 - 0.03 * NEW; const double W1 = (dg * CAYE * W1NIR + W2 + W3) / (1.0 + W1NIR) - W2 - W3; @@ -682,21 +674,16 @@ void Wing::flops_mass() { myRuntimeInfo->out << "y ... " << data->wing_mass_properties.data["y"].value() << std::endl; myRuntimeInfo->out << "z ... " << data->wing_mass_properties.data["z"].value() << std::endl; - // Calculate wing inertia's ... To Do } /** - * \brief Chiozzotto weight estimation relationship mass estimation + * \brief Chiozzotto weight estimation relationship mass estimation - assumes symmetric engine distribution on wings * */ void Wing::chiozzotto_wer_mass() { myRuntimeInfo->out << "Wing mass estimation using ... CHIOZZOTTO" << std::endl; myRuntimeInfo->out << "Calculating ... " << std::endl; - std::cout << "===================================" << std::endl; - std::cout << "========= HARDCODED VALUES ========" << std::endl; - std::cout << "In function: " << __func__ << std::endl; - std::cout << "L#664 - Engines_mass_and_eta {{5307.267993,0.3}}" << std::endl; - std::cout << "===================================" << std::endl; + std::map<std::string, std::tuple<double, double>> min_max_mtom = { {"AL ASW", {20000, 250000}}, {"AL USW", {20000, 250000}}, {"AL FSW", {20000, 250000}}, @@ -749,9 +736,8 @@ void Wing::chiozzotto_wer_mass() { // Vector with data for one half -> // More than one engine -> k_e = k_e_1 * k_e_2 - std::vector<std::tuple<double, double>> engines_mass_and_eta = {{5307.267993, 0.3}}; double wing_loading = data->sizing_point_wing_loading.value(); - if (data->sizing_point_wing_loading.unit().compare("kg/m^2") == 0) { + if (data->sizing_point_wing_loading.unit() == "kg/m^2") { wing_loading *= G_FORCE; } @@ -764,6 +750,8 @@ void Wing::chiozzotto_wer_mass() { const double pressure_at_zero = isa.getPressureISA(0.0); const double pressure_at_design_altitude = isa.getPressureISA(data->specification_design_altitude.value()); + std::vector<std::tuple<double, double>> engines_mass_and_eta = data->wing_mounted_engine_data; + // Calculation of EAS Design const double v_eas_design = data->specification_design_mach.value() * speed_of_sound_at_zero * sqrt(pressure_at_design_altitude / pressure_at_zero); @@ -847,7 +835,9 @@ void Wing::chiozzotto_wer_mass() { // Engine relief factor double k_e = 1.; for (auto engine : engines_mass_and_eta) { - const auto [engine_mass, engine_relative_spanwise_position] = engine; + const auto [engine_mass, engine_spanwise_position] = engine; + /* If engines exist, the spanwise position is absolute, if engines not exist, the default values are in rel. half span */ + double engine_relative_spanwise_position = data->engines_exist ? std::fabs(engine_spanwise_position)/half_span : engine_spanwise_position; k_e *= (1 - C_er * pow(engine_relative_spanwise_position, E_eta_er) * pow(engine_mass / mtom, E_K_er)); } // Secondary structure mass diff --git a/wing_design/src/taw/tawWingDesignData.cpp b/wing_design/src/taw/tawWingDesignData.cpp index dbd44495..665be368 100644 --- a/wing_design/src/taw/tawWingDesignData.cpp +++ b/wing_design/src/taw/tawWingDesignData.cpp @@ -46,12 +46,50 @@ void taw::cantilever::WingDesignData::read(const node& xml) { specification_maximum_load_factor.read(xml); sizing_point_wing_loading.read(xml); mtom_mass_properties.read(xml); - read_number_of_wing_mounted_engines(xml); + read_wing_mounted_engine_information(xml); } -void taw::cantilever::WingDesignData::read_number_of_wing_mounted_engines(const node& xml) { - auto propulsors = xml.find("requirements_and_specifications/design_specification/propulsion/propulsor",1); - std::cout << "SIZE PROPULSORS: " << propulsors << std::endl; +void taw::cantilever::WingDesignData::read_wing_mounted_engine_information(const node& xml) { + auto propulsors_reqs = xml.getVector("aircraft_exchange_file/requirements_and_specifications/design_specification/propulsion/propulsor",1); + + std::vector<int> wing_mounted_engine_ids; + for (size_t i = 0; i < propulsors_reqs.size(); ++i) { + if (EndnodeReadOnly<std::string>("position/parent_component").read(*propulsors_reqs.at(i)).value() == "wing") { + specification_number_of_wing_mounted_engines++; + wing_mounted_engine_ids.push_back(i); + } + } + /* floor uneven number of engines -> chiozzotto only uses one side of the wing */ + size_t number_of_wing_mounted_engine_half = static_cast<size_t>(std::floor(specification_number_of_wing_mounted_engines / 2.)); + if (xml.find("aircraft_exchange_file/component_design/propulsion") == 0) { + myRuntimeInfo->out << "Using default values for engines if chiozzotto mass method is selected" << std::endl; + myRuntimeInfo->out << "Assume engine + pylon + nacelle ~4000kg and postion between 0.35 and 0.8 eta, starting at 0.35 for first engine" << std::endl; + engines_exist = false; + + double engine_mass = 4000.0; /*<-- 4000kg per engine assumed each */ + double eta_min = 0.35; + double eta_max = 0.8; + for(size_t i = 0; i < number_of_wing_mounted_engine_half; ++i) { + double eta_engine = std::lerp(eta_min,eta_max,i/number_of_wing_mounted_engine_half); + wing_mounted_engine_data.push_back({engine_mass, eta_engine}); + } + } + else { + auto propulsors_comp = xml.getVector("aircraft_exchange_file/component_design/propulsion/specific/propulsion",1); + for (size_t i = 0; i < number_of_wing_mounted_engine_half; ++i) { + MassPropertiesIO pylon = MassPropertiesIO("nacelle@0","nacelle"); + MassPropertiesIO nacelle = MassPropertiesIO("pylon@0","pylon"); + MassPropertiesIO engine = MassPropertiesIO("engine","engine"); + pylon.read(*propulsors_comp.at(wing_mounted_engine_ids.at(i))); + nacelle.read(*propulsors_comp.at(wing_mounted_engine_ids.at(i))); + engine.read(*propulsors_comp.at(wing_mounted_engine_ids.at(i))); + double propulsion_mass = pylon.data["mass"].value() + nacelle.data["mass"].value() + engine.data["mass"].value(); + double propulsion_position = engine.data["y"].value(); + wing_mounted_engine_data.push_back({propulsion_mass,propulsion_position}); + + } + } + } void taw::cantilever::WingDesignData::read_fuselage(std::filesystem::path path, diff --git a/wing_design/src/taw/tawWingDesignData.h b/wing_design/src/taw/tawWingDesignData.h index a82486f1..60f3f80b 100644 --- a/wing_design/src/taw/tawWingDesignData.h +++ b/wing_design/src/taw/tawWingDesignData.h @@ -27,7 +27,8 @@ class WingDesignData { void read(const node& xml); void read_fuselage(std::filesystem::path acxml, std::filesystem::path geometry_data_dir); - void read_number_of_wing_mounted_engines(const node& xml); + void read_wing_mounted_engine_information(const node& xml); + void update(node& xml); void update_wing(node& xml); @@ -44,7 +45,9 @@ class WingDesignData { EndnodeReadOnly<double> sizing_point_wing_loading; EndnodeReadOnly<double> track_based_relative_kink; Endnode<double> spanwise_kink; - uint8_t specification_number_of_wing_mounted_engines; + size_t specification_number_of_wing_mounted_engines; + std::vector<std::tuple<double,double>> wing_mounted_engine_data; + bool engines_exist = true; MassPropertiesIO mtom_mass_properties; MassPropertiesIO wing_mass_properties; -- GitLab