Пример #1
0
 def setUp(self):
     self.steel = Steel()
     self.elastic_modulus = self.steel.elastic_modulus
     self.ixx = np.random.uniform(10e6, 200e6)
     self.length = np.random.uniform(2e3, 10e3)
     self.q = -np.random.uniform(1, 10)
     self.pl = -np.random.uniform(5e3, 50e3)
Пример #2
0
    def setUp(self):
        # create materials
        steel = Steel()

        # create 2d frame analysis object
        self.analysis = FrameAnalysis2D()

        section1 = Section(area=6e3, ixx=200e6)
        section2 = Section(area=4e3, ixx=50e6)

        # create nodes
        self.node_a = self.analysis.create_node(coords=[0])
        self.node_b = self.analysis.create_node(coords=[8000])
        self.node_c = self.analysis.create_node(coords=[13000])

        # create beam elements
        self.element_ab = self.analysis.create_element(
            el_type='EB2-2D',
            nodes=[self.node_a, self.node_b],
            material=steel,
            section=section1)
        self.element_bc = self.analysis.create_element(
            el_type='EB2-2D',
            nodes=[self.node_b, self.node_c],
            material=steel,
            section=section2)
Пример #3
0
    def test_example2_1(self):
        nodes = []  # list holding the node objects
        elements = []  # list holding the element objects

        # create 2d frame analysis object
        analysis = FrameAnalysis2D()

        # create sections
        steel = Steel()
        section1 = Section(area=6000)
        section2 = Section(area=8000)

        # create nodes
        nodes.append(analysis.create_node(coords=[0, 0]))
        nodes.append(analysis.create_node(coords=[6000, 4000]))
        nodes.append(analysis.create_node(coords=[9000, 0]))

        # create truss elements
        elements.append(analysis.create_element(
            el_type='Bar2-2D', nodes=[nodes[0], nodes[1]], material=steel, section=section1
        ))
        elements.append(analysis.create_element(
            el_type='Bar2-2D', nodes=[nodes[1], nodes[2]], material=steel, section=section2
        ))

        # add supports
        freedom_case = cases.FreedomCase()
        freedom_case.add_nodal_support(node=nodes[0], val=0, dof=0)
        freedom_case.add_nodal_support(node=nodes[0], val=0, dof=1)
        freedom_case.add_nodal_support(node=nodes[2], val=0, dof=0)
        freedom_case.add_nodal_support(node=nodes[2], val=0, dof=1)

        # add loads
        load_case = cases.LoadCase()
        load_case.add_nodal_load(node=nodes[1], val=500e3, dof=0)

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case, load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check node displacement
        n1_disp = nodes[1].get_displacements(analysis_case)

        u = n1_disp[0]
        v = n1_disp[1]

        self.assertEqual(np.around(u, 2), 2.41)
        self.assertEqual(np.around(v, 2), 0.72)

        # check axial forces
        (_, n1) = elements[0].get_afd(n=1, analysis_case=analysis_case)
        (_, n2) = elements[1].get_afd(n=1, analysis_case=analysis_case)

        self.assertEqual(np.around(n1/1e3, 1), 400.6)
        self.assertEqual(np.around(n2/1e3, 1), -277.8)
