Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 5 additions & 4 deletions PyNite/BeamSegY.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ def moment(self, x, P_delta=False):
P1 = self.P1
w1 = self.w1
w2 = self.w2
delta1 = self.delta1
delta = self.deflection(x)
L = self.Length()

# M = M1 + V1*x + w1*x**2/2 + x**3*(-w1 + w2)/(6*L)
M = -M1 - V1*x - w1*x**2/2 - x**3*(-w1 + w2)/(6*L)

if P_delta == True:
delta1 = self.delta1
delta = self.deflection(x)
M += P1*(delta - delta1)

return M
Expand All @@ -49,12 +49,13 @@ def slope(self, x, P_delta=False):
w1 = self.w1
w2 = self.w2
theta_1 = self.theta1
delta_x = self.deflection(x, P_delta)
delta_1 = self.delta1

L = self.Length()
EI = self.EI

if P_delta == True:
delta_x = self.deflection(x, P_delta)
delta_1 = self.delta1
return theta_1 + (-V1*x**2/2 - w1*x**3/6 + x*(-M1 - P1*delta_1 + P1*delta_x) + x**4*(w1 - w2)/(24*L))/EI
else:
return theta_1 + (-V1*x**2/2 - w1*x**3/6 + x*(-M1) + x**4*(w1 - w2)/(24*L))/EI
Expand Down
19 changes: 12 additions & 7 deletions PyNite/BeamSegZ.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

@author: D. Craig Brinck, SE
"""
from numpy import full

# %%
# A mathematically continuous beam segment
class BeamSegZ():
Expand Down Expand Up @@ -103,17 +105,16 @@ def moment(self, x, P_delta=False):
V1 = self.V1
M1 = self.M1
P1 = self.P1
Px = self.axial(x)
w1 = self.w1
w2 = self.w2
delta_1 = self.delta1
delta_x = self.deflection(x)
L = self.Length()

M = M1 - V1*x - w1*x**2/2 - x**3*(-w1 + w2)/(6*L)

# Include the P-little-delta moment if a P-Delta analysis was run
if P_delta == True:
delta_1 = self.delta1
delta_x = self.deflection(x)
M += P1*(delta_x - delta_1)

# Return the computed moment
Expand All @@ -129,14 +130,18 @@ def axial(self, x):

return P1 + (p2 - p1)/(2*L)*x**2 + p1*x

def Torsion(self):
def Torsion(self, x = 0):
"""
Returns the torsional moment in the segment.
"""

# The torsional moment is constant across the segment
# This can be updated in the future for distributed torsional forces
return self.T1

if isinstance(x, (int, float)):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this change is doing. Can you provide some comments to clarify?

Copy link
Contributor Author

@bjhowie bjhowie Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for checking whether 'x' is a number or not is that these segment result functions can now be given an 'x' value that is actually an array of x values. The calling function expects the returned value to be an array of length equal to the input array of x values. For most functions, the returned value is calculated as a function of the input 'x' value which means the result is automatically equal in length to to 'x'. As the torsion is not calculated as a function of 'x', we need to manually check if 'x' is an array, and if so, return an array of equal length.

I am going to update these functions with type annotations, as a reminder in future that the function can accept either a number or an array of numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually scratch that last point. I'm not familiar with type annotations prior to python 3.10, which we would need to support. There is a broader conversation to be had there.

return self.T1
else:
return full(len(x), self.T1)

def slope(self, x, P_delta=False):
"""Returns the slope of the elastic curve at any point `x` along the segment.
Expand All @@ -154,8 +159,6 @@ def slope(self, x, P_delta=False):
P1 = self.P1
w1 = self.w1
w2 = self.w2
delta_1 = self.delta1
delta_x = self.deflection(x, P_delta)
theta_1 = self.theta1
L = self.Length()
EI = self.EI
Expand All @@ -164,6 +167,8 @@ def slope(self, x, P_delta=False):
theta_x = theta_1 - (-V1*x**2/2 - w1*x**3/6 + x*M1 + x**4*(w1 - w2)/(24*L))/EI

if P_delta == True:
delta_1 = self.delta1
delta_x = self.deflection(x, P_delta)
theta_x -= x*(-P1*delta_1 + P1*delta_x)/EI

# TODO: This is an old equation left for reference. Delete it after the new equation has been proved over time.
Expand Down
Loading
Loading