示例#1
0
    def testShearBendingSimple(self):
        # Test data from "Mechanical of Materials", Gere, 6th ed., pg. 273
        # cantilevered beam with linear distributed load

        L = 10.0
        q0 = 3.0

        n = 1
        nodes = n + 1

        tip = pb.TipData()

        base = pb.BaseData(np.ones(6), 1.0)

        z = np.arange(nodes, dtype=np.float64) * (L / n)
        EIx = EIy = EA = GJ = rhoJ = rhoA = np.ones(nodes)
        sec = pb.SectionData(nodes, z, EA, EIx, EIy, GJ, rhoA, rhoJ)

        Px = q0 * (1 - z / L)
        Py = Pz = np.zeros(nodes)
        loads = pb.Loads(nodes, Px, Py, Pz)

        beam = pb.Beam(sec, loads, tip, base)

        (Vx, Vy, Fz, Mx, My, Tz) = beam.shearAndBending()

        tol_pct = 1e-8
        Vx_expect = np.polyval([q0 * L / 2.0, -q0 * L, q0 * L / 2.0],
                               [0.0, 1.0])
        My_expect = np.polyval([
            -q0 * L * L / 6.0, 3.0 * q0 * L * L / 6.0, -3.0 * q0 * L * L / 6.0,
            q0 * L * L / 6.0
        ], [0.0, 1.0])
        npt.assert_almost_equal(Vx, Vx_expect)
        npt.assert_almost_equal(My, My_expect)
示例#2
0
    def testCantileverDeflection(self):
        # Test data from "Finite Element Structural Analysis", Yang, pg. 145
        E = 2.0
        I = 3.0
        L = 4.0
        p0 = 5.0

        nodes = 2

        Px = np.array([-p0, 0.0])
        Py = Pz = np.zeros(nodes)
        loads = pb.Loads(nodes, Px, Py, Pz)

        tip = pb.TipData()

        base = pb.BaseData(np.ones(6), 1.0)

        z = np.array([0.0, L])
        EIx = EIy = E * I * np.ones(nodes)
        EA = E * np.ones(nodes)
        GJ = rhoA = rhoJ = np.ones(nodes)
        sec = pb.SectionData(nodes, z, EA, EIx, EIy, GJ, rhoA, rhoJ)

        beam = pb.Beam(sec, loads, tip, base)

        (dx, dy, dz, dtheta_x, dtheta_y, dtheta_z) = beam.displacement()

        self.assertAlmostEqual(dx[0], 0.0, 8)
        self.assertAlmostEqual(dx[1], -p0 * L**3.0 / E / I * L / 30.0, 8)
        self.assertAlmostEqual(dtheta_y[0], 0.0, 8)
        self.assertAlmostEqual(dtheta_y[1], -p0 * L**3.0 / E / I * 1 / 24.0, 8)
示例#3
0
    def testBucklingEuler(self):
        # unit test data from Euler's buckling formula for a clamped/free beam

        E = 2.0
        I = 3.0
        L = 4.0

        n = 3
        nodes = n + 1

        Px = Py = Pz = np.zeros(nodes)
        loads = pb.Loads(nodes, Px, Py, Pz)

        tip = pb.TipData()

        base = pb.BaseData(np.ones(6), 1.0)

        z = L * np.arange(nodes)
        EIx = EIy = E * I * np.ones(nodes)
        EA = GJ = rhoJ = rhoA = np.ones(nodes)
        sec = pb.SectionData(nodes, z, EA, EIx, EIy, GJ, rhoA, rhoJ)

        beam = pb.Beam(sec, loads, tip, base)

        (Pcr_x, Pcr_y) = beam.criticalBucklingLoads()

        Ltotal = n * L
        tol_pct = 0.011
        expect = E * I * (0.5 * np.pi / Ltotal)**2.0
        self.assertAlmostEqual(Pcr_x, expect, 2)
        self.assertAlmostEqual(Pcr_y, expect, 2)
