Example #1
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)
Example #2
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)
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)