Пример #4
0
    def test_example2_3(self):
        # create 2d frame analysis object
        analysis = FrameAnalysis2D()

        # create sections
        steel = Steel()
        section1 = Section(area=4000)
        section2 = Section(area=1000)

        # create nodes
        a = analysis.create_node(coords=[0, 0])
        b = analysis.create_node(coords=[2000, 2000])
        c = analysis.create_node(coords=[-4000, 2000])

        # create truss elements
        el1 = analysis.create_element(el_type='Bar2-2D',
                                      nodes=[c, a],
                                      material=steel,
                                      section=section1)
        el2 = analysis.create_element(el_type='Bar2-2D',
                                      nodes=[a, b],
                                      material=steel,
                                      section=section2)

        # add supports
        freedom_case = cases.FreedomCase()
        freedom_case.add_nodal_support(node=b, val=0, dof=0)
        freedom_case.add_nodal_support(node=b, val=0, dof=1)
        freedom_case.add_nodal_support(node=c, val=0, dof=0)
        freedom_case.add_nodal_support(node=c, val=0, dof=1)
        sup1 = freedom_case.add_nodal_support(node=a, val=0, dof=0)
        sup2 = freedom_case.add_nodal_support(node=a, val=-5, dof=1)

        # add loads
        load_case = cases.LoadCase()

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case,
                                           load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check reactions
        self.assertEqual(np.around(sup1.get_reaction(analysis_case) / 1e3, 1),
                         181.0)
        self.assertEqual(np.around(sup2.get_reaction(analysis_case) / 1e3, 1),
                         -355.7)
    def setUp(self):
        steel = Steel()

        # create a rectangular element
        self.width = 5
        self.height = 3

        self.node1 = Node([0, 0])
        self.node2 = Node([self.width, 0])
        self.node3 = Node([self.width, self.height])
        self.node4 = Node([0, self.height])

        self.element = FiniteElement(
            nodes=[self.node1, self.node2, self.node3, self.node4],
            material=steel,
            efs=[True, True, False, False, False, False])
Пример #6
0
    def setUp(self):
        steel = Steel()
        section = Section()

        # create an FrameElement2D elemnetn
        self.x = 4
        self.y = 3
        self.node1 = Node([0, 0])
        self.node2 = Node([self.x, self.y])

        self.element_frame = FrameElement(
            nodes=[self.node1, self.node2], material=steel, section=section,
            efs=[True, True, False, False, False, True]
        )
        self.element_frame2D = FrameElement2D(
            nodes=[self.node1, self.node2], material=steel, section=section,
            efs=[True, True, False, False, False, False]
        )
Пример #7
0
# ------------
# preprocessor
# ------------

# lists
nodes = []  # list holding the node objects
elements = []  # list holding the element objects
freedom_cases = []  # list holding the freedom cases
load_cases = []  # list holding the load cases
analysis_cases = []  # list holding the analysis cases

# create 2d frame analysis object
analysis = FrameAnalysis2D()

# create materials and sections
steel = Steel()
section = Section(area=3230, ixx=23.6e6)

# create nodes
nodes.append(analysis.create_node(coords=[0, 0]))
nodes.append(analysis.create_node(coords=[1500, 0]))
nodes.append(analysis.create_node(coords=[3000, 1500]))

# create beam elements
for i in range(2):
    elements.append(
        analysis.create_element(el_type='EB2-2D',
                                nodes=[nodes[i], nodes[i + 1]],
                                material=steel,
                                section=section))
