# This file is part of FAST-OAD_CS23-HE : A framework for rapid Overall Aircraft Design of Hybrid
# Electric Aircraft.
# Copyright (C) 2022 ISAE-SUPAERO
# This test file does not test the validity of the formulas used for the sizing, rather it check
# that the Sizing components outputs what is expect of them i.e: mass, CG, Cd0, ...
from fastoad.openmdao.problem import AutoUnitsDefaultGroup
from fastga_he.powertrain_builder import resources
import fastga_he.models.propulsion.components as he_comp
from tests.testing_utilities import VariableListLocal
UNIQUE_STRING = "ca_part_sur_un_depart"
[docs]
def test_all_slipstream_components_exist():
# Component existing mean that they are imported in the right place (the __init__ of the
# components folder) and that it can be created
for component_om_name in resources.DICTIONARY_CN:
slipstream_group_name = "Slipstream" + resources.DICTIONARY_CN[component_om_name]
try:
class_to_test = he_comp.__dict__[slipstream_group_name]()
assert class_to_test
except AttributeError:
assert False
[docs]
def test_all_components_output_required_value():
# Originally I planned on doing each delta on their own but since it takes so much bloody
# time to list output, we will do everything at once
for component_om_name in resources.DICTIONARY_CN:
slipstream_group_name = "Slipstream" + resources.DICTIONARY_CN[component_om_name]
slipstream_group_id = resources.DICTIONARY_CN_ID[component_om_name]
component = he_comp.__dict__[slipstream_group_name]()
# Need a unique string for the rest of the test
component.options[slipstream_group_id] = UNIQUE_STRING
new_component = AutoUnitsDefaultGroup()
new_component.add_subsystem("system", component, promotes=["*"])
component = new_component
variables = VariableListLocal.from_system(component)
input_and_output_value = []
for var in variables:
input_and_output_value.append(var.name)
# Because there are a lot of IVC which makes the delta's appear as inputs
assert "delta_Cl" in input_and_output_value
assert "delta_Cd" in input_and_output_value
assert "delta_Cm" in input_and_output_value
[docs]
def test_all_slipstream_components_are_imported():
imported_components = list(he_comp.__dict__.keys())
for component_om_name in resources.DICTIONARY_CN:
slipstream_group_name = "Slipstream" + resources.DICTIONARY_CN[component_om_name]
assert slipstream_group_name in imported_components
[docs]
def test_all_imported_slisptream_components_are_defined():
# In practice this covers the tests above
imported_components = list(he_comp.__dict__.keys())
imported_slipstream_components = []
for imported_component in imported_components:
if "Slipstream" in imported_component:
imported_slipstream_components.append(imported_component)
defined_components = []
for component_om_name in resources.DICTIONARY_CN:
defined_components.append("Slipstream" + resources.DICTIONARY_CN[component_om_name])
assert set(imported_slipstream_components) == set(defined_components)