コード例 #1
0
class TestBeamFEAttachmentModes(unittest.TestCase):
    def setUp(self):
        x = array([0.0, 10.0, 22.0, 28.0])
        EI = array([[2e7, 2e7], [1e7, 1e7], [1e7, 1e7]])
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=0, EA=0, EIy=EI, EIz=0)
        self.fe.set_boundary_conditions('C', 'C')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_simple_model(self):
        am = self.fe.attachment_modes()
        self.assertEqual(am.shape, (4 * 6, 2 * 2))
コード例 #2
0
class TestBeamFE_Example62(unittest.TestCase):
    def setUp(self):
        x = linspace(0, 1, 16)
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=1, EA=0, EIy=1, EIz=0)
        self.fe.set_boundary_conditions('C', 'F')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_mode_frequencies(self):
        modal = self.fe.modal_matrices()
        assert_allclose(modal.w[:4], [3.5160, 22.0345, 61.6972, 120.9019],
                        atol=1e-1)
コード例 #3
0
    def setUp(self):
        x = linspace(0, self.L, 15)
        fe = BeamFE(x, density=self.m, EA=0, EIy=self.EI, EIz=0)
        fe.set_boundary_conditions('C', 'C')
        fe.set_dofs([False, False, True, False, True, False])
        beam = DistalModalElementFromFE('beam', fe, num_modes=1,
                                        damping=self.damping_coeff)

        system = System()
        system.add_leaf(beam)
        system.setup()
        system.update_kinematics()

        self.beam, self.system = beam, system
コード例 #4
0
ファイル: test_simple_cases.py プロジェクト: BowenFu/beamfe
class TestBeamFE_Example62(unittest.TestCase):
    def setUp(self):
        x = linspace(0, 1, 16)
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=1, EA=0, EIy=1, EIz=0)
        self.fe.set_boundary_conditions('C', 'F')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_mode_frequencies(self):
        modal = self.fe.modal_matrices()
        assert_allclose(modal.w[:4],
                        [3.5160, 22.0345, 61.6972, 120.9019],
                        atol=1e-1)
コード例 #5
0
class TestBeamFE_Example42(unittest.TestCase):
    def setUp(self):
        x = array([0.0, 4.0, 10.0])
        EI = 144.0
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=0, EA=0, EIy=EI, EIz=0)
        self.fe.set_boundary_conditions('C', 'F')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_stiffness(self):
        # Reddy1993, p 164
        expected = array([
            [27, 0, 0, 0, 0, 0],
            [-54, 144, 0, 0, 0, 0],
            [-27, 54, 27 + 8, 0, 0, 0],
            [-54, 72, 54 - 24, 144 + 96, 0, 0],
            [0, 0, -8, 24, 8, 0],
            [0, 0, -24, 48, 24, 96],
        ])
        expected += expected.T - np.diag(expected.diagonal())  # make symmetric
        expected_II = expected[2:6, 2:6]
        expected_IB = expected[2:6, 0:2]
        assert_allclose(self.fe.K_II, expected_II)
        assert_allclose(self.fe.K_IB, expected_IB)

    def test_distributed_load(self):
        # Distributed force on second element:
        load = array([0, 0, 0, 0, 0, 0, 0, 0, -100, 0, 0, 0])
        Q = self.fe.distribute_load_on_element(1, load)
        Q = Q[[2, 4, 8, 10, 14, 16]]
        assert_allclose(Q, [0, 0, -90, 120, -210, -180])

    def test_solution_without_spring(self):
        # Distributed force on first element:
        load = array([0, 0, 0, 0, 0, 0, 0, 0, -100, 0, 0, 0])
        QF = self.fe.distribute_load_on_element(1, load)

        # Solve static deflection
        deflections, reactions = self.fe.static_deflection(QF)

        # Expected values from Reddy
        expected_deflections = zeros_like(deflections)
        expected_deflections[[
            8, 10, 14, 16
        ]] = array([-1.6, 0.72, -7.108, 0.99]) * 1e4 / 143.0
        assert_allclose(deflections, expected_deflections, atol=1e1)
コード例 #6
0
    def setUp(self):
        x = linspace(0, self.L, 15)
        fe = BeamFE(x, density=self.m, EA=0, EIy=self.EI, EIz=0)
        fe.set_boundary_conditions('C', 'C')
        fe.set_dofs([False, False, True, False, True, False])
        beam = DistalModalElementFromFE('beam',
                                        fe,
                                        num_modes=1,
                                        damping=self.damping_coeff)

        system = System()
        system.add_leaf(beam)
        system.setup()
        system.update_kinematics()

        self.beam, self.system = beam, system