示例#4
0
    def testFreqFree_FreeBeam_n3(self):
        # Test data from "Consistent Mass Matrix for Distributed Mass Systmes", John Archer,
        # Journal of the Structural Division Proceedings of the American Society of Civil Engineers,
        # pg. 168
        E = 2.0
        I = 3.0
        L = 4.0
        A = 5.0
        rho = 6.0

        n = 3
        nodes = n + 1

        Px = Py = Pz = np.zeros(nodes)
        loads = pb.Loads(nodes, Px, Py, Pz)

        tip = pb.TipData()

        base = pb.BaseData()

        z = L * np.arange(nodes)
        EIx = EIy = E * I * np.ones(nodes)
        EA = GJ = rhoJ = np.ones(nodes)
        rhoA = rho * A * np.ones(nodes)
        sec = pb.SectionData(nodes, z, EA, EIx, EIy, GJ, rhoA, rhoJ)

        beam = pb.Beam(sec, loads, tip, base)

        nFreq = 100
        freq = beam.naturalFrequencies(nFreq)

        m = rho * A
        alpha = m * (n * L)**4.0 / (840.0 * E * I)

        tol_pct = 6e-6 * 100
        expect = np.sqrt(0.59919 / alpha) / (2 * np.pi)
        self.assertAlmostEqual(freq[1], expect, delta=tol_pct)
        self.assertAlmostEqual(freq[2], expect, delta=tol_pct)
        expect = np.sqrt(4.5750 / alpha) / (2 * np.pi)
        self.assertAlmostEqual(freq[5], expect, delta=tol_pct)
        self.assertAlmostEqual(freq[6], expect, delta=tol_pct)
        expect = np.sqrt(22.010 / alpha) / (2 * np.pi)
        self.assertAlmostEqual(freq[8], expect, delta=tol_pct)
        self.assertAlmostEqual(freq[9], expect, delta=tol_pct)
        expect = np.sqrt(70.920 / alpha) / (2 * np.pi)
        self.assertAlmostEqual(freq[11], expect, delta=tol_pct)
        self.assertAlmostEqual(freq[12], expect, delta=tol_pct)
        expect = np.sqrt(265.91 / alpha) / (2 * np.pi)
        self.assertAlmostEqual(freq[14], expect, delta=tol_pct)
        self.assertAlmostEqual(freq[15], expect, delta=tol_pct)
        expect = np.sqrt(402.40 / alpha) / (2 * np.pi)
        self.assertAlmostEqual(freq[16], expect, delta=tol_pct)
        self.assertAlmostEqual(freq[17], expect, delta=tol_pct)
示例#5
0
    def testShearBendingSimplePt(self):
        # Test data from "Mechanical of Materials", Gere, 6th ed., pg. 288
        # cantilevered beam with two point loads

        L = 10.0
        P1 = 2.0
        P2 = 3.0

        n = 3
        nodes = n + 1

        tip = pb.TipData()

        base = pb.BaseData(np.ones(6), 1.0)

        z = np.arange(nodes, dtype=np.float64) * (L / n)
        EIx = EIy = EA = GJ = rhoJ = rhoA = np.ones(nodes)
        sec = pb.SectionData(nodes, z, EA, EIx, EIy, GJ, rhoA, rhoJ)

        Px = Py = Pz = Fy_pt = Fz_pt = Mx_pt = My_pt = Mz_pt = np.zeros(nodes)
        Fx_pt = np.zeros(nodes)
        Fx_pt[1] = -P2
        Fx_pt[3] = -P1
        loads = pb.Loads(nodes, Px, Py, Pz, Fx_pt, Fy_pt, Fz_pt, Mx_pt, My_pt,
                         Mz_pt)

        beam = pb.Beam(sec, loads, tip, base)

        (Vx, Vy, Fz, Mx, My, Tz) = beam.shearAndBending()

        tol_pct = 1e-8
        Vx_expect = np.polyval([0.0, 0.0, -P1 - P2], [0.0])
        self.assertAlmostEqual(Vx[0], Vx_expect, 8)

        Vx_expect = np.polyval([0.0, 0.0, -P1], [0.0])
        self.assertAlmostEqual(Vx[1], Vx_expect, 8)
        self.assertAlmostEqual(Vx[2], Vx_expect, 8)

        b = L / 3.0
        a = 2.0 / 3.0 * L
        My_expect = np.polyval(
            [0.0, 0.0, -P1 * a + P1 * L + P2 * b, -P1 * L - P2 * b], [0.0])
        self.assertAlmostEqual(My[0], My_expect, 8)

        My_expect = np.polyval([0.0, 0.0, -0.5 * P1 * a + P1 * a, -P1 * a],
                               [0.0])
        self.assertAlmostEqual(My[1], My_expect, 8)

        My_expect = np.polyval([0.0, 0.0, 0.5 * P1 * a, -0.5 * P1 * a], [0.0])
        self.assertAlmostEqual(My[2], My_expect, 8)
