-
Meric Taneri authoredMeric Taneri authored
default_integration.h 7.27 KiB
/*
* UNICADO - UNIversity Conceptual Aircraft Design and Optimization
*
* Copyright (C) 2024 UNICADO consortium
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Description:
* This file is part of UNICADO.
*/
#ifndef SRC_INTEGRATION_DEFAULT_DEFAULT_INTEGRATION_H_
#define SRC_INTEGRATION_DEFAULT_DEFAULT_INTEGRATION_H_
/* === Includes === */
#include "../propulsion_integration.h"
#include <memory>
#include <set>
namespace design
{
namespace integration
{
/* === Classes === */
/**
* @class Default
* @brief The default integration strategy for propulsion systems.
*/
class Default : public PropulsionIntegrator
{
public:
/* === Helper Types === */
/**
* @struct EngineCount
* @brief Helper struct to store the number of engines in the fuselage and wing.
*/
struct EngineCount
{
int fuselage{0}; /**< The number of engines in the fuselage. */
int wing{0}; /**< The number of engines in the wing. */
int empennage{0}; /**< The number of engines in the empennage. */
};
/* === Constructors === */
/**
* @brief Construct a new default propulsion integrator.
* @param configuration The module configuration provided by the user.
* @param aircraft_geometry The aircraft geometry.
* @param n_engines The number of engines (first: n_fuselage, second: n_wing)
*/
Default(
const std::shared_ptr<node> &configuration,
const std::shared_ptr<geometry::Aircraft> &aircraft_geometry,
const EngineCount &n_engines)
: PropulsionIntegrator(configuration, aircraft_geometry), n_engines_{n_engines} {};
/* === Methods === */
/**
* @brief Integrate a turbofan engine with kerosene as fuel.
* @note The engine WILL be modified!
*
* @param engine The engine to integrate.
*/
void operator()(Turbofan<EnergyCarrier::Kerosene> &engine); // NOLINT runtime/references
void operator()(Turbofan<EnergyCarrier::Liquid_Hydrogen>& engine); // NOLINT runtime/references
private:
/* === Methods === */
/**
* @brief Integrate the engine into the wing.
* This method follows the procedure described in \cite Ata10.
* It assumes one main wing which is extruded in global Y direction.
* The number of engines is limited to 2 or 4 per wing.
* @attention The given engine is modified by this method!
* @throws std::runtime_error if the preconditions are not met.
*
* @param engine The engine to integrate.
*/
template <EnergyCarrier EC>
void integrate_into_wing(Turbofan<EC> &engine); // NOLINT runtime/references
template <EnergyCarrier EC>
void integrate_into_fuselage(Turbofan<EC> &engine); // NOLINT runtime/references
template <EnergyCarrier EC>
void integrate_into_empennage(Turbofan<EC> &engine); // NOLINT runtime/references
template <EnergyCarrier EC>
void integrate_into_wing_body(Turbofan<EC> &engine); // NOLINT runtime/references
template <EnergyCarrier EC>
void guess_position(Turbofan<EC> &engine); // NOLINT runtime/references
template <EnergyCarrier EC>
void turbofan_method(Turbofan<EC>& engine); // NOLINT runtime/references
/**
* @brief Calculate the engine span location on the wing
* according to the procedure described in \cite Ata10.
* @attention This always returns positive values! You have to adjust
* the sign according to the wing extrusion direction.
*
* @param width_fuselage [m] The maximum width of the fuselage.
* @param diameter_engine_max [m] The maximum diameter of the engine.
* @param wing_span [m] The absolute span of the wing.
* @param is_outer [-] Whether the position should be calculated for the outer engine.
* @return double [m] The absolute span position of the engine.
*/
[[nodiscard]] auto calculate_span_position(
const double width_fuselage,
const double diameter_engine_max,
const double wing_span,
const bool is_outer) const -> double;
/**
* @brief Select the fuselage from the aircraft geometry.
*
* @param aircraft The aircraft geometry.
* @return geometry::Fuselage The selected fuselage.
* @throws std::runtime_error When the aircraft fuselage configuration is not supported.
*/
[[nodiscard]] auto select_fuselage() -> geometry::Fuselage&;
/**
* @brief Select the vertical tail from the aircraft geometry.
*
* @param aircraft The aircraft geometry.
* @return geometry::Wing The selected empennage surface.
* @throws std::runtime_error When the aircraft empennage configuration is not supported.
*/
[[nodiscard]] auto select_vertical_tail() -> geometry::Wing&;
/**
* @brief Select the wing from the aircraft geometry.
*
* @param aircraft The aircraft geometry.
* @return geometry::Wing The selected wing.
* @throws std::runtime_error When the aircraft wing configuration is not supported.
*/
[[nodiscard]] auto select_wing() -> geometry::Wing&;
/* === Properties === */
const EngineCount n_engines_{}; /** The number of engines in the fuselage and wing. */
EngineCount engines_done{}; /** Keeps track how many engines are already integrated */
std::set<ParentComponent> parents_placed; /** Keeps track of the components where engines are already integrated */
double usershift_x = this->configuration()->at("/module_configuration_file/program_settings/repositioning/shift_x/value");
double usershift_y = this->configuration()->at("/module_configuration_file/program_settings/repositioning/shift_y/value");
double usershift_z = this->configuration()->at("/module_configuration_file/program_settings/repositioning/shift_z/value");
};
}; // namespace integration
}; // namespace design
#endif // SRC_INTEGRATION_DEFAULT_DEFAULT_INTEGRATION_H_