コード例 #7
0
    def test_first_mode_frequency(self):
        # From Reddy1993, p. 160
        x = np.linspace(0, 1, 16)

        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        fe = BeamFE(x, density=1, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        fe.set_dofs([False, False, True, False, True, False])
        element = ModalElementFromFE('elem', fe)

        Mmodal = element.mass_ee
        Kmodal = element.K
        w = np.sqrt(np.diag(Kmodal) / np.diag(Mmodal))
        assert_aae(w[0], 3.5160, decimal=4)
コード例 #8
0
    def test_first_mode_frequency(self):
        # From Reddy1993, p. 160
        x = np.linspace(0, 1, 16)

        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        fe = BeamFE(x, density=1, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        fe.set_dofs([False, False, True, False, True, False])
        element = ModalElementFromFE('elem', fe)

        Mmodal = element.mass_ee
        Kmodal = element.K
        w = np.sqrt(np.diag(Kmodal) / np.diag(Mmodal))
        assert_aae(w[0], 3.5160, decimal=4)
コード例 #9
0
class TestBeamFEAttachmentModes(unittest.TestCase):
    def setUp(self):
        x = array([0.0, 10.0, 22.0, 28.0])
        EI = array([[2e7, 2e7],
                    [1e7, 1e7],
                    [1e7, 1e7]])
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=0, EA=0, EIy=EI, EIz=0)
        self.fe.set_boundary_conditions('C', 'C')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_simple_model(self):
        am = self.fe.attachment_modes()
        self.assertEqual(am.shape, (4*6, 2*2))
コード例 #10
0
ファイル: test_simple_cases.py プロジェクト: BowenFu/beamfe
class TestBeamFE_Example42(unittest.TestCase):
    def setUp(self):
        x = array([0.0, 4.0, 10.0])
        EI = 144.0
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=0, EA=0, EIy=EI, EIz=0)
        self.fe.set_boundary_conditions('C', 'F')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_stiffness(self):
        # Reddy1993, p 164
        expected = array([
            [27,  0,   0,     0,      0,  0],
            [-54, 144, 0,     0,      0,  0],
            [-27, 54,  27+8,  0,      0,  0],
            [-54, 72,  54-24, 144+96, 0,  0],
            [0,   0,   -8,    24,     8,  0],
            [0,   0,   -24,   48,     24, 96],
        ])
        expected += expected.T - np.diag(expected.diagonal())  # make symmetric
        expected_II = expected[2:6, 2:6]
        expected_IB = expected[2:6, 0:2]
        assert_allclose(self.fe.K_II, expected_II)
        assert_allclose(self.fe.K_IB, expected_IB)

    def test_distributed_load(self):
        # Distributed force on second element:
        load = array([0, 0, 0, 0, 0, 0, 0, 0, -100, 0, 0, 0])
        Q = self.fe.distribute_load_on_element(1, load)
        Q = Q[[2, 4, 8, 10, 14, 16]]
        assert_allclose(Q, [0, 0, -90, 120, -210, -180])

    def test_solution_without_spring(self):
        # Distributed force on first element:
        load = array([0, 0, 0, 0, 0, 0, 0, 0, -100, 0, 0, 0])
        QF = self.fe.distribute_load_on_element(1, load)

        # Solve static deflection
        deflections, reactions = self.fe.static_deflection(QF)

        # Expected values from Reddy
        expected_deflections = zeros_like(deflections)
        expected_deflections[[8, 10, 14, 16]] = array(
            [-1.6, 0.72, -7.108, 0.99]) * 1e4 / 143.0
        assert_allclose(deflections, expected_deflections, atol=1e1)