Пример #8
0
    def test_example2_2(self):
        # create 2d frame analysis object
        analysis = FrameAnalysis2D()

        # create sections
        steel = Steel()
        section1 = Section(area=5000)
        section2 = Section(area=3000)

        # create nodes
        a = analysis.create_node(coords=[0, 0])
        b = analysis.create_node(coords=[3000, 3000])
        c = analysis.create_node(coords=[3000, -3000])
        d = analysis.create_node(coords=[-3000 / np.tan(np.pi / 6), 3000])
        e = analysis.create_node(coords=[-3000 / np.tan(np.pi / 6), -3000])

        # create truss elements
        el1 = analysis.create_element(el_type='Bar2-2D',
                                      nodes=[e, a],
                                      material=steel,
                                      section=section1)
        el2 = analysis.create_element(el_type='Bar2-2D',
                                      nodes=[d, a],
                                      material=steel,
                                      section=section1)
        el3 = analysis.create_element(el_type='Bar2-2D',
                                      nodes=[b, a],
                                      material=steel,
                                      section=section2)
        el4 = analysis.create_element(el_type='Bar2-2D',
                                      nodes=[c, a],
                                      material=steel,
                                      section=section2)

        # add supports
        freedom_case = cases.FreedomCase()
        freedom_case.add_nodal_support(node=b, val=0, dof=0)
        freedom_case.add_nodal_support(node=b, val=0, dof=1)
        freedom_case.add_nodal_support(node=c, val=0, dof=0)
        freedom_case.add_nodal_support(node=c, val=0, dof=1)
        freedom_case.add_nodal_support(node=d, val=0, dof=0)
        freedom_case.add_nodal_support(node=d, val=0, dof=1)
        freedom_case.add_nodal_support(node=e, val=0, dof=0)
        freedom_case.add_nodal_support(node=e, val=0, dof=1)

        # add loads
        load_case = cases.LoadCase()
        load_case.add_nodal_load(node=a, val=1000e3, dof=0)

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case,
                                           load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check node displacement
        dofs = a.get_dofs(a.nfs)
        u = dofs[0].get_displacement(analysis_case)
        v = dofs[1].get_displacement(analysis_case)

        self.assertEqual(np.around(u, 2), 2.55)
        self.assertEqual(np.around(v, 2), 0)

        # check axial forces
        n1 = el1.get_afd(n=1, analysis_case=analysis_case)
        n2 = el2.get_afd(n=1, analysis_case=analysis_case)
        n3 = el3.get_afd(n=1, analysis_case=analysis_case)
        n4 = el4.get_afd(n=1, analysis_case=analysis_case)

        self.assertEqual(np.around(n1 / 1e3, 1), 368.8)
        self.assertEqual(np.around(n2 / 1e3, 1), 368.8)
        self.assertEqual(np.around(n3 / 1e3, 1), -255.5)
        self.assertEqual(np.around(n4 / 1e3, 1), -255.5)
Пример #9
0
 def setUp(self):
     # create materials
     self.steel = Steel()
Пример #10
0
def preprocessor(length, depth, panels, freq):
    w = 10  # load per unit length [N/mm]
    dx = length / panels  # length of a truss panel

    # create 2d frame analysis object
    analysis = FrameAnalysis2D()

    # create materials and sections
    steel = Steel()
    section_deck = Section(area=3230, ixx=23.6e6)  # 200UB25
    section_vertical = Section(area=3000, ixx=3.91e6)  # 100x9 SHS
    section_diagonal = Section(area=314)  # 20 dia rod
    section_tie = Section(area=1018)  # 36 dia rod

    # create deck nodes
    nodes_deck = []

    for i in range(panels + 1):
        nodes_deck.append(analysis.create_node(coords=[i * dx]))

    # create tie nodes - first node coincides with first deck node
    nodes_tie = [nodes_deck[0]]

    for i in range(panels - 1):
        # fit parabola
        x = (i + 1) * dx
        y = 4 * depth / length / length * x * x - 4 * depth / length * x

        nodes_tie.append(analysis.create_node(coords=[x, y]))

    # last node coincides with last deck node
    nodes_tie.append(nodes_deck[-1])

    # create deck (beam) elements
    elements_deck = []

    for i in range(panels):
        elements_deck.append(
            analysis.create_element(el_type='EB2-2D',
                                    nodes=[nodes_deck[i], nodes_deck[i + 1]],
                                    material=steel,
                                    section=section_deck))

    # create tie (bar) elements
    elements_tie = []

    for i in range(panels):
        elements_tie.append(
            analysis.create_element(el_type='Bar2-2D',
                                    nodes=[nodes_tie[i], nodes_tie[i + 1]],
                                    material=steel,
                                    section=section_tie))

    # create vertical (beam) elements
    elements_vertical = []

    for i in range(panels - 1):
        elements_vertical.append(
            analysis.create_element(
                el_type='EB2-2D',
                nodes=[nodes_deck[i + 1], nodes_tie[i + 1]],
                material=steel,
                section=section_vertical))

    # create diagonal (bar) elements
    elements_diaongal = []

    for i in range(panels - 2):
        elements_diaongal.append(
            analysis.create_element(
                el_type='Bar2-2D',
                nodes=[nodes_deck[i + 1], nodes_tie[i + 2]],
                material=steel,
                section=section_diagonal))

        elements_diaongal.append(
            analysis.create_element(
                el_type='Bar2-2D',
                nodes=[nodes_deck[i + 2], nodes_tie[i + 1]],
                material=steel,
                section=section_diagonal))

    # add supports
    freedom_case = cases.FreedomCase()
    freedom_case.add_nodal_support(node=nodes_deck[0], val=0, dof=0)
    freedom_case.add_nodal_support(node=nodes_deck[0], val=0, dof=1)
    freedom_case.add_nodal_support(node=nodes_deck[-1], val=0, dof=1)

    # add loads
    load_case = cases.LoadCase()

    # if frequency analysis, don't bother adding load
    if not freq:
        for el in elements_deck:
            load_case.add_element_load(el.generate_udl(q=-w))

    # add analysis case
    analysis_case = cases.AnalysisCase(freedom_case=freedom_case,
                                       load_case=load_case)

    return (analysis, analysis_case)
Пример #11
0
    def test_example5_7(self):
        l_a = np.sqrt(8000 * 8000 - 3000 * 3000)

        # create materials
        steel = Steel()

        # create 2d frame analysis object
        analysis = FrameAnalysis2D()

        section = Section(area=6e3, ixx=200e6)

        # create nodes
        node_a = analysis.create_node(coords=[0])
        node_b = analysis.create_node(coords=[l_a, 3000])
        node_c = analysis.create_node(coords=[l_a + 8000, 3000])

        # create beam elements
        element_ab = analysis.create_element(
            el_type='EB2-2D', nodes=[node_a, node_b], material=steel, section=section
        )
        element_bc = analysis.create_element(
            el_type='EB2-2D', nodes=[node_b, node_c], material=steel, section=section
        )

        # add supports
        freedom_case = cases.FreedomCase()
        sup_a = [0, 0, 0]
        sup_a[0] = freedom_case.add_nodal_support(node=node_a, val=0, dof=0)
        sup_a[1] = freedom_case.add_nodal_support(node=node_a, val=0, dof=1)
        sup_a[2] = freedom_case.add_nodal_support(node=node_a, val=0, dof=5)
        sup_c = [0, 0, 0]
        sup_c[0] = freedom_case.add_nodal_support(node=node_c, val=0, dof=0)
        sup_c[1] = freedom_case.add_nodal_support(node=node_c, val=0, dof=1)
        sup_c[2] = freedom_case.add_nodal_support(node=node_c, val=0, dof=5)

        # add loads
        load_case = cases.LoadCase()
        load_case.add_nodal_load(node=node_b, val=50e3 * 3000 / 8000, dof=0)
        load_case.add_nodal_load(node=node_b, val=-50e3 * l_a / 8000, dof=1)
        load_case.add_element_load(element_bc.generate_udl(q=-4))

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case, load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check node displacement
        disp_b = node_b.get_displacements(analysis_case)
        u_b = disp_b[0]
        v_b = disp_b[1]
        r_b = disp_b[5]

        self.assertEqual(np.around(u_b, 4), 0.9950)
        self.assertEqual(np.around(v_b, 3), -4.982)
        self.assertEqual(np.around(r_b, 6), -0.000534)

        # check reactions
        ra_x = sup_a[0].get_reaction(analysis_case=analysis_case)
        ra_y = sup_a[1].get_reaction(analysis_case=analysis_case)
        ra_m = sup_a[2].get_reaction(analysis_case=analysis_case)
        rc_x = sup_c[0].get_reaction(analysis_case=analysis_case)
        rc_y = sup_c[1].get_reaction(analysis_case=analysis_case)
        rc_m = sup_c[2].get_reaction(analysis_case=analysis_case)

        self.assertEqual(np.around(ra_x/1e3, 1), 130.5)
        self.assertEqual(np.around(ra_y/1e3, 1), 55.7)
        self.assertEqual(np.around(ra_m/1e6, 2), 13.37)
        self.assertEqual(np.around(rc_x/1e3, 1), -149.3)
        self.assertEqual(np.around(rc_y/1e3, 1), 22.7)
        self.assertEqual(np.around(rc_m/1e6, 2), -45.36)
Пример #12
0
    def test_example5_4(self):
        # create materials
        steel = Steel()

        # create 3d frame analysis object
        analysis = FrameAnalysis3D()

        section_ab = Section(area=20e3)
        section_ac = Section(area=30e3)
        section_ad = Section(area=40e3)
        section_ae = Section(area=30e3)

        # create nodes
        node_a = analysis.create_node(coords=[2000, 4000, 8000])
        node_b = analysis.create_node(coords=[0, 0, 0])
        node_c = analysis.create_node(coords=[8000, 0, 0])
        node_d = analysis.create_node(coords=[8000, 6000, 0])
        node_e = analysis.create_node(coords=[0, 6000, 0])

        # create truss elements
        element_ab = analysis.create_element(
            el_type='Bar2-3D', nodes=[node_a, node_b], material=steel, section=section_ab
        )
        element_ac = analysis.create_element(
            el_type='Bar2-3D', nodes=[node_a, node_c], material=steel, section=section_ac
        )
        element_ad = analysis.create_element(
            el_type='Bar2-3D', nodes=[node_a, node_d], material=steel, section=section_ad
        )
        element_ae = analysis.create_element(
            el_type='Bar2-3D', nodes=[node_a, node_e], material=steel, section=section_ae
        )

        # add supports
        freedom_case = cases.FreedomCase()
        sup_b = [0, 0, 0]
        sup_c = [0, 0, 0]
        sup_d = [0, 0, 0]
        sup_e = [0, 0, 0]
        sup_b[0] = freedom_case.add_nodal_support(node=node_b, val=0, dof=0)
        sup_b[1] = freedom_case.add_nodal_support(node=node_b, val=0, dof=1)
        sup_b[2] = freedom_case.add_nodal_support(node=node_b, val=0, dof=2)
        sup_c[0] = freedom_case.add_nodal_support(node=node_c, val=0, dof=0)
        sup_c[1] = freedom_case.add_nodal_support(node=node_c, val=0, dof=1)
        sup_c[2] = freedom_case.add_nodal_support(node=node_c, val=0, dof=2)
        sup_d[0] = freedom_case.add_nodal_support(node=node_d, val=0, dof=0)
        sup_d[1] = freedom_case.add_nodal_support(node=node_d, val=0, dof=1)
        sup_d[2] = freedom_case.add_nodal_support(node=node_d, val=0, dof=2)
        sup_e[0] = freedom_case.add_nodal_support(node=node_e, val=0, dof=0)
        sup_e[1] = freedom_case.add_nodal_support(node=node_e, val=0, dof=1)
        sup_e[2] = freedom_case.add_nodal_support(node=node_e, val=0, dof=2)

        # add loads
        load_case = cases.LoadCase()
        load_case.add_nodal_load(node=node_a, val=200e3, dof=0)
        load_case.add_nodal_load(node=node_a, val=600e3, dof=1)
        load_case.add_nodal_load(node=node_a, val=-800e3, dof=2)

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case, load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check node displacement
        disp_a = node_a.get_displacements(analysis_case)
        u_a = disp_a[0]
        v_a = disp_a[1]
        w_a = disp_a[2]

        self.assertEqual(np.around(u_a, 3), 0.178)
        self.assertEqual(np.around(v_a, 3), 2.722)
        self.assertEqual(np.around(w_a, 3), -0.487)

        # check reactions
        rb_x = sup_b[0].get_reaction(analysis_case=analysis_case)
        rb_y = sup_b[1].get_reaction(analysis_case=analysis_case)
        rb_z = sup_b[2].get_reaction(analysis_case=analysis_case)
        rc_x = sup_c[0].get_reaction(analysis_case=analysis_case)
        rc_y = sup_c[1].get_reaction(analysis_case=analysis_case)
        rc_z = sup_c[2].get_reaction(analysis_case=analysis_case)
        rd_x = sup_d[0].get_reaction(analysis_case=analysis_case)
        rd_y = sup_d[1].get_reaction(analysis_case=analysis_case)
        rd_z = sup_d[2].get_reaction(analysis_case=analysis_case)
        re_x = sup_e[0].get_reaction(analysis_case=analysis_case)
        re_y = sup_e[1].get_reaction(analysis_case=analysis_case)
        re_z = sup_e[2].get_reaction(analysis_case=analysis_case)

        self.assertEqual(np.around(rb_x/1e3, 1), -76.4)
        self.assertEqual(np.around(rb_y/1e3, 1), -152.8)
        self.assertEqual(np.around(rb_z/1e3, 1), -305.6)
        self.assertEqual(np.around(rc_x/1e3, 1), 170.8)
        self.assertEqual(np.around(rc_y/1e3, 1), -113.9)
        self.assertEqual(np.around(rc_z/1e3, 1), -227.8)
        self.assertEqual(np.around(rd_x/1e3, 1), -470.8)
        self.assertEqual(np.around(rd_y/1e3, 1), -156.9)
        self.assertEqual(np.around(rd_z/1e3, 1), 627.8)
        self.assertEqual(np.around(re_x/1e3, 1), 176.4)
        self.assertEqual(np.around(re_y/1e3, 1), -176.4)
        self.assertEqual(np.around(re_z/1e3, 1), 705.6)
Пример #13
0
    def test_example5_6(self):
        # create materials
        steel = Steel()

        # create 2d frame analysis object
        analysis = FrameAnalysis2D()

        section_ab = Section(area=6e3, ixx=200e6)
        section_bc = Section(area=4e3, ixx=50e6)

        # create nodes
        node_a = analysis.create_node(coords=[0])
        node_b = analysis.create_node(coords=[8000])
        node_p = analysis.create_node(coords=[10000])
        node_c = analysis.create_node(coords=[13000])

        # create beam elements
        element_ab = analysis.create_element(
            el_type='EB2-2D', nodes=[node_a, node_b], material=steel, section=section_ab
        )
        element_bp = analysis.create_element(
            el_type='EB2-2D', nodes=[node_b, node_p], material=steel, section=section_bc
        )
        element_pc = analysis.create_element(
            el_type='EB2-2D', nodes=[node_p, node_c], material=steel, section=section_bc
        )

        # add supports
        freedom_case = cases.FreedomCase()
        sup_a = freedom_case.add_nodal_support(node=node_a, val=0, dof=1)
        sup_b = freedom_case.add_nodal_support(node=node_b, val=0, dof=1)
        sup_c = [0, 0, 0]
        sup_c[0] = freedom_case.add_nodal_support(node=node_c, val=0, dof=0)
        sup_c[1] = freedom_case.add_nodal_support(node=node_c, val=0, dof=1)
        sup_c[2] = freedom_case.add_nodal_support(node=node_c, val=0, dof=5)

        # add loads
        load_case = cases.LoadCase()
        load_case.add_element_load(element_ab.generate_udl(q=-2))
        load_case.add_nodal_load(node=node_p, val=-20e3, dof=1)

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case, load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check node displacement
        disp_a = node_a.get_displacements(analysis_case)
        disp_b = node_b.get_displacements(analysis_case)
        r_a = disp_a[5]
        r_b = disp_b[5]

        self.assertEqual(np.around(r_a, 7), -5.681e-4)
        self.assertEqual(np.around(r_b, 7), 0.696e-4)

        # check reactions
        ra_y = sup_a.get_reaction(analysis_case=analysis_case)
        rb_y = sup_b.get_reaction(analysis_case=analysis_case)
        rc_y = sup_c[1].get_reaction(analysis_case=analysis_case)
        rc_m = sup_c[2].get_reaction(analysis_case=analysis_case)

        self.assertEqual(np.around(ra_y/1e3, 2), 6.13)
        self.assertEqual(np.around(rb_y/1e3, 2), 23.00)
        self.assertEqual(np.around(rc_y/1e3, 2), 6.87)
        self.assertEqual(np.around(rc_m/1e6, 2), -9.32)
