diff --git a/src/hyperstruct/__main__.py b/src/hyperstruct/__main__.py index abd4007..906b00a 100644 --- a/src/hyperstruct/__main__.py +++ b/src/hyperstruct/__main__.py @@ -1,8 +1,13 @@ """Command-line interface.""" +from importlib.metadata import version + import click +__version__ = version("hyperstruct") + + @click.command() @click.version_option() def main() -> None: diff --git a/src/hyperstruct/fuselage.py b/src/hyperstruct/fuselage.py index 52da307..3df23f5 100644 --- a/src/hyperstruct/fuselage.py +++ b/src/hyperstruct/fuselage.py @@ -121,7 +121,7 @@ def field_thickness_block_shear(self) -> float: else: t_c = self.q / (self.c_r * self.material.F_su) - return t_c + return float(t_c) def field_thickness_postbuckled(self, alpha: float = 45) -> float: """Field thickness based on critical shear flow. @@ -177,9 +177,9 @@ def land_thickness_net_section(self) -> float: On unmilled panels, the land thickness is simply equivalent to the field thickness. """ if not self.milled: - return self.t_c + return float(self.t_c) else: - return self.q / (self.c_r * self.material.F_su) + return float(self.q / (self.c_r * self.material.F_su)) def thickness_pressure(self, F_allow: Any = None) -> Tuple[float, float]: """Thicknesses based on cover pressure. diff --git a/tests/test_fuselage.py b/tests/test_fuselage.py new file mode 100644 index 0000000..de36b21 --- /dev/null +++ b/tests/test_fuselage.py @@ -0,0 +1,62 @@ +"""Test cases for the fuselage module.""" + +import pytest + +from hyperstruct import Material +from hyperstruct.fuselage import Cover + + +@pytest.fixture +def aluminum() -> Material: + """Some basic aluminum.""" + material = Material( + E=10.5e6, + E_c=10.6e6, + nu=0.33, + F_tu=64, + F_ty=42.1, + F_cy=48, + F_su=41, + F_bru=104, + F_bry=89, + F_en=20, + db_r=116, + ) + return material + + +@pytest.fixture +def unmilled_cover(aluminum: Material) -> Cover: + """Build a Cover component.""" + component = Cover( + material=aluminum, milled=False, L=30, D=20, R=1, RC=25, V=420.0, I=69.0, Q=69.0 + ) + return component + + +def test_unmilled_shear_and_net(unmilled_cover: Cover) -> None: + """Test an unmilled cover.""" + t_c = unmilled_cover.field_thickness_block_shear() + t_l = unmilled_cover.land_thickness_net_section() + assert isinstance(t_l, float) + assert isinstance(t_c, float) + + +def test_unmilled_pressure(unmilled_cover: Cover) -> None: + """Test an unmilled cover.""" + t_l, t_c = unmilled_cover.thickness_pressure() + assert isinstance(t_l, float) + assert isinstance(t_c, float) + + +def test_unmilled_flutter(unmilled_cover: Cover) -> None: + """Test an unmilled cover.""" + t_c = unmilled_cover.panel_flutter(mach=1.3, altitude=5000) + assert isinstance(t_c, float) + + +def test_unmilled_acoustic(unmilled_cover: Cover) -> None: + """Test an unmilled cover.""" + t_l, t_c = unmilled_cover.acoustic_fatigue() + assert isinstance(t_l, float) + assert isinstance(t_c, float)