!pip install sectionproperties
import matplotlib.pyplot as plt
import numpy as np
from sectionproperties.pre.library import rectangular_section
from sectionproperties.pre.library import circular_section
from sectionproperties.analysis import Section
geom = rectangular_section(d=500, b=300)
geom.create_mesh(mesh_sizes=[200])
sec = Section(geometry=geom)
sec.plot_mesh(materials=False)
sec.calculate_geometric_properties()
sec.calculate_warping_properties()
case1 = sec.calculate_stress(mxx=5e6, vy=-10e3, mzz=0)
Calculation fo Normal Stress
# bending normal stress
case1.plot_stress(stress="m_zz")
mxx=5e6; b=300; d=500; Ixx=b*d**3/12;
sigma = mxx/Ixx*(d/2)
print(sigma)
# 1. 좌표 범위 설정 (예: -5에서 5까지 100등분)
x = np.linspace(-b/2, b/2, 100)
y = np.linspace(-d/2, d/2, 100)
# 2. 격자(Grid) 만들기 (핵심!)
X, Y = np.meshgrid(x, y)
# 3. 식 대입
sigma = mxx/Ixx*(Y)*(X/X)
# 4. 맵 그리기
plt.pcolormesh(X, Y, sigma, cmap='bwr')
plt.colorbar(label='Value')
plt.axis('equal')
plt.show()
Calculation fo Shear Stress
# shear stress
case1.plot_stress(stress="v_zxy")
V=10e3; b=300; d=500; Ixx=b*d**3/12; Q=b*d/2*d/4
tau = V*Q/(Ixx*b)
print(tau)
# 1. 좌표 범위 설정 (예: -5에서 5까지 100등분)
x = np.linspace(-b/2, b/2, 100)
y = np.linspace(-d/2, d/2, 100)
# 2. 격자(Grid) 만들기 (핵심!)
X, Y = np.meshgrid(x, y)
# 3. 식 대입
tau = V*(b/2*(d**2/4-Y**2))/(Ixx*b)*(X/X)
# 4. 맵 그리기
plt.pcolormesh(X, Y, tau, cmap='Reds')
plt.colorbar(label='Value')
plt.axis('equal')
plt.show()
Calculation of Torsional Stress
geom = circular_section(d=200, n=64)
geom.create_mesh(mesh_sizes=[100])
sec = Section(geometry=geom)
sec.plot_mesh(materials=False)
sec.calculate_geometric_properties()
sec.calculate_warping_properties()
case1 = sec.calculate_stress(mxx=0, vy=0, mzz=3e6)
# torsion stress vectors
case1.plot_stress(stress="mzz_zxy")
d=200; T=3e6; r=d/2
Ip=np.pi*r**4/2
tau_max = T/Ip*(d/2)
print(tau_max)
# r: 반지름 (0부터 d/2까지)
theta = np.linspace(0, 2 * np.pi, 100)
r = np.linspace(0, d/2, 100)
Theta, R = np.meshgrid(theta, r)
# 2. 식 대입
tau = T/Ip*(R)*(Theta/Theta)
# 3. 극좌표 그래프 그리기
plt.figure(figsize=(6, 6))
ax = plt.subplot(1, 1, 1, projection='polar')
mesh = plt.pcolormesh(Theta, R, tau, cmap='Reds')
plt.colorbar(label='Value')
plt.show()