Skip to content

Commit 6156775

Browse files
authored
Merge pull request #184 from Czarified/numpy_work
Numpy work
2 parents f47a561 + 656ee94 commit 6156775

File tree

5 files changed

+87
-66
lines changed

5 files changed

+87
-66
lines changed

poetry.lock

Lines changed: 58 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "hyperstruct"
3-
version = "0.0.9"
3+
version = "0.0.10"
44
description = "Hyperstruct"
55
authors = ["Benjamin Crews <[email protected]>"]
66
license = "MIT"
@@ -18,7 +18,7 @@ Changelog = "https://github.com/czarified/hyperstruct/releases"
1818
[tool.poetry.dependencies]
1919
python = ">=3.10, <4.0"
2020
click = ">=8.0.1, <9.0"
21-
numpy = ">=1.26.4, <2.0"
21+
numpy = ">=2.0, <3.0"
2222
scipy = ">=1.14.1, <2.0"
2323
matplotlib = ">=3.10.1, <4.0"
2424
pytest-check = ">=2.5.3, <3.0"
@@ -81,7 +81,7 @@ pretty = true
8181
show_column_numbers = true
8282
show_error_codes = true
8383
show_error_context = true
84-
disable_error_code = ["import-untyped"]
84+
disable_error_code = ["import-untyped", "assignment", "operator", "index", "misc"]
8585

8686
[build-system]
8787
requires = ["poetry-core>=2.0.0"]

src/hyperstruct/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import matplotlib.pyplot as plt
1010
import numpy as np
11+
from matplotlib.axes import Axes
12+
from matplotlib.figure import Figure
1113
from matplotlib.patches import Circle
1214
from matplotlib.patches import Ellipse
1315
from matplotlib.patches import FancyBboxPatch
@@ -249,7 +251,7 @@ def curvature(self) -> float:
249251

250252
def show(
251253
self, coords: Optional[List[Tuple[float, float]]] = None, display: bool = True
252-
) -> Tuple:
254+
) -> Tuple[Figure, Axes]:
253255
"""Plot the station shape for a visual check.
254256
255257
This method just uses matplotlib to draw the shape on a plot.

src/hyperstruct/fuselage.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ def stiffener_spacing(
13391339

13401340
return (t_s, t_bar, d, H)
13411341

1342-
def synthesis(self):
1342+
def synthesis(self) -> None:
13431343
"""Run the sizing routine.
13441344
13451345
Component weight is obtained by multiplying area, effective thickness,
@@ -1395,7 +1395,7 @@ class MajorFrame(Component):
13951395
fs_loc: float
13961396
"""Fuselage Station location (e.g. 150in from origin)."""
13971397

