Note
Click here to download the full example code
Torsion Constant of a RectangleΒΆ
Plot the variation of the torsion constant with aspect ratio of a rectangle section.
In this example, the aspect ratio of a rectangular section is varied whilst keeping a constant cross-sectional area and the torsion constant calculated. The variation of the torsion constant with the aspect ratio is then plotted.
# sphinx_gallery_thumbnail_number = 1
import numpy as np
import matplotlib.pyplot as plt
import sectionproperties.pre.library.primitive_sections as sections
from sectionproperties.analysis.section import Section
Rectangle dimensions
d_list = []
b_list = np.linspace(0.2, 1, 20)
j_list = [] # list holding torsion constant results
Number of elements for each analysis
n = 100
Loop through all the widths
for b in b_list:
# calculate d assuming area = 1
d = 1 / b
d_list.append(d)
# compute mesh size
ms = d * b / n
# perform a warping analysis on rectangle
geometry = sections.rectangular_section(d=d, b=b)
geometry.create_mesh(mesh_sizes=[ms])
section = Section(geometry)
section.calculate_geometric_properties()
section.calculate_warping_properties()
# get the torsion constant
j = section.get_j()
print("d/b = {0:.3f}; J = {1:.5e}".format(d / b, j))
j_list.append(j)
d/b = 25.000; J = 1.30315e-02
d/b = 17.060; J = 1.88338e-02
d/b = 12.380; J = 2.55717e-02
d/b = 9.391; J = 3.31309e-02
d/b = 7.367; J = 4.14010e-02
d/b = 5.934; J = 5.02289e-02
d/b = 4.881; J = 5.95117e-02
d/b = 4.086; J = 6.90261e-02
d/b = 3.470; J = 7.86512e-02
d/b = 2.983; J = 8.81645e-02
d/b = 2.593; J = 9.73762e-02
d/b = 2.274; J = 1.06053e-01
d/b = 2.010; J = 1.14042e-01
d/b = 1.790; J = 1.21141e-01
d/b = 1.604; J = 1.27224e-01
d/b = 1.446; J = 1.32194e-01
d/b = 1.310; J = 1.35982e-01
d/b = 1.192; J = 1.38616e-01
d/b = 1.090; J = 1.40125e-01
d/b = 1.000; J = 1.40617e-01
Plot the torsion constant as a function of the aspect ratio
(fig, ax) = plt.subplots()
ax.plot(np.array(d_list) / b_list, j_list, "kx-")
ax.set_xlabel("Aspect Ratio [d/b]")
ax.set_ylabel("Torsion Constant [J]")
ax.set_title("Rectangular Section Torsion Constant")
plt.show()
Total running time of the script: ( 0 minutes 21.878 seconds)