Beispiel #1
0
def plot_bending_modes(nodes, n=3):
    print "\nPloting {0} first bending modes:".format(n)
    f, axarr = plt.subplots(n, sharex=True)
    for j, N in enumerate(nodes):
        beam = BendingBeam(L, S, mat, BCs=[0, 1], nodes=N)
        eigs = beam.get_modes()

        for i, (eigval, eigvec) in enumerate(eigs[:n]):
            print "N:", N, ", f=", eigval, "Hz"
            y = eigvec[::2] / eigvec[-2]
            x = np.linspace(0, L, len(y))
            axarr[i].plot(x, y, styles[j])

    axarr[n-1].set_xlabel(r"Length of the beam ($y$ axis) in meters")
    axarr[n/2].set_ylabel("Normalized vertical deflection")

    for i, (f, mode) in enumerate(cantilever_bending_modes(beam, n, points=20)):
        print f, "Hz"
        x = mode.T[0]
        y = mode.T[1]
        axarr[i].plot(x, y, styles[2])
        axarr[i].grid()
    axarr[n/2].legend(["N = 8", "N = 20", "static"],
                      loc='center right',
                      bbox_to_anchor=(1.3, 0.5))

    plt.subplots_adjust(right=0.8)
Beispiel #2
0
    for i, (f, f_i) in enumerate(zip(freqs, freqs_i)):
        plt.plot(nodes, abs(f-f_i)/f*100, bstyles[i])

    plt.legend(["$f = %.2f Hz$" % f for f in freqs])
    plt.xlabel(r'Number of nodes')
    plt.ylabel(r'Relative error $\epsilon = |f_n - f|/f*100$ (%)')
    plt.grid()


if __name__ == "__main__":
    nodes = [8, 20]
    n = 6
    legend = [r"N = {0}".format(i) for i in nodes] + [r"analytic"]
    bending_beam_8 = BendingBeam(L, S, mat, BCs=[0, 1], nodes=8)
    bending_beam_20 = BendingBeam(L, S, mat, BCs=[0, 1], nodes=20)
    bending_modes_8 = map(lambda x: (r"N = 8", x[0], x[1][::2]),
                          bending_beam_8.get_modes()[:n])
    bending_modes_20 = map(lambda x: (r"N = 20", x[0], x[1][::2]),
                           bending_beam_20.get_modes()[:n])
    bending_modes = cantilever_bending_modes(bending_beam_8, n)
    bending_modes = map(lambda x: (r"analytic", x[0], x[1].T[1]),
                        bending_modes)

    subplot_modes(zip(bending_modes_8, bending_modes_20, bending_modes))

    # plot_bending_modes(nodes, n)
    # plot_twisting_modes(nodes, n)
    # plot_twisting_errors(range(8, 101, 2), 6)
    plt.show()