import sectionproperties.pre.sections as sections
from sectionproperties.analysis.cross_section import CrossSection

# create a 50 diameter circle discretised by 64 points
geometry = sections.CircularSection(d=50, n=64)
geometry.plot_geometry()  # plot the geometry

# create a mesh with a mesh size of 2.5
mesh = geometry.create_mesh(mesh_sizes=[2.5])

section = CrossSection(geometry, mesh)  # create a CrossSection object
section.display_mesh_info()  # display the mesh information
section.plot_mesh()  # plot the generated mesh

# perform a geometric, warping and plastic anaylsis, displaying the time info
section.calculate_geometric_properties(time_info=True)
section.calculate_warping_properties(time_info=True)
section.calculate_plastic_properties(time_info=True)

# print the results to the terminal
section.display_results()

# get the second moments of area and the torsion constant
(ixx_c, iyy_c, ixy_c) = section.get_ic()
j = section.get_j()

# print the sum of the second moments of area and the torsion constant
print("Ixx + Iyy = {0:.3f}".format(ixx_c + iyy_c))
print("J = {0:.3f}".format(j))
# merge the two sections into one geometry object
geometry = sections.MergedSection([ub, panel])
geometry.clean_geometry()  # clean the geometry
geometry.plot_geometry()  # plot the geometry

# create a mesh - use a mesh size of 5 for the UB, 20 for the panel
mesh = geometry.create_mesh(mesh_sizes=[5, 20])

# create a CrossSection object - take care to list the materials in the same order as entered into
# the MergedSection
section = CrossSection(geometry, mesh, materials=[steel, timber])
section.display_mesh_info()  # display the mesh information

# plot the mesh with coloured materials and a line transparency of 0.5
section.plot_mesh(materials=True, alpha=0.5)

# perform a geometric, warping and plastic analysis
section.calculate_geometric_properties(time_info=True)
section.calculate_warping_properties(time_info=True)
section.calculate_plastic_properties(time_info=True, verbose=True)

# perform a stress analysis with N = 100 kN, Mxx = 120 kN.m and Vy = 75 kN
stress_post = section.calculate_stress(N=-100e3,
                                       Mxx=-120e6,
                                       Vy=-75e3,
                                       time_info=True)

# print the results to the terminal
section.display_results()
Beispiel #3
0
class OneSec:
    """表示一个截面"""
    def __init__(self, pls):
        """
        单独截面
        :param pls: 多条 cad 多段线对象组成的列表,其中应有一根指示控制点的线
        """

        # 原始线和控制点
        self.pls_origin = []
        self.points = []
        for i in pls:
            if i.area == 0:
                self.points = i.id
            else:
                self.pls_origin.append(i)

        # 对线段进行排序,得到分离节点和完整节点
        self.areas = np.array([i.area for i in self.pls_origin])
        self.pls = np.array(self.pls_origin)[np.argsort(self.areas)][::-1]
        self.ids_sep = [i.id for i in self.pls]
        self.ids = [j.tolist() for i in self.ids_sep for j in i]

        # 获取节点连接方式
        self.faces = []
        id_num = 0
        for i in self.ids_sep:
            id_num_0 = id_num
            for j in i:
                connect = [
                    id_num, id_num_0
                ] if id_num + 1 == id_num_0 + len(i) else [id_num, id_num + 1]
                self.faces.append(connect)
                id_num += 1

        # 定义其他所需值
        self.geo = 0
        self.mesh = 0
        self.sec = 0
        self.prop = {}
        self.stress = 0
        self.corner = []
        self.ids_to_c = []

    def sec_cal(self, mesh=0.01, d=0.03):
        """
        对单个截面进行属性计算
        :param mesh: 截面划分单元尺寸
        :param d: 截取形心附近应力范围
        :return: 无
        """

        self.geo = sections.CustomSection(self.ids, self.faces,
                                          self.points[1:], [self.points[0]])
        self.mesh = self.geo.create_mesh(mesh_sizes=[mesh])
        self.sec = CrossSection(self.geo, self.mesh)
        self.sec.plot_mesh()
        self.sec.calculate_geometric_properties()
        self.sec.calculate_warping_properties()

        # 获取截面属性
        prop = self.sec.section_props
        self.prop['center'] = self.sec.get_c()
        self.ids_to_c = [i - self.prop['center'] for i in self.ids_sep]
        self.prop['area'] = prop.area
        self.prop['as'] = [prop.A_s22, prop.A_s11]
        self.prop['i'] = [prop.j, prop.ixx_c, prop.iyy_c]
        pts = np.array(self.ids)
        left = prop.cx - pts[:, 0].min()
        right = pts[:, 0].max() - prop.cx
        top = pts[:, 1].max() - prop.cy
        bot = prop.cy - pts[:, 1].min()
        self.prop['c'] = [right, left, top, bot]

        self.stress = self.sec.calculate_stress(Vx=1, Vy=1)
        stresses = self.stress.get_stress()
        dy = self.sec.get_c()[1] - self.sec.mesh_nodes[:, 1]
        dx = self.sec.get_c()[0] - self.sec.mesh_nodes[:, 0]
        qyb = stresses[0]['sig_zy_vy'][dx < d].max() * prop.ixx_c
        qzb = stresses[0]['sig_zx_vx'][dy < d].max() * prop.iyy_c
        self.prop['q'] = [qyb, qzb]
        self.prop['p'] = [
            self.pls[0].length,
            sum([i.length for i in self.pls[1:]])
        ]

        # 获取角点
        pt_all = self.ids_to_c[0]
        pt_1 = pt_all[(pt_all[:, 0] < 0) & (pt_all[:, 1] > 0)]
        pt_2 = pt_all[(pt_all[:, 0] > 0) & (pt_all[:, 1] > 0)]
        pt_3 = pt_all[(pt_all[:, 0] < 0) & (pt_all[:, 1] < 0)]
        pt_4 = pt_all[(pt_all[:, 0] > 0) & (pt_all[:, 1] < 0)]
        pt_1 = find_pt(pt_1, relation='max')
        pt_2 = find_pt(pt_2, relation='max')
        pt_3 = find_pt(pt_3, relation='max')
        pt_4 = find_pt(pt_4, relation='max')
        self.corner = [pt_1, pt_2, pt_4, pt_3]