def test_composite_beam(): E = Symbol('E') I = Symbol('I') b1 = Beam(2, E, 1.5*I) b2 = Beam(2, E, I) b = b1.join(b2, "fixed") b.apply_load(-20, 0, -1) b.apply_load(80, 0, -2) b.apply_load(20, 4, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0)] assert b.length == 4 assert b.second_moment == Piecewise((1.5*I, x <= 2), (I, x <= 4)) assert b.slope().subs(x, 4) == 120.0/(E*I) assert b.slope().subs(x, 2) == 80.0/(E*I) assert int(b.deflection().subs(x, 4).args[0]) == 302 # Coefficient of 1/(E*I) l = symbols('l', positive=True) R1, M1, R2, R3, P = symbols('R1 M1 R2 R3 P') b1 = Beam(2*l, E, I) b2 = Beam(2*l, E, I) b = b1.join(b2,"hinge") b.apply_load(M1, 0, -2) b.apply_load(R1, 0, -1) b.apply_load(R2, l, -1) b.apply_load(R3, 4*l, -1) b.apply_load(P, 3*l, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0), (l, 0), (4*l, 0)] b.solve_for_reaction_loads(M1, R1, R2, R3) assert b.reaction_loads == {R3: -P/2, R2: -5*P/4, M1: -P*l/4, R1: 3*P/4} assert b.slope().subs(x, 3*l) == -7*P*l**2/(48*E*I) assert b.deflection().subs(x, 2*l) == 7*P*l**3/(24*E*I) assert b.deflection().subs(x, 3*l) == 5*P*l**3/(16*E*I)
def test_composite_beam(): E = Symbol('E') I = Symbol('I') b1 = Beam(2, E, 1.5 * I) b2 = Beam(2, E, I) b = b1.join(b2, "fixed") b.apply_load(-20, 0, -1) b.apply_load(80, 0, -2) b.apply_load(20, 4, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0)] assert b.length == 4 assert b.second_moment == Piecewise((1.5 * I, x <= 2), (I, x <= 4)) assert b.slope().subs(x, 4) == 120.0 / (E * I) assert b.slope().subs(x, 2) == 80.0 / (E * I) assert int(b.deflection().subs(x, 4).args[0]) == 302 # Coefficient of 1/(E*I) l = symbols('l', positive=True) R1, M1, R2, R3, P = symbols('R1 M1 R2 R3 P') b1 = Beam(2 * l, E, I) b2 = Beam(2 * l, E, I) b = b1.join(b2, "hinge") b.apply_load(M1, 0, -2) b.apply_load(R1, 0, -1) b.apply_load(R2, l, -1) b.apply_load(R3, 4 * l, -1) b.apply_load(P, 3 * l, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0), (l, 0), (4 * l, 0)] b.solve_for_reaction_loads(M1, R1, R2, R3) assert b.reaction_loads == { R3: -P / 2, R2: -5 * P / 4, M1: -P * l / 4, R1: 3 * P / 4 } assert b.slope().subs(x, 3 * l) == -7 * P * l**2 / (48 * E * I) assert b.deflection().subs(x, 2 * l) == 7 * P * l**3 / (24 * E * I) assert b.deflection().subs(x, 3 * l) == 5 * P * l**3 / (16 * E * I) # When beams having same second moment are joined. b1 = Beam(2, 500, 10) b2 = Beam(2, 500, 10) b = b1.join(b2, "fixed") b.apply_load(M1, 0, -2) b.apply_load(R1, 0, -1) b.apply_load(R2, 1, -1) b.apply_load(R3, 4, -1) b.apply_load(10, 3, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0), (1, 0), (4, 0)] b.solve_for_reaction_loads(M1, R1, R2, R3) assert b.slope() == -2*SingularityFunction(x, 0, 1)/5625 + SingularityFunction(x, 0, 2)/1875\ - 133*SingularityFunction(x, 1, 2)/135000 + SingularityFunction(x, 3, 2)/1000\ - 37*SingularityFunction(x, 4, 2)/67500 assert b.deflection() == -SingularityFunction(x, 0, 2)/5625 + SingularityFunction(x, 0, 3)/5625\ - 133*SingularityFunction(x, 1, 3)/405000 + SingularityFunction(x, 3, 3)/3000\ - 37*SingularityFunction(x, 4, 3)/202500
def test_composite_beam(): E = Symbol('E') I = Symbol('I') b1 = Beam(2, E, 1.5*I) b2 = Beam(2, E, I) b = b1.join(b2, "fixed") b.apply_load(-20, 0, -1) b.apply_load(80, 0, -2) b.apply_load(20, 4, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0)] assert b.length == 4 assert b.second_moment == Piecewise((1.5*I, x <= 2), (I, x <= 4)) assert b.slope().subs(x, 4) == 120.0/(E*I) assert b.slope().subs(x, 2) == 80.0/(E*I) assert int(b.deflection().subs(x, 4).args[0]) == 302 # Coefficient of 1/(E*I) l = symbols('l', positive=True) R1, M1, R2, R3, P = symbols('R1 M1 R2 R3 P') b1 = Beam(2*l, E, I) b2 = Beam(2*l, E, I) b = b1.join(b2,"hinge") b.apply_load(M1, 0, -2) b.apply_load(R1, 0, -1) b.apply_load(R2, l, -1) b.apply_load(R3, 4*l, -1) b.apply_load(P, 3*l, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0), (l, 0), (4*l, 0)] b.solve_for_reaction_loads(M1, R1, R2, R3) assert b.reaction_loads == {R3: -P/2, R2: -5*P/4, M1: -P*l/4, R1: 3*P/4} assert b.slope().subs(x, 3*l) == -7*P*l**2/(48*E*I) assert b.deflection().subs(x, 2*l) == 7*P*l**3/(24*E*I) assert b.deflection().subs(x, 3*l) == 5*P*l**3/(16*E*I) # When beams having same second moment are joined. b1 = Beam(2, 500, 10) b2 = Beam(2, 500, 10) b = b1.join(b2, "fixed") b.apply_load(M1, 0, -2) b.apply_load(R1, 0, -1) b.apply_load(R2, 1, -1) b.apply_load(R3, 4, -1) b.apply_load(10, 3, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0), (1, 0), (4, 0)] b.solve_for_reaction_loads(M1, R1, R2, R3) assert b.slope() == -2*SingularityFunction(x, 0, 1)/5625 + SingularityFunction(x, 0, 2)/1875\ - 133*SingularityFunction(x, 1, 2)/135000 + SingularityFunction(x, 3, 2)/1000\ - 37*SingularityFunction(x, 4, 2)/67500 assert b.deflection() == -SingularityFunction(x, 0, 2)/5625 + SingularityFunction(x, 0, 3)/5625\ - 133*SingularityFunction(x, 1, 3)/405000 + SingularityFunction(x, 3, 3)/3000\ - 37*SingularityFunction(x, 4, 3)/202500
def Problem4_7(): x, y, z = symbols('x y z') A = lambda d: np.pi/4*d**2 I1 = MomentOfArea.MomentOfArea2("circle", 1, 1).momentEnglish I2 = MomentOfArea.MomentOfArea2("circle", 1, 1.5).momentEnglish I3 = MomentOfArea.MomentOfArea2("circle", 1, 1.75).momentEnglish gamma = 0.282 g = 32.2 * 12 L1 = 0.5 L2 = 8.0 L3 = 11.0 L4 = 0.5 A1 = A(1) A2 = A(1.5) A3 = A(1.75) A4 = A(1) # E, I = symbols('E, I') E = 30E6 init_printing(use_latex=True, wrap_line=False) b1 = Beam(L1, E, I1) b2 = Beam(L2, E, I2) b3 = Beam(L3, E, I3) b4 = Beam(L4, E, I1) ba = b1.join(b2, "fixed") bb = b2.join(ba, "fixed") bc = b3.join(bb, "fixed") b = b4.join(bc, "fixed") #Apply loads # -point load of 12 kN downward at x = 9 and of the -1 order or, -12<x-9>^-1 R1, R2 = symbols('R1, R2') # b.apply_load(R1, 0, -1) b.apply_load(-600, 8.5, -1) # -Moment # -Distributed load #Boundary conditions # -At 0,0 the deflection will be 0 b.bc_deflection.append((0, 0)) b.bc_deflection.append((0.5, 0)) # print(b.load) # -At 0, 0 the slope will be 0 # b.bc_slope.append((0, 0)) # R, M = symbols('R, M') b.apply_load(R1, 0, -1) b.apply_load(R2, 20, -1) # b.apply_load(R, 0, -1) # b.apply_load(M, 0, -2) b.solve_for_reaction_loads(R1, R2) # b.plot_shear_force() # b.plot_bending_moment() # Y = lambdify(x, b.plot_deflection(subs={E: 30E6}), "sympy") expr = b.deflection() # print(expr) m = b.max_deflection() f = lambdify(x, expr, "sympy") ans = f(5) L1c = L1/2 L2c = L1 + L2/2 L3c = L1 + L2 + L3/2 L4c = L1 + L2 + L3 + L4/2 w1 = gamma*g*L1*A1 w2 = gamma*g*L2*A2 w3 = gamma*g*L3*A3 w4 = gamma*g*L4*A4 omega = Fatigue.RayleighsLumpedMasses([w1, w2, w3, w4], [f(L1c), f(L2c), f(L3c), f(L4c)]) print(omega)
def test_cross_section(): I = Symbol('I') l = Symbol('l') E = Symbol('E') C3, C4 = symbols('C3, C4') a, c, g, h, r, n = symbols('a, c, g, h, r, n') # test for second_moment and cross_section setter b0 = Beam(l, E, I) assert b0.second_moment == I assert b0.cross_section == None b0.cross_section = Circle((0, 0), 5) assert b0.second_moment == pi*Rational(625, 4) assert b0.cross_section == Circle((0, 0), 5) b0.second_moment = 2*n - 6 assert b0.second_moment == 2*n-6 assert b0.cross_section == None with raises(ValueError): b0.second_moment = Circle((0, 0), 5) # beam with a circular cross-section b1 = Beam(50, E, Circle((0, 0), r)) assert b1.cross_section == Circle((0, 0), r) assert b1.second_moment == pi*r*Abs(r)**3/4 b1.apply_load(-10, 0, -1) b1.apply_load(R1, 5, -1) b1.apply_load(R2, 50, -1) b1.apply_load(90, 45, -2) b1.solve_for_reaction_loads(R1, R2) assert b1.load == (-10*SingularityFunction(x, 0, -1) + 82*SingularityFunction(x, 5, -1)/S(9) + 90*SingularityFunction(x, 45, -2) + 8*SingularityFunction(x, 50, -1)/9) assert b1.bending_moment() == (-10*SingularityFunction(x, 0, 1) + 82*SingularityFunction(x, 5, 1)/9 + 90*SingularityFunction(x, 45, 0) + 8*SingularityFunction(x, 50, 1)/9) q = (-5*SingularityFunction(x, 0, 2) + 41*SingularityFunction(x, 5, 2)/S(9) + 90*SingularityFunction(x, 45, 1) + 4*SingularityFunction(x, 50, 2)/S(9))/(pi*E*r*Abs(r)**3) assert b1.slope() == C3 + 4*q q = (-5*SingularityFunction(x, 0, 3)/3 + 41*SingularityFunction(x, 5, 3)/27 + 45*SingularityFunction(x, 45, 2) + 4*SingularityFunction(x, 50, 3)/27)/(pi*E*r*Abs(r)**3) assert b1.deflection() == C3*x + C4 + 4*q # beam with a recatangular cross-section b2 = Beam(20, E, Polygon((0, 0), (a, 0), (a, c), (0, c))) assert b2.cross_section == Polygon((0, 0), (a, 0), (a, c), (0, c)) assert b2.second_moment == a*c**3/12 # beam with a triangular cross-section b3 = Beam(15, E, Triangle((0, 0), (g, 0), (g/2, h))) assert b3.cross_section == Triangle(Point2D(0, 0), Point2D(g, 0), Point2D(g/2, h)) assert b3.second_moment == g*h**3/36 # composite beam b = b2.join(b3, "fixed") b.apply_load(-30, 0, -1) b.apply_load(65, 0, -2) b.apply_load(40, 0, -1) b.bc_slope = [(0, 0)] b.bc_deflection = [(0, 0)] assert b.second_moment == Piecewise((a*c**3/12, x <= 20), (g*h**3/36, x <= 35)) assert b.cross_section == None assert b.length == 35 assert b.slope().subs(x, 7) == 8400/(E*a*c**3) assert b.slope().subs(x, 25) == 52200/(E*g*h**3) + 39600/(E*a*c**3) assert b.deflection().subs(x, 30) == 537000/(E*g*h**3) + 712000/(E*a*c**3)