Frame Analysis Example

Analyse a cross-section to be used in frame analysis.

The following example demonstrates how sectionproperties can be used to calculate the cross-section properties required for a frame analysis. Using this method is preferred over executing a geometric and warping analysis as only variables required for a frame analysis are computed. In this example the torsion constant of a rectangular section is calculated for a number of different mesh sizes and the accuracy of the result compared with the time taken to obtain the solution.

# sphinx_gallery_thumbnail_number = 1

import time
import numpy as np
import matplotlib.pyplot as plt
import sectionproperties.pre.library.primitive_sections as sections
from sectionproperties.analysis.section import Section

Create a rectangular section

geometry = sections.rectangular_section(d=100, b=50)

Create a list of mesh sizes to analyse

mesh_sizes = [3, 4, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100, 200]
j_calc = []  # list to store torsion constants
t_calc = []  # list to store computation times

Loop through mesh sizes

for mesh_size in mesh_sizes:
    geometry.create_mesh(mesh_sizes=[mesh_size])  # create mesh
    section = Section(geometry)  # create a Section object
    start_time = time.time()  # start timing
    # calculate the frame properties
    (_, _, _, _, j, _) = section.calculate_frame_properties()
    t = time.time() - start_time  # stop timing
    t_calc.append(t)  # save the time
    j_calc.append(j)  # save the torsion constant
    # print the result
    str = "Mesh Size: {0}; ".format(mesh_size)
    str += "Solution Time {0:.5f} s; ".format(t)
    str += "Torsion Constant: {0:.12e}".format(j)
    print(str)
Mesh Size: 3; Solution Time 6.62067 s; Torsion Constant: 2.858525191518e+06
Mesh Size: 4; Solution Time 4.81756 s; Torsion Constant: 2.858529348617e+06
Mesh Size: 5; Solution Time 3.83594 s; Torsion Constant: 2.858533994778e+06
Mesh Size: 10; Solution Time 1.87892 s; Torsion Constant: 2.858564308063e+06
Mesh Size: 15; Solution Time 1.20050 s; Torsion Constant: 2.858628499542e+06
Mesh Size: 20; Solution Time 0.88515 s; Torsion Constant: 2.858670496343e+06
Mesh Size: 25; Solution Time 0.71865 s; Torsion Constant: 2.858748138885e+06
Mesh Size: 30; Solution Time 0.59589 s; Torsion Constant: 2.858865014806e+06
Mesh Size: 40; Solution Time 0.45969 s; Torsion Constant: 2.858947255775e+06
Mesh Size: 50; Solution Time 0.38113 s; Torsion Constant: 2.859438375764e+06
Mesh Size: 75; Solution Time 0.24807 s; Torsion Constant: 2.860241467603e+06
Mesh Size: 100; Solution Time 0.17823 s; Torsion Constant: 2.861326245766e+06
Mesh Size: 200; Solution Time 0.09177 s; Torsion Constant: 2.869013885610e+06

Compute the error, assuming that the finest mesh (index 0) gives the ‘correct’ value

correct_val = j_calc[0]
j_np = np.array(j_calc)
error_vals = (j_calc - correct_val) / j_calc * 100

Produce a plot of the accuracy of the torsion constant with computation time

plt.loglog(t_calc[1:], error_vals[1:], "kx-")
plt.xlabel("Solver Time [s]")
plt.ylabel("Torsion Constant Error [%]")
plt.show()
08 frame

Total running time of the script: ( 0 minutes 23.172 seconds)

Gallery generated by Sphinx-Gallery