示例#6
0
    def testTaperedDeflections(self):
        # Test data from "Finite Element Structural Analysis", Yang, pg. 180
        E = 2.0
        I = 3.0
        L = 4.0
        P = 5.0

        nodes = 3

        Px = Py = Pz = np.zeros(nodes)
        loads = pb.Loads(nodes, Px, Py, Pz)

        tip = pb.TipData(0.0, np.zeros(3), np.zeros(6), [-P, 0.0, 0.0],
                         np.zeros(3))

        base = pb.BaseData(np.ones(6), 1.0)

        z = np.array([0.0, 0.5 * L, L])
        EIx = EIy = E * I * np.array([9.0, 5.0, 1.0])
        EA = E * np.ones(nodes)
        GJ = rhoA = rhoJ = np.ones(nodes)
        sec = pb.SectionData(nodes, z, EA, EIx, EIy, GJ, rhoA, rhoJ)

        beam = pb.Beam(sec, loads, tip, base)

        (dx, dy, dz, dtheta_x, dtheta_y, dtheta_z) = beam.displacement()

        tol = 1e-8
        tol_pct_1 = 0.17
        tol_pct_2 = 0.77
        self.assertAlmostEqual(dx[0], 0.0, 8)
        self.assertAlmostEqual(dx[-1],
                               -0.051166 * P * L**3 / E / I,
                               delta=tol_pct_1)
        self.assertAlmostEqual(dtheta_y[0], 0.0, 8)
        self.assertAlmostEqual(dtheta_y[-1],
                               -0.090668 * P * L**2 / E / I,
                               delta=tol_pct_2)
示例#7
0
    def testOtherCalls(self):

        E = 2.0
        I = 3.0
        L = 4.0
        q0 = 5.0

        n = 3
        nodes = n + 1

        tip = pb.TipData()

        base = pb.BaseData(np.ones(6), 1.0)

        z = L * np.arange(nodes)
        EIx = EIy = E * I * np.ones(nodes)
        EA = GJ = rhoJ = rhoA = np.ones(nodes)
        sec = pb.SectionData(nodes, z, EA, EIx, EIy, GJ, rhoA, rhoJ)

        Pz = q0 * (1 - z / L)
        Py = Px = np.zeros(nodes)
        loads = pb.Loads(nodes, Px, Py, Pz)

        beam = pb.Beam(sec, loads, tip, base)

        badlist = [
            float('inf'), -float('inf'),
            float('nan'), 0.0, np.inf, -np.inf, np.nan
        ]
        self.assertNotIn(beam.mass(), badlist)
        self.assertNotIn(beam.outOfPlaneMomentOfInertia(), badlist)

        npts = 10
        xv = yv = np.zeros(npts)
        zv = np.linspace(z[0], z[-1], npts)
        self.assertNotIn(beam.axialStrain(npts, xv, yv, zv).sum(), badlist)