1398-
loads: ArrayLike
1398+
loads: Any
13991399
"""The loads list contains all external loads applied on this frame.
14001400
[
14011401
[y, z, V, H, M],
@@ -1512,7 +1512,7 @@ def show(self, show_coords: bool = False, save: bool = False) -> None:
15121512

15131513
_ = ax.set_xlabel("Butt Line, $BL$", fontfamily="serif")
15141514
_ = ax.set_ylabel("Water Line, $WL$", fontfamily="serif")
1515-
_ = ax.tick_params(axis="both", which="both", direction="in")
1515+
ax.tick_params(axis="both", which="both", direction="in")
15161516
_ = ax.set_title(f"FS{self.fs_loc} Frame Applied Loads", fontfamily="serif")
15171517
_ = ax.legend(
15181518
handles=[
@@ -1579,8 +1579,8 @@ def synthesis(self, num: int = 60) -> None:
15791579
self.weight = self.results[:, 0].sum()
15801580

15811581
def geometry_cuts(
1582-
self, num, debug: bool = False
1583-
) -> Tuple[float, ArrayLike, ArrayLike]:
1582+
self, num: int, debug: bool = False
1583+
) -> Tuple[float, ArrayLike, pd.DataFrame]:
15841584
"""Calculate the frame node coordinates for all synthesis cuts. [FRMND1].
15851585
15861586
The frame synthesis cut coordinates are based on equal-length segments
@@ -1628,7 +1628,7 @@ def geometry_cuts(
16281628
# iteration step segment length.
16291629
# Initial dsl_k doesn't matter.
16301630

1631-
def objective(phi, *args) -> float:
1631+
def objective(phi: float, *args: Any) -> float:
16321632
"""An objective local function to minimize.
16331633
16341634
Args:
@@ -1643,7 +1643,7 @@ def objective(phi, *args) -> float:
16431643
del_y = y_k - y_i
16441644
del_z = z_k - z_i
16451645
dls_k = np.sqrt(del_y**2 + del_z**2)
1646-
return abs(dls - dls_k)
1646+
return float(abs(dls - dls_k))
16471647

16481648
solution = minimize_scalar(
16491649
objective,
@@ -1787,7 +1787,7 @@ def cut_loads(
17871787
area = np.sum(da_j)
17881788

17891789
# The shear flow the cut due to the unbalanced forces is:
1790-
def __local_shear_flow(i) -> float:
1790+
def __local_shear_flow(i: int) -> float:
17911791
"""Local function for the shear flow iteration."""
17921792
qi_prime_1 = 0.0
17931793
for n in range(2, i + 1):
@@ -1870,9 +1870,9 @@ def frame_loads(
18701870
self,
18711871
dls: float,
18721872
zzf: float,
1873-
inertias: ArrayLike,
1874-
cut_geom: ArrayLike,
1875-
) -> ArrayLike:
1873+
inertias: Any,
1874+
cut_geom: pd.DataFrame,
1875+
) -> Any:
18761876
"""This method calculates the final redundant loads. [FRMLD.2].
18771877
18781878
Take section cut loads from each section around the perimeter and build
@@ -1885,7 +1885,7 @@ def frame_loads(
18851885
cut_geom: 2D Array of section geometry
18861886
18871887
Returns:
1888-
ArrayLike: Segment centroidal net internal loads
1888+
Segment centroidal net internal loads
18891889
"""
18901890
ioz_s, ioy_s, ioz_f, ioy_f = inertias
18911891
# We gotta do some silly type conversions here.
@@ -1895,14 +1895,14 @@ def frame_loads(
18951895
dlsp_j = cut_geom["DLSP_j"]
18961896
dlsp = cut_geom["DLS_j"]
18971897
pp = np.sum(dlsp_j)
1898-
y_pb: ArrayLike = np.array(cut_geom["y_pbj"])
1899-
z_pb: ArrayLike = np.array(cut_geom["z_pbj"])
1900-
y: ArrayLike = np.array(cut_geom["y_i"])
1901-
z: ArrayLike = np.array(cut_geom["z_i"])
1902-
y_b: ArrayLike = np.array(cut_geom["y_bj"])
1903-
z_b: ArrayLike = np.array(cut_geom["z_bj"])
1904-
y_p: ArrayLike = np.array(cut_geom["y_pi"])
1905-
z_p: ArrayLike = np.array(cut_geom["z_pi"])
1898+
y_pb: Any = np.array(cut_geom["y_pbj"])
1899+
z_pb: Any = np.array(cut_geom["z_pbj"])
1900+
y: Any = np.array(cut_geom["y_i"])
1901+
z: Any = np.array(cut_geom["z_i"])
1902+
y_b: Any = np.array(cut_geom["y_bj"])
1903+
z_b: Any = np.array(cut_geom["z_bj"])
1904+
y_p: Any = np.array(cut_geom["y_pi"])
1905+
z_p: Any = np.array(cut_geom["z_pi"])
19061906
# theta: ArrayLike = cut_geom["theta_i"]
19071907
jj = len(cut_geom)
19081908

@@ -1914,8 +1914,8 @@ def frame_loads(
19141914
theta=row["theta_i"],
19151915
dls=row["DLS_j"],
19161916
zzf=zzf,
1917-
ioy_s=ioy_s,
1918-
ioz_s=ioz_s,
1917+
ioy_s=float(ioy_s),
1918+
ioz_s=float(ioz_s),
19191919
y=y,
19201920
z=z,
19211921
y_b=y_b,

0 commit comments

Comments
 (0)