Пример #14
0
    def test_example3_3(self):
        nodes = []  # list holding the node objects
        elements = []  # list holding the element objects

        # create 2d frame analysis object
        analysis = FrameAnalysis2D()

        # create sections
        steel = Steel()
        section1 = Section(area=15e3)
        section2 = Section(area=18e3)
        section3 = Section(area=20e3)

        # create nodes
        nodes.append(analysis.create_node(coords=[0, 0]))
        nodes.append(analysis.create_node(coords=[4000/np.tan(np.pi/6), 4000]))
        nodes.append(analysis.create_node(coords=[4000/np.tan(np.pi/6) + 4000, 0]))
        nodes.append(analysis.create_node(coords=[0, 4000]))

        # create truss elements
        elements.append(analysis.create_element(
            el_type='Bar2-2D', nodes=[nodes[0], nodes[1]], material=steel, section=section1
        ))
        elements.append(analysis.create_element(
            el_type='Bar2-2D', nodes=[nodes[1], nodes[2]], material=steel, section=section3
        ))
        elements.append(analysis.create_element(
            el_type='Bar2-2D', nodes=[nodes[0], nodes[2]], material=steel, section=section2
        ))
        elements.append(analysis.create_element(
            el_type='Bar2-2D', nodes=[nodes[3], nodes[1]], material=steel, section=section3
        ))

        # add supports
        freedom_case = cases.FreedomCase()
        sup1 = freedom_case.add_nodal_support(node=nodes[0], val=0, dof=0)
        sup2 = freedom_case.add_nodal_support(node=nodes[0], val=0, dof=1)
        sup3 = freedom_case.add_nodal_support(node=nodes[2], val=0, dof=1)
        sup4 = freedom_case.add_nodal_support(node=nodes[3], val=0, dof=0)
        sup5 = freedom_case.add_nodal_support(node=nodes[3], val=0, dof=1)

        # add loads
        load_case = cases.LoadCase()
        load_case.add_nodal_load(node=nodes[1], val=500e3*np.cos(2*np.pi/9), dof=0)
        load_case.add_nodal_load(node=nodes[1], val=500e3*np.sin(2*np.pi/9), dof=1)

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case, load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check node displacement
        disp_a = nodes[1].get_displacements(analysis_case)
        disp_b = nodes[2].get_displacements(analysis_case)

        u_a = disp_a[0]
        v_a = disp_a[1]
        u_b = disp_b[0]

        self.assertEqual(np.around(u_a, 2), 0.38)
        self.assertEqual(np.around(v_a, 2), 1.23)
        self.assertEqual(np.around(u_b, 2), -0.44)

        # check reactions
        rc_x = sup1.get_reaction(analysis_case=analysis_case)
        rc_y = sup2.get_reaction(analysis_case=analysis_case)
        rb_y = sup3.get_reaction(analysis_case=analysis_case)
        rd_x = sup4.get_reaction(analysis_case=analysis_case)
        rd_y = sup5.get_reaction(analysis_case=analysis_case)

        self.assertEqual(np.around(rc_x/1e3, 1), -162.5)
        self.assertEqual(np.around(rc_y/1e3, 1), -177.1)
        self.assertEqual(np.around(rb_y/1e3, 1), -144.3)
        self.assertEqual(np.around(rd_x/1e3, 1), -220.5)
        self.assertEqual(np.around(rd_y/1e3, 1), 0)
