Ejemplo n.º 1
0
def test_beam_supports_are_correctly_added():
    span = 9
    my_beam = Beam(span)
    my_beam.rolling_support = 7

    assert my_beam._pinned_support == 2
    assert my_beam._rolling_support == 7
Ejemplo n.º 2
0
def test_beam_supports_must_be_within_span():
    span = 9
    my_beam = Beam(span)

    with pytest.raises(ValueError):
        my_beam.pinned_support = -3

    with pytest.raises(ValueError):
        my_beam.rolling_support = 10
Ejemplo n.º 3
0
def example_shear1():
    """Generate shear force introductory problem schematic"""
    my_beam = Beam(6)
    my_beam.rolling_support = 0  # x-coordinate of the rolling support
    my_beam.pinned_support = 3  # x-coordinate of the pinned support
    my_beam.add_loads([PointLoadV(10, 6)])  # 10kN pointing upwards, at x=6m
    fig = plt.figure()
    my_beam.plot_shear_force(fig.add_subplot(2, 1, 1))
    my_beam.plot_bending_moment(fig.add_subplot(2, 1, 2))

    # save the png and add it to the documentation
    mod_path = os.path.dirname(os.path.abspath(__file__))  # current module
    save_name = os.path.basename(__file__).replace('.py', '.png')  # file name
    save_path = os.path.join(mod_path, save_name)
    fig.savefig(save_path, transparent=True)
def example_normal1():
    """Generate normal force introductory problem schematic"""
    beam = Beam(6)
    beam.rolling_support = 0  # x-coordinate of the rolling support
    beam.pinned_support = 3    # x-coordinate of the pinned support
    beam.add_loads([PointLoadH(5, 6)])  # 5 kN pointing right, at x=6 m
    fig = beam.plot_normal_force()
    
    # save the png and add it to the documentation
    mod_path = os.path.dirname(os.path.abspath(__file__))  # current module
    save_name = os.path.basename(__file__).replace('.py', '.png')  # file name
    save_path = os.path.join(mod_path, save_name)
    fig.savefig(save_path, transparent=True)
Ejemplo n.º 5
0
def example_1():
    """Run example 1"""
    beam = Beam(9)  # Initialize a Beam object of length 9m
    beam.pinned_support = 2    # x-coordinate of the pinned support
    beam.rolling_support = 7  # x-coordinate of the rolling support
    beam.add_loads((
                    PointLoadH(10, 3),  # 10kN pointing right, at x=3m
                    PointLoadV(-20, 3),  # 20kN downwards, at x=3m
                    DistributedLoadV(-10, (3, 9)),  # 10 kN/m, downwards, for 3m <= x <= 9m
                    DistributedLoadV(-20 + x**2, (0, 2)),  # variable load, for 0m <= x <= 2m
                ))
    fig = beam.plot()

    # save the png and add it to the documentation
    mod_path = os.path.dirname(os.path.abspath(__file__))  # current module
    save_name = os.path.basename(__file__).replace('.py', '.png')  # file name
    save_path = os.path.join(mod_path, save_name)
    fig.savefig(save_path, transparent=True)
Ejemplo n.º 6
0
def defined_canonical_beam(span=9, pinned=2, rolling=7):
    my_beam = Beam(span)
    my_beam.pinned_support = pinned
    my_beam.rolling_support = rolling
    my_beam.add_loads([
        DistributedLoadV("-10", (3, 9)),
        PointLoadV(-20, 3),
        DistributedLoadV(-20, (0, 2)),
        PointLoadH(15, 5),
        DistributedLoadH("-2", (7, 9))
    ])
    x_vec = np.linspace(0, 9, 19)

    try:
        yield my_beam, x, x_vec
    finally:
        pass