コード例 #11
0
    def test_static_deflection(self):
        x = array([0.0, 4.0, 10.0])
        EI = 144.0
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        fe = BeamFE(x, density=10, EA=0, EIy=EI, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        fe.set_dofs([False, False, True, False, True, False])
        element = ModalElementFromFE('elem', fe)

        # Distributed load, linearly interpolated
        load = np.zeros((3, 3))
        load[-1, 2] = -100        # Load in z direction at tip
        element.apply_distributed_loading(load)
        defl = -element.applied_stress / np.diag(element.K)

        # Check against directly calculating static deflection from FE
        Q = fe.distribute_load(interleave(load, 6))
        defl_fe, reactions_fe = fe.static_deflection(Q)
        assert_aae(dot(element.shapes, defl), defl_fe, decimal=2)
コード例 #12
0
    def test_static_deflection(self):
        x = array([0.0, 4.0, 10.0])
        EI = 144.0
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        fe = BeamFE(x, density=10, EA=0, EIy=EI, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        fe.set_dofs([False, False, True, False, True, False])
        element = ModalElementFromFE('elem', fe)

        # Distributed load, linearly interpolated
        load = np.zeros((3, 3))
        load[-1, 2] = -100  # Load in z direction at tip
        element.apply_distributed_loading(load)
        defl = -element.applied_stress / np.diag(element.K)

        # Check against directly calculating static deflection from FE
        Q = fe.distribute_load(interleave(load, 6))
        defl_fe, reactions_fe = fe.static_deflection(Q)
        assert_aae(dot(element.shapes, defl), defl_fe, decimal=2)
コード例 #13
0
    def test_rigid_element_reference_loading(self):
        # Make an element with no modes (rigid)
        fe = BeamFE(np.linspace(0, 1, 11), density=1, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        fe.set_dofs([False, False, True, False, True, False])
        element = ModalElementFromFE('elem', fe, 0)

        # Distributed load, linearly interpolated
        load = np.zeros((11, 3))
        load[:, 2] = -100        # Uniform load in z direction
        element.apply_distributed_loading(load)
        assert_aae(element.applied_stress, [])
        assert_aae(element.applied_forces[0:6], [0, 0, -100 * 1, 0, 50, 0])
        assert_aae(element.applied_forces[6:12], 0)

        # Distributed load, triangle at tip
        load = np.zeros((11, 3))
        load[-1, 2] = -100             # tapered load in z direction
        element.applied_forces[:] = 0  # reset
        element.apply_distributed_loading(load)
        F = -100 * 0.1 / 2
        assert_aae(element.applied_forces[0:6],
                   [0, 0, F, 0, -F * (0.9 + 0.1 * 2 / 3), 0])
        assert_aae(element.applied_forces[6:12], 0)
コード例 #14
0
    def test_rigid_element_reference_loading(self):
        # Make an element with no modes (rigid)
        fe = BeamFE(np.linspace(0, 1, 11), density=1, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        fe.set_dofs([False, False, True, False, True, False])
        element = ModalElementFromFE('elem', fe, 0)

        # Distributed load, linearly interpolated
        load = np.zeros((11, 3))
        load[:, 2] = -100  # Uniform load in z direction
        element.apply_distributed_loading(load)
        assert_aae(element.applied_stress, [])
        assert_aae(element.applied_forces[0:6], [0, 0, -100 * 1, 0, 50, 0])
        assert_aae(element.applied_forces[6:12], 0)

        # Distributed load, triangle at tip
        load = np.zeros((11, 3))
        load[-1, 2] = -100  # tapered load in z direction
        element.applied_forces[:] = 0  # reset
        element.apply_distributed_loading(load)
        F = -100 * 0.1 / 2
        assert_aae(element.applied_forces[0:6],
                   [0, 0, F, 0, -F * (0.9 + 0.1 * 2 / 3), 0])
        assert_aae(element.applied_forces[6:12], 0)
コード例 #15
0
ファイル: test_simple_cases.py プロジェクト: BowenFu/beamfe
class TestBeamFE_Example41(unittest.TestCase):
    def setUp(self):
        x = array([0.0, 10.0, 22.0, 28.0])
        EI = array([[2e7, 2e7],
                    [1e7, 1e7],
                    [1e7, 1e7]])
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=0, EA=0, EIy=EI, EIz=0)
        self.fe.set_boundary_conditions('P', 'C')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_stiffness(self):
        # Reddy1993, pp 161-162
        expected = 1e7 * array([
            [0.024, -0.12, -0.024, -0.12,  0,        0,        0,       0],
            [0,     0.80,  0.12,   0.40,   0,        0,        0,       0],
            [0,     0,     0.0309, 0.0783, -0.00694, -0.04167, 0,       0],
            [0,     0,     0,      1.133,  0.0417,   0.167,    0,       0],
            [0,     0,     0,      0,      0.0625,   -0.125,   -0.0556, -0.167],
            [0,     0,     0,      0,      0,        1,        0.1667,  0.333],
            [0,     0,     0,      0,      0,        0,        0.0556,  0.1667],
            [0,     0,     0,      0,      0,        0,        0,       0.6667],
        ])
        expected += expected.T - np.diag(expected.diagonal())  # make symmetric
        expected_II = expected[1:6, 1:6]
        expected_IB = expected[1:6, [0, 6, 7]]
        assert_allclose(expected_II, self.fe.K_II, atol=1e-2 * 1e7)
        assert_allclose(expected_IB, self.fe.K_IB, atol=1e-3 * 1e7)

    def test_distributed_load(self):
        # Distributed force on first element:
        load = array([0, 0, -2400, 0, 0, 0, 0, 0, -2400, 0, 0, 0])
        Q = self.fe.distribute_load_on_element(0, load)
        Q = Q[[2, 4, 8, 10, 14, 16, 20, 22]]
        assert_allclose(Q / 1e3, [-12, 20, -12, -20, 0, 0, 0, 0])

    def test_solution(self):
        # Distributed force on first element:
        load = array([0, 0, -2400, 0, 0, 0, 0, 0, -2400, 0, 0, 0])
        QF = self.fe.distribute_load_on_element(0, load)

        # Nodal forces:
        Q = np.zeros(self.fe.K.shape[0])
        Q[14] = -10000     # z force at 3rd node

        # Solve static deflection
        deflections, reactions = self.fe.static_deflection(QF + Q)

        # Expected values from Reddy
        expected_deflections = zeros_like(deflections)
        expected_deflections[[4, 8, 10, 14, 16]] = [0.03856, -0.2808, 0.01214,
                                                    -0.1103, -0.02752]
        assert_allclose(deflections, expected_deflections, atol=1e-4)
        expected_reactions = zeros_like(reactions)
        expected_reactions[[2, 20, 22]] = [18565.54, 15434.46, 92164.83]
        assert_allclose(reactions, expected_reactions, atol=1e-2)

    def test_load_matrix_gives_same_result_as_method(self):
        # Distributed force on all elements
        load = np.zeros(4 * 6)
        load[2::6] = [350, 324, 654, 54]  # Z component

        Q1 = self.fe.distribute_load(load)
        Q2 = dot(self.fe.F, load)

        assert_allclose(Q1, Q2)
コード例 #16
0
class TestBeamFE_Example41(unittest.TestCase):
    def setUp(self):
        x = array([0.0, 10.0, 22.0, 28.0])
        EI = array([[2e7, 2e7], [1e7, 1e7], [1e7, 1e7]])
        # Using the z axis as the transverse direction gives the same
        # sign convention as Reddy uses in 2D, namely that rotations
        # are positive clockwise.
        self.fe = BeamFE(x, density=0, EA=0, EIy=EI, EIz=0)
        self.fe.set_boundary_conditions('P', 'C')
        self.fe.set_dofs([False, False, True, False, True, False])

    def test_stiffness(self):
        # Reddy1993, pp 161-162
        expected = 1e7 * array([
            [0.024, -0.12, -0.024, -0.12, 0, 0, 0, 0],
            [0, 0.80, 0.12, 0.40, 0, 0, 0, 0],
            [0, 0, 0.0309, 0.0783, -0.00694, -0.04167, 0, 0],
            [0, 0, 0, 1.133, 0.0417, 0.167, 0, 0],
            [0, 0, 0, 0, 0.0625, -0.125, -0.0556, -0.167],
            [0, 0, 0, 0, 0, 1, 0.1667, 0.333],
            [0, 0, 0, 0, 0, 0, 0.0556, 0.1667],
            [0, 0, 0, 0, 0, 0, 0, 0.6667],
        ])
        expected += expected.T - np.diag(expected.diagonal())  # make symmetric
        expected_II = expected[1:6, 1:6]
        expected_IB = expected[1:6, [0, 6, 7]]
        assert_allclose(expected_II, self.fe.K_II, atol=1e-2 * 1e7)
        assert_allclose(expected_IB, self.fe.K_IB, atol=1e-3 * 1e7)

    def test_distributed_load(self):
        # Distributed force on first element:
        load = array([0, 0, -2400, 0, 0, 0, 0, 0, -2400, 0, 0, 0])
        Q = self.fe.distribute_load_on_element(0, load)
        Q = Q[[2, 4, 8, 10, 14, 16, 20, 22]]
        assert_allclose(Q / 1e3, [-12, 20, -12, -20, 0, 0, 0, 0])

    def test_solution(self):
        # Distributed force on first element:
        load = array([0, 0, -2400, 0, 0, 0, 0, 0, -2400, 0, 0, 0])
        QF = self.fe.distribute_load_on_element(0, load)

        # Nodal forces:
        Q = np.zeros(self.fe.K.shape[0])
        Q[14] = -10000  # z force at 3rd node

        # Solve static deflection
        deflections, reactions = self.fe.static_deflection(QF + Q)

        # Expected values from Reddy
        expected_deflections = zeros_like(deflections)
        expected_deflections[[4, 8, 10, 14, 16]] = [
            0.03856, -0.2808, 0.01214, -0.1103, -0.02752
        ]
        assert_allclose(deflections, expected_deflections, atol=1e-4)
        expected_reactions = zeros_like(reactions)
        expected_reactions[[2, 20, 22]] = [18565.54, 15434.46, 92164.83]
        assert_allclose(reactions, expected_reactions, atol=1e-2)

    def test_load_matrix_gives_same_result_as_method(self):
        # Distributed force on all elements
        load = np.zeros(4 * 6)
        load[2::6] = [350, 324, 654, 54]  # Z component

        Q1 = self.fe.distribute_load(load)
        Q2 = dot(self.fe.F, load)

        assert_allclose(Q1, Q2)