Пример #15
0
    def test_example3_2(self):
        nodes = []  # list holding the node objects
        elements = []  # list holding the element objects

        # create 2d frame analysis object
        analysis = FrameAnalysis2D()

        # create sections
        steel = Steel()
        section1 = Section(area=15e3)
        section2 = Section(area=18e3)
        section3 = Section(area=20e3)

        # create nodes
        nodes.append(analysis.create_node(coords=[0, 0]))
        nodes.append(
            analysis.create_node(coords=[4000 / np.tan(np.pi / 6), 4000]))
        nodes.append(
            analysis.create_node(coords=[4000 / np.tan(np.pi / 6) + 4000, 0]))

        # create truss elements
        elements.append(
            analysis.create_element(el_type='Bar2-2D',
                                    nodes=[nodes[0], nodes[1]],
                                    material=steel,
                                    section=section1))
        elements.append(
            analysis.create_element(el_type='Bar2-2D',
                                    nodes=[nodes[1], nodes[2]],
                                    material=steel,
                                    section=section3))
        elements.append(
            analysis.create_element(el_type='Bar2-2D',
                                    nodes=[nodes[0], nodes[2]],
                                    material=steel,
                                    section=section2))

        # add supports
        freedom_case = cases.FreedomCase()
        sup1 = freedom_case.add_nodal_support(node=nodes[0], val=0, dof=0)
        sup2 = freedom_case.add_nodal_support(node=nodes[0], val=0, dof=1)
        sup3 = freedom_case.add_nodal_support(node=nodes[2], val=0, dof=1)

        # add loads
        load_case = cases.LoadCase()
        load_case.add_nodal_load(node=nodes[1],
                                 val=500e3 * np.cos(2 * np.pi / 9),
                                 dof=0)
        load_case.add_nodal_load(node=nodes[1],
                                 val=500e3 * np.sin(2 * np.pi / 9),
                                 dof=1)

        # add analysis case
        analysis_case = cases.AnalysisCase(freedom_case=freedom_case,
                                           load_case=load_case)

        # linear static solver
        LinearStatic(analysis=analysis, analysis_cases=[analysis_case]).solve()

        # check node displacement
        node_a = nodes[1]
        node_b = nodes[2]
        dofs_a = node_a.get_dofs(node_a.nfs)
        dofs_b = node_b.get_dofs(node_b.nfs)

        u_a = dofs_a[0].get_displacement(analysis_case)
        v_a = dofs_a[1].get_displacement(analysis_case)
        u_b = dofs_b[0].get_displacement(analysis_case)

        self.assertEqual(np.around(u_a, 2), 0.87)
        self.assertEqual(np.around(v_a, 2), 1.24)
        self.assertEqual(np.around(u_b, 2), -0.19)

        # check axial forces
        n1 = elements[0].get_afd(n=1, analysis_case=analysis_case)
        n2 = elements[1].get_afd(n=1, analysis_case=analysis_case)
        n3 = elements[2].get_afd(n=1, analysis_case=analysis_case)

        self.assertEqual(np.around(n1 / 1e3, 1), 515.7)
        self.assertEqual(np.around(n2 / 1e3, 1), 89.9)
        self.assertEqual(np.around(n3 / 1e3, 1), -63.6)

        # check reactions
        rc_x = sup1.get_reaction(analysis_case=analysis_case)
        rc_y = sup2.get_reaction(analysis_case=analysis_case)
        rb_y = sup3.get_reaction(analysis_case=analysis_case)

        self.assertEqual(np.around(rc_x / 1e3, 1), -383.0)
        self.assertEqual(np.around(rc_y / 1e3, 1), -257.8)
        self.assertEqual(np.around(rb_y / 1e3, 1), -63.6)