如何以特定方式(门户框架 - 力矩图)创建绘图函数?
我是机械工程专业的学生,我正在尝试在Python中创建一个脚本。我的代码中缺少的是如何定位力矩功能以像门户框架一样对齐。
mpilar1是FISRT列(右侧LEF)的力矩函数。
MASNA1是FISRT梁(右图)的力矩函数。
MASNA2是第二光束(右图)的力矩函数。
mpilar2是第二列的力矩函数(右图向右)。
代码:
import math as mt
import numpy as np
import warnings
import matplotlib.pyplot as plt
warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
#Definir parâmetros do pavilhão
v = 20 #(Vão em metros)
h = 6 #("Altura do pilar em metros:")
ht = 8 #("Altura total metros:")
alfa = (mt.atan((int(ht)-int(h))/(int(v)/2)))*180/((mt.pi))
print("Ângulo da vertente:", round(alfa, 1), "º")
lasna = ((v/2) ** 2 + (ht-h) ** 2) ** 0.5
print("Comprimento de cada asna: ", round(lasna, 2), "m")
h1 = np.arange(0, h+1, 1)
ha1 = np.arange(0, lasna, 0.1)
def draw_line():
x_number_list = [0, 0, (v/2), v, v]
y_number_list = [0, h, ht, h, 0]
plt.plot(x_number_list, y_number_list, linewidth=3)
plt.title("Pórtico", fontsize=15)
plt.xlabel("Vão (m)", fontsize=10)
plt.ylabel("Altura (m)", fontsize=10)
plt.tick_params(axis='both', labelsize=9)
plt.show()
if __name__ == '__main__':
draw_line()
Mpilar1 = 1500 * h1 ** 2 + 350 * h1
Masna1 = 300 * ha1 ** 2 + 15 * ha1
Masna2 = 200 * ha1 ** 2 + 15 * ha1
Mpilar2 = 1400 * h1 ** 2 + 10 * h1
plt.plot(h1, Mpilar1)
plt.plot(ha1, Masna1)
plt.plot(ha1, Masna2)
plt.plot(h1, Mpilar2)
I´m a mechanical engineering student and I'm trying to create a script for moment diagram in Python. What is missing in my code is how to orientate the moment functions in order to be aligned like the portal frame.
Mpilar1 is the moment function for the fisrt column (lef to right).
Masna1 is the moment function for the fisrt beam (lef to right).
Masna2 is the moment function for the second beam (lef to right).
Mpilar2 is the moment function for the second column (lef to right).
Code:
import math as mt
import numpy as np
import warnings
import matplotlib.pyplot as plt
warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
#Definir parâmetros do pavilhão
v = 20 #(Vão em metros)
h = 6 #("Altura do pilar em metros:")
ht = 8 #("Altura total metros:")
alfa = (mt.atan((int(ht)-int(h))/(int(v)/2)))*180/((mt.pi))
print("Ângulo da vertente:", round(alfa, 1), "º")
lasna = ((v/2) ** 2 + (ht-h) ** 2) ** 0.5
print("Comprimento de cada asna: ", round(lasna, 2), "m")
h1 = np.arange(0, h+1, 1)
ha1 = np.arange(0, lasna, 0.1)
def draw_line():
x_number_list = [0, 0, (v/2), v, v]
y_number_list = [0, h, ht, h, 0]
plt.plot(x_number_list, y_number_list, linewidth=3)
plt.title("Pórtico", fontsize=15)
plt.xlabel("Vão (m)", fontsize=10)
plt.ylabel("Altura (m)", fontsize=10)
plt.tick_params(axis='both', labelsize=9)
plt.show()
if __name__ == '__main__':
draw_line()
Mpilar1 = 1500 * h1 ** 2 + 350 * h1
Masna1 = 300 * ha1 ** 2 + 15 * ha1
Masna2 = 200 * ha1 ** 2 + 15 * ha1
Mpilar2 = 1400 * h1 ** 2 + 10 * h1
plt.plot(h1, Mpilar1)
plt.plot(ha1, Masna1)
plt.plot(ha1, Masna2)
plt.plot(h1, Mpilar2)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在代表曲线的点上使用转换矩阵。特别是,您必须使用Roto-Translation矩阵旋转并将曲线转换为正确的位置和方向,并且您可能必须应用一个镜像矩阵才能根据您的约定将矩对齐。
请注意,我的结构工程日已经消失了,所以我不记得惯例可以适当地定向时刻。作为练习,这留给了您。
上面的代码中有几件事要注意:
让我们考虑
points1 = np.stack([[h1,mpilar1 / max(mpilar1),np.ones_like(h1) ])
。它创建了一个3xn的坐标矩阵。第一行是x坐标,h1
。第二行是当下的y坐标,mpilar1 / max(mpilar1)< / code>(请注意,我已经对其进行了付出的以适合图表)。第三行是1,能够应用翻译矩阵是一个诀窍。在绘图命令中,我们将仅使用第一行和第二行(x和y坐标)。
points4 = np.matmul(np.matmul(r(20,6,alfa_rad),my),points4)
在这里,我首先反映了有关y轴的点,然后我应用了一个旋转和翻译。您将必须播放才能适当地定向!You have to use transformation matrices over the points representing your curves. In particular, you'd have to use a roto-translation matrix to rotate and translate a curve to the correct position and orientation, and you might have to apply a mirror matrix to get the moments aligned according to your convention.
Please note that my structural engineering days are loooong gone, so I don't remember the convention to properly orient the moments. That's left to you as an exercise.
There are a few things to note in the above code:
let's consider
points1 = np.stack([h1, Mpilar1 / max(Mpilar1), np.ones_like(h1)])
. It creates a 3xn matrix of coordinates. The first row is the x-coordinates,h1
. The second row is the y-coordinates of the moment,Mpilar1 / max(Mpilar1)
(note that I have adimentionalized it in order to fit the chart). The third row is 1, and it is a trick to be able to apply a translation matrix. In the plot commands, we will only use the first and second rows (the x and y coordinates).points4 = np.matmul(np.matmul(R(20, 6, alfa_rad), My), points4)
here I first mirrored the points about the y-axis, then I applied a rotation and translation. You will have to play in order to properly orient the moment!该解决方案有效,但是在这种情况下,我无法具有正确的力矩图。
代码:
The solution works, but in this case I can´t have the correct moment diagram.
Code: