Skip to content

Commit

Permalink
Tests and __version__.
Browse files Browse the repository at this point in the history
Add the hyperstruct.__version__ attribute with importlib.

Add some initial tests on the fuselage Cover. It's immediately obvious that the panel flutter routine isn't working as expected. Sometimes the result can be complex instead of real.
  • Loading branch information
Czarified committed May 14, 2024
1 parent a881e37 commit 0b47f8d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/hyperstruct/__main__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/hyperstruct/fuselage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
62 changes: 62 additions & 0 deletions tests/test_fuselage.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 0b47f8d

Please sign in to comment.