def example_shear0():
    """Generate shear force introductory problem schematic"""
    my_beam = Beam(6)
    my_beam.rolling_support = 0  # x-coordinate of the rolling support
    my_beam.pinned_support = 3  # x-coordinate of the pinned support
    my_beam.add_loads([PointLoadV(10, 6)])  # 10kN pointing upwards, at x=6m
    fig = my_beam.plot_beam_diagram()
    ax = fig.gca()
    ax.text(0, -1.35, r'A', ha='center', va='top')
    ax.text(3, -1.35, r'B', ha='center', va='top')
    ax.text(5.9, -1.2, r'$P_1=10kN$', ha='right', va='top', color='darkgreen')
    ax.axvline(x=2, linestyle='--', color="k", alpha=0.5)
    ax.text(2, 0.5, r'Section 1-1', rotation=90, ha='right', va='bottom')
    ax.axvline(x=4, linestyle='--', color="k", alpha=0.5)
    ax.text(4, 0.5, r'Section 2-2', rotation=90, ha='right', va='bottom')
    ax.axvline(x=6, linestyle='--', color="k", alpha=0.5)
    ax.text(6, 0.5, r'Section 3-3', rotation=90, ha='right', va='bottom')

    # save the png and add it to the documentation
    mod_path = os.path.dirname(os.path.abspath(__file__))  # current module
    save_name = os.path.basename(__file__).replace('.py', '.png')  # file name
    save_path = os.path.join(mod_path, save_name)
    fig.savefig(save_path, transparent=True)
Ejemplo n.º 8
0
def test_beam_loads_are_correctly_added():
    span = 9
    my_beam = Beam(span)

    loads = [
        DistributedLoadV(-20, (0, 2)),
        PointLoadV(-20, 3),
        DistributedLoadV("-10", (3, 9)),
        PointLoadH(15, 5),
        DistributedLoadV("-2*x", (1, 3))
    ]
    my_beam.add_loads(loads)

    assert my_beam._loads[0] == DistributedLoadV(-20, (0, 2))
    assert my_beam._loads[1] == PointLoadV(-20, 3)
    assert my_beam._loads[2] == DistributedLoadV("-10", (3, 9))
    assert my_beam._loads[3] == PointLoadH(15, 5)
    assert my_beam._loads[4] == DistributedLoadH("-2*x", (1, 3))

    with pytest.raises(TypeError):
        my_beam.add_loads((10, (3, 9)))
Ejemplo n.º 9
0
def example_2():
    """Run example 2"""
    beam = Beam(9)
    beam.pinned_support = 2    # x-coordinate of the pinned support
    beam.rolling_support = 7  # x-coordinate of the rolling support
    eps = 1e-5
    beam.add_loads((
                    DistributedLoadV(-5+x - (x-2)**2 + (x-4)**3, (2+eps, 6.5)),
                    DistributedLoadV(-x**2*11/4, (0.0, 2)),
                    DistributedLoadV(-3+(x-6.5)**2*3/(2.5**2), (6.5+eps, 9)),
                ))
    fig = plt.figure(figsize=(6, 7.5))
    fig.subplots_adjust(hspace=0.4)

    ax1 = fig.add_subplot(3, 1, 1)
    beam.plot_beam_diagram(ax1)

    ax2 = fig.add_subplot(3, 1, 2)
    beam.plot_shear_force(ax2)

    ax3 = fig.add_subplot(3, 1, 3)
    beam.plot_bending_moment(ax3)

    # save the png and add it to the documentation
    mod_path = os.path.dirname(os.path.abspath(__file__))  # current module
    save_name = os.path.basename(__file__).replace('.py', '.png')  # file name
    save_path = os.path.join(mod_path, save_name)
    fig.savefig(save_path, transparent=True)
Ejemplo n.º 10
0
def example_3():
    """Run example 3"""
    beam = Beam(9)
    beam.pinned_support = 2  # x-coordinate of the pinned support
    beam.rolling_support = 7  # x-coordinate of the rolling support
    beam.add_loads((
        PointLoadV(3, 6),
        PointTorque(30, 4),
    ))
    fig = plt.figure(figsize=(6, 7.5))
    fig.subplots_adjust(hspace=0.4)

    ax1 = fig.add_subplot(3, 1, 1)
    beam.plot_beam_diagram(ax1)

    ax2 = fig.add_subplot(3, 1, 2)
    beam.plot_shear_force(ax2)

    ax3 = fig.add_subplot(3, 1, 3)
    beam.plot_bending_moment(ax3)

    # save the png and add it to the documentation
    mod_path = os.path.dirname(os.path.abspath(__file__))  # current module
    save_name = os.path.basename(__file__).replace('.py', '.png')  # file name
    save_path = os.path.join(mod_path, save_name)
    fig.savefig(save_path, transparent=True)
Ejemplo n.º 11
0
def test_beam_is_correctly_created():
    span = 9
    my_beam = Beam(span)
    assert my_beam._x0 == 0
    assert my_beam._x1 == 9