Skip to content

Commit 8079cfe

Browse files
Merge pull request #87 from fast-aircraft-design/increased_MDA_robustness
Increased mda robustness by allowing k_sfc extrapolation and addition of warning for negative chords due to unfeasible wing geometry
2 parents 269d558 + 7d7ffea commit 8079cfe

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

src/fastoad_cs25/models/geometry/geom_components/wing/components/compute_l1_l4.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616

1717
import numpy as np
1818
import openmdao.api as om
19+
from fastoad.api import ValidityDomainChecker
1920

2021

22+
@ValidityDomainChecker(
23+
{"data:geometry:wing:root:virtual_chord": (0.0, None)},
24+
)
2125
class ComputeL1AndL4Wing(om.ExplicitComponent):
2226
# TODO: Document equations. Cite sources
2327
"""Wing chords (l1 and l4) estimation"""

src/fastoad_cs25/models/geometry/geom_components/wing/components/tests/test_wing_geom_comps.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,29 @@ def test_geometry_wing_l1_l4():
8484
assert wing_l4 == pytest.approx(1.882, abs=1e-3)
8585

8686

87+
def test_activation_warning_for_negative_l1(caplog):
88+
"""Test if a warning is generated when an unfeasible wing geometry is input and results
89+
in a negative chord value. Unfeasible geometries concerned especially wings with high aspect
90+
ratio, far lateral kink, and high sweep, low inner-kink trailing sweep."""
91+
92+
input_vars = om.IndepVarComp()
93+
input_vars.add_output("data:geometry:wing:area", 50, units="m**2")
94+
input_vars.add_output("data:geometry:wing:sweep_25", 27.0, units="deg")
95+
input_vars.add_output("data:geometry:wing:virtual_taper_ratio", 0.9, units=None)
96+
input_vars.add_output("data:geometry:wing:kink:y", 12, units="m")
97+
input_vars.add_output("data:geometry:wing:root:y", 1.96, units="m")
98+
input_vars.add_output("data:geometry:wing:tip:y", 15.8015, units="m")
99+
100+
problem = run_system(ComputeL1AndL4Wing(), input_vars)
101+
wing_l1 = problem["data:geometry:wing:root:virtual_chord"]
102+
103+
# Check for the core part of the warning message
104+
expected_core = (
105+
f'"data:geometry:wing:root:virtual_chord" out of bound: value [{wing_l1[0]:.8f}] m'
106+
)
107+
assert expected_core in caplog.text, f"Expected warning not found in logs. Logs: {caplog.text}"
108+
109+
87110
def test_geometry_wing_l2_l3():
88111
"""Tests computation of the wing chords (l2 and l3)"""
89112

src/fastoad_cs25/models/propulsion/fuel_propulsion/rubber_engine/rubber_engine.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def compute_flight_points(self, flight_points: Union[FlightPoint, pd.DataFrame])
129129
k_sfc_alt = interp1d(
130130
[-1000.0, 0.0, 13106.4, 20000.0],
131131
np.hstack((self.k_sfc_sl, self.k_sfc_sl, self.k_sfc_cr, self.k_sfc_cr)),
132+
bounds_error=False,
133+
fill_value=(self.k_sfc_sl, self.k_sfc_cr),
132134
)
133135
k_sfc = k_sfc_alt(flight_points.altitude)
134136

src/fastoad_cs25/models/propulsion/fuel_propulsion/rubber_engine/tests/test_rubber_engine.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ def test_compute_flight_points():
4343
np.testing.assert_allclose(flight_point.thrust_rate, 0.5, rtol=1e-4)
4444
np.testing.assert_allclose(flight_point.sfc, 1.3496e-5, rtol=1e-4)
4545

46+
flight_point = FlightPoint(
47+
mach=0, altitude=-3000, engine_setting=EngineSetting.TAKEOFF, thrust_rate=0.8
48+
) # with altitude below boundaries of k_sfc interpolation
49+
engine.compute_flight_points(flight_point)
50+
np.testing.assert_allclose(flight_point.sfc, 1.02479e-05, rtol=1e-4)
51+
52+
flight_point = FlightPoint(
53+
mach=0.8, altitude=30000, engine_setting=EngineSetting.CRUISE.value, thrust_rate=0.7
54+
) # with altitude above boundaries of k_sfc interpolation
55+
engine.compute_flight_points(flight_point)
56+
np.testing.assert_allclose(flight_point.sfc, 1.42638e-05, rtol=1e-4)
57+
4658
# Test full arrays
4759
# 2D arrays are used, where first line is for thrust rates, and second line
4860
# is for thrust values.

0 commit comments

Comments
 (0)