Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Type overloads for improved typing #303

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions anastruct/fem/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ def __init__(
self.shear_force: Optional[np.ndarray] = None
self.axial_force: Optional[np.ndarray] = None
self.deflection: Optional[np.ndarray] = None
self.total_deflection: Optional[np.ndarray] = None
self.extension: Optional[np.ndarray] = None
self.max_deflection = None
self.max_extension = None
self.max_deflection: Optional[float] = None
self.max_total_deflection: Optional[float] = None
self.max_extension: Optional[float] = None
self.nodes_plastic: List[bool] = [False, False]
self.compile_constitutive_matrix(initial=True)
self.compile_stiffness_matrix()
Expand Down
9 changes: 3 additions & 6 deletions anastruct/fem/plotter/mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,13 +1287,10 @@ def displacements( # pylint: disable=arguments-renamed
max_displacement = max(
map(
lambda el: (
max(
abs(el.node_1.ux),
abs(el.node_1.uy),
el.max_deflection or 0,
np.sqrt(
(el.max_extension or 0) ** 2
+ (el.max_total_deflection or 0) ** 2
)
if el.type == "general"
else 0
),
self.system.element_map.values(),
)
Expand Down
7 changes: 3 additions & 4 deletions anastruct/fem/plotter/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ def displacements(
max_displacement = max(
map(
lambda el: (
max(
abs(el.node_1.ux), abs(el.node_1.uy), el.max_deflection or 0
np.sqrt(
(el.max_extension or 0) ** 2
+ (el.max_total_deflection or 0) ** 2
)
if el.type == "general"
else 0
),
self.system.element_map.values(),
)
Expand Down
39 changes: 32 additions & 7 deletions anastruct/fem/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ def determine_displacements(element: "Element", con: int) -> None:
w2 = w2[::-1] - lx[::-1] * np.tan(alpha2)

element.deflection = -(w1 + w2) / 2.0
assert element.deflection is not None
element.max_deflection = np.max(np.abs(element.deflection))
else: # truss element has no bending
element.deflection = np.zeros(con)

assert element.deflection is not None
element.max_deflection = np.max(np.abs(element.deflection))

# Extension
assert element.axial_force is not None
Expand All @@ -300,8 +303,30 @@ def determine_displacements(element: "Element", con: int) -> None:
element.extension = -1 * (u1 + u2) / 2.0
element.max_extension = np.max(np.abs(element.extension))

# assert element.N_1 is not None
# assert element.N_2 is not None
# u = 0.5 * (element.N_1 + element.N_2) / element.EA * element.l
# du = u / con
# element.extension = du * (np.arange(con) + 1)
# Total deflection
ux1 = element.node_1.ux
uz1 = -element.node_1.uy
ux2 = element.node_2.ux
uz2 = -element.node_2.uy

if element.type == "general":
n = len(element.deflection)
x_val = np.linspace(ux1, ux2, n)
y_val = np.linspace(uz1, uz2, n)

element.total_deflection = (
element.deflection
+ x_val * math.sin(element.angle)
+ y_val * math.cos(element.angle)
)

else: # truss element has no bending
n = len(element.extension)
x_val = np.linspace(ux1, ux2, n)
y_val = np.linspace(uz1, uz2, n)

element.total_deflection = x_val * math.sin(
element.angle
) + y_val * math.cos(element.angle)

element.max_total_deflection = np.max(np.abs(element.total_deflection))
Loading
Loading