def test_simply_supported_beam_offset_load(): """simple beam - concentrated load at arbitrary points Load case 8 """ locations = [2, 3, 5, 7, 8] for location in locations: # Exact setup a = location b = L - a R1 = -P * b / L R2 = -P * a / L M_loc = -P * a * b / L # moment at load d_loc = P * a**2 * b**2 / (3 * EI * L) # deflection at load # numerical result beam = Beam( L, loads=[PointLoad(P, location)], reactions=[PinnedReaction(x) for x in [0, L]], E=E, Ixx=Ixx, ) beam.solve() # verify reactions validate(beam, loc=location, R=[(R1, 0), (R2, 0)], M_loc=M_loc, d_loc=d_loc)
def test_simply_supported_beam_unequal_non_symmetric_loads(): """Simple beam: Two unequal concentrated loads non-symmetrically placed load case 11 """ P1 = -900 P2 = -1200 a = L / 4 # location of first load from right b = L / 5 # location of second load from left R1 = -(P1 * (L - a) + P2 * b) / L R2 = -(P1 * a + P2 * (L - b)) / L M1 = R1 * a x = L / 2 Mx = R1 * x + P1 * (x - a) M2 = R2 * b p = [ PointLoad(magnitude=P1, location=a), PointLoad(magnitude=P2, location=L - b) ] r = [PinnedReaction(x) for x in [0, L]] beam = Beam(length=L, loads=p, reactions=r, E=E, Ixx=Ixx) beam.solve() # verify reactions for m, loc in zip((M1, Mx, M2), (a, L / 2, L - b)): # assert approx(beam.reactions[0].value[0], rel=1e-4) == R1*1.25 validate(beam, loc=loc, R=[(R1, 0), (R2, 0)], M_loc=m, d_loc=None)
def test_solve_method(): beam = Beam(25, [PointLoad(-100, 25)], [FixedReaction(0)], 29e6, 345) reaction = beam.reactions[0] assert reaction.force is None, "Reaction force was not None before being solved" assert reaction.moment is None, "Reaction moment was not None before being solved" beam.solve() reaction = beam.reactions[0] assert reaction.force == 100, "Reaction force must be equal to and opposite load" assert ( reaction.moment == 100 * 25), "Reaction moment must be equal to the load times the moment arm"
def test_simply_supported_beam_equal_symmetric_loads(): """Simple beam: Two equal concentrated loads symmetrically placed load case 9 """ R = -P # both reactions are equal a = L / 4 M_loc = -P * a # max moment (at center between loads) d_loc = P * a / (24 * EI) * (3 * L**2 - 4 * a**2 ) # max deflection (at center) p = [PointLoad(magnitude=P, location=x) for x in [a, L - a]] r = [PinnedReaction(x) for x in [0, L]] beam = Beam(length=L, loads=p, reactions=r, E=E, Ixx=Ixx) beam.solve() # verify reactions validate(beam, loc=L / 2, R=[(R, 0), (R, 0)], M_loc=M_loc, d_loc=d_loc)
def example_2(): """ Cantilevered Beam with 3 Pinned Supports and End Loading """ print("=" * 79) print("Example 2") print("Show an example with 3 Pinned Supports and End Loading\n") beam_len = 10 # Note that both the reaction and load are both lists. They must always be # given to Beam as a list, r = [PinnedReaction(0), PinnedReaction(2), PinnedReaction(6)] # define reactions p = [PointLoad(magnitude=-2, location=beam_len)] # define loads b = Beam(beam_len, loads=p, reactions=r, E=29e6, Ixx=125) # an explicit solve is required to calculate the reaction values b.solve() print(b)
def test_simply_supported_beam_center_load(): """simple beam - concentrated load at center Load case 7 """ # Exact setup R = -P / 2 # lbs, reactions M_max = -P * L / 4 # psi, maximum moment d_max = P * L**3 / (48 * EI) # max displacement # Numerical setup beam = Beam( length=L, loads=[PointLoad(magnitude=P, location=L / 2)], reactions=[PinnedReaction(x) for x in [0, L]], E=E, Ixx=Ixx, ) beam.solve() validate(beam, loc=L / 2, R=[(R, 0), (R, 0)], M_loc=M_max, d_loc=d_max)
def example_1(): """ Cantilevered Beam with Fixed Support and End Loading """ print("=" * 79) print("Example 1") print( "Show an example with a cantilevered beam with a fixed support and " "point load at the end\n" ) beam_len = 10 # Note that both the reaction and load are both lists. They must always be # given to Beam as a list, r = [FixedReaction(0)] # define reactions as list p = [PointLoad(magnitude=-2, location=beam_len)] # define loads as list b = Beam(beam_len, loads=p, reactions=r, E=29e6, Ixx=125) # an explicit solve is required to calculate the reaction values b.solve() print(b)
def test_cantilevered_beam_load_at_end(): """fixed beam with concentrated load at free end case 13 """ R = -P M_max = P * L # at fixed end d_max = P * L**3 / (3 * EI) # at free end beam = Beam( length=L, loads=[PointLoad(magnitude=P, location=0)], reactions=[FixedReaction(L)], E=E, Ixx=Ixx, ) beam.solve() validate(beam, loc=0, R=[(R, M_max)], M_loc=0, d_loc=d_max) assert pytest.approx(beam.moment(L), rel=TOL) == M_max
def test_simply_supported_beam_equal_non_symmetric_loads(): """Simple beam: Two equal concentrated loads non-symmetrically placed load case 10 """ a = L / 4 # location of first load from right b = L / 5 # location of second load from left R1 = -P / L * (L - a + b) R2 = -P / L * (L + a - b) M1 = R1 * a # moment at first load x = L / 2 Mx = R1 * x + P * (x - a) # moment at center M2 = R2 * b # moment at second load p = [PointLoad(magnitude=P, location=x) for x in [a, L - b]] r = [PinnedReaction(x) for x in [0, L]] beam = Beam(length=L, loads=p, reactions=r, E=E, Ixx=Ixx) beam.solve() # verify reactions for m, loc in zip((M1, Mx, M2), (a, L / 2, L - b)): validate(beam, loc=loc, R=[(R1, 0), (R2, 0)], M_loc=m, d_loc=None)