Beispiel #1
0
    def test_beam3(self):
        solver.solve(self.beams[3])

        #Test the solution
        self.assertEqual(-48.5, self.beams[3].interactions[0].magnitude)
        self.assertEqual(18, self.beams[3].interactions[4].magnitude)

        shear_moment = shearmomentgenerator.generate_numerical(self.beams[3], self.STEP_SIZE)

        #Test shear
        assert abs(shear_moment[0][0] - 0) < self.ALMOST
        assert abs(shear_moment[int(1/self.STEP_SIZE) -1][0] - 0) < self.ALMOST
        assert abs(shear_moment[int(1/self.STEP_SIZE) + 1][0] - 7) < self.ALMOST
        assert abs(shear_moment[int(2/self.STEP_SIZE) -1][0] - 7) < self.ALMOST
        assert abs(shear_moment[int(7/self.STEP_SIZE) +1][0] - (-18)) < self.ALMOST
        assert abs(shear_moment[int(8/self.STEP_SIZE) -1][0] - (-18)) < self.ALMOST
        assert abs(shear_moment[int(8/self.STEP_SIZE) +1][0] - (0)) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE) -1][0] - (0)) < self.ALMOST

        #Test moment
        assert abs(shear_moment[0][1] - 48.5) < self.ALMOST
        assert abs(shear_moment[int(1/self.STEP_SIZE) - 1][1] - 48.5) < self.ALMOST
        
        #Had to decrease criteria due to steep slope
        assert abs(shear_moment[int(8/self.STEP_SIZE) - 1][1] - 10) < 0.02
        assert abs(shear_moment[int(8/self.STEP_SIZE) +1][1] - 0) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE) -1][1] - 0) < self.ALMOST
    def do_plot(self, arguments, opts=None):
        """Plot the shear / moment diagram. Usage:
        plot [-s stepsize] (default step size 0.01)
        """

        step_size = 0.01

        annotate = False

        if opts.step != None:
            step_size = opts.step

        if opts.annotate != None:
            annotate = True

        #Generate the shear and moment points, using generate_numerical
        shear_moment = shearmomentgenerator.generate_numerical(self.beam, step_size)

        #Plot the points
        x = np.arange(0, self.beam.length, step_size)

        shear = [y[0] for y in shear_moment]
        moment = [y[1] for y in shear_moment]

        fig = plt.figure()

        shear_plot = fig.add_subplot(211)
        shear_plot.plot(x, shear)
        plt.title('Shear')

        moment_plot = fig.add_subplot(212)
        moment_plot.plot(x, moment)
        plt.title('Moment')

        #Experimental: annotate the plot with the magnitudes of the interactions
        if annotate:
            for interaction in self.beam.interactions:
                point_one = int(interaction.location / step_size) - 1
                point_two = int(interaction.location / step_size)
    
                
                shear_plot.annotate('(' + str(interaction.location) + 
                    ', ' + str(shear[point_one]) + ')', xy=(interaction.location, shear[point_one]), textcoords='offset points')
    
                if isinstance(interaction, Moment):
                    moment_plot.annotate('(' + str(interaction.location) + 
                        ', ' + str(moment[point_one]) + ')', xy=(interaction.location, moment[point_one]), textcoords='offset points')
    
                if interaction.location != self.beam.length:
                    shear_plot.annotate('(' + str(interaction.location) + 
                        ', ' + str(shear[point_two]) + ')', xy=(interaction.location, shear[point_two]), textcoords='offset points')
    
                    moment_plot.annotate('(' + str(interaction.location) + 
                        ', ' + str(moment[point_two]) + ')', xy=(interaction.location, moment[point_two]), textcoords='offset points')


        shear_plot.axis([min(x), max(x), min(shear) - self.PLOT_MARGIN * (max(shear)-min(shear)), max(shear) + self.PLOT_MARGIN * (max(shear)-min(shear))])
        moment_plot.axis([min(x), max(x), min(moment) - self.PLOT_MARGIN * (max(moment)-min(moment)), max(moment) + self.PLOT_MARGIN * (max(moment)-min(moment))])

        plt.show()
def plot_clicked():
    """Generate and display the force moment plot."""

    if len(beam.interactions) < 1:
        QtGui.QMessageBox.warning(window, "Error", "There is nothing to plot.")
        return

    # Clear the plot
    plt.clf()

    # Generate the shear and moment points, using generate_numerical
    try:
        shear_moment = shearmomentgenerator.generate_numerical(beam, step_size)
    except Shear_Moment_Error as e:
        QtGui.QMessageBox.warning(window, "Error", str(e))
        return

    # Plot the points
    x = np.arange(0, beam.length, step_size)

    shear = [y[0] for y in shear_moment]
    moment = [y[1] for y in shear_moment]

    shear_plot = figure.add_subplot(211)
    shear_plot.plot(x, shear)
    plt.title("Shear")

    moment_plot = figure.add_subplot(212)
    moment_plot.plot(x, moment)
    plt.title("Moment")

    # apply a buffer around the plot for easier viewing
    shear_plot.axis(
        [
            min(x),
            max(x),
            min(shear) - plot_margin * (max(shear) - min(shear)),
            max(shear) + plot_margin * (max(shear) - min(shear)),
        ]
    )

    moment_plot.axis(
        [
            min(x),
            max(x),
            min(moment) - plot_margin * (max(moment) - min(moment)),
            max(moment) + plot_margin * (max(moment) - min(moment)),
        ]
    )

    # update the canvas
    canvas.draw()
Beispiel #4
0
def plot_clicked():
    """Generate and display the force moment plot."""

    if len(beam.interactions) < 1:
        QtGui.QMessageBox.warning(window, "Error", "There is nothing to plot.")
        return

    #Clear the plot
    plt.clf()

    #Generate the shear and moment points, using generate_numerical
    try:
        shear_moment = shearmomentgenerator.generate_numerical(beam, step_size)
    except Shear_Moment_Error as e:
        QtGui.QMessageBox.warning(window, "Error", str(e))
        return

    #Plot the points
    x = np.arange(0, beam.length, step_size)

    shear = [y[0] for y in shear_moment]
    moment = [y[1] for y in shear_moment]

    shear_plot = figure.add_subplot(211)
    shear_plot.plot(x, shear)
    plt.title('Shear')

    moment_plot = figure.add_subplot(212)
    moment_plot.plot(x, moment)
    plt.title('Moment')

    #apply a buffer around the plot for easier viewing
    shear_plot.axis([
        min(x),
        max(x),
        min(shear) - plot_margin * (max(shear) - min(shear)),
        max(shear) + plot_margin * (max(shear) - min(shear))
    ])

    moment_plot.axis([
        min(x),
        max(x),
        min(moment) - plot_margin * (max(moment) - min(moment)),
        max(moment) + plot_margin * (max(moment) - min(moment))
    ])

    #update the canvas
    canvas.draw()
Beispiel #5
0
    def test_beam1(self):
        solver.solve(self.beams[1])

        #Test solution
        self.assertEqual(-10, self.beams[1].interactions[0].magnitude)
        self.assertEqual(-95, self.beams[1].interactions[1].magnitude)

        shear_moment = shearmomentgenerator.generate_numerical(self.beams[1], self.STEP_SIZE)

        #Test shear
        for item in shear_moment:
            assert abs(item[0] - (-10)) < self.ALMOST

        #Test moment
        assert abs(shear_moment[0][1] - 95) < self.ALMOST
        assert abs(shear_moment[int(4/self.STEP_SIZE - 1)][1] - 55 ) < self.ALMOST
        assert abs(shear_moment[int(5.5/self.STEP_SIZE) - 1][1] - 0) < self.ALMOST
Beispiel #6
0
    def test_beam0(self):

        solver.solve(self.beams[0])

        #Test solution
        self.assertEqual(5, self.beams[0].interactions[0].magnitude)
        self.assertEqual(5, self.beams[0].interactions[2].magnitude)
        
        shear_moment = shearmomentgenerator.generate_numerical(self.beams[0], self.STEP_SIZE)

        #Test moment
        assert abs(shear_moment[0][1] - 0 ) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE/2)][1] - 25) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE/4)][1] - 25/2) < self.ALMOST

        #Test shear
        assert abs(shear_moment[1][0] - 5) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE/2) -1][0] - 5 ) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE/2) +2][0] - (-5)) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE) -1][0] - (-5)) < self.ALMOST
Beispiel #7
0
    def test_beam2(self):
        solver.solve(self.beams[2])

        #Test the solution
        self.assertEqual(7.5, self.beams[2].interactions[0].magnitude)
        self.assertEqual(32.5, self.beams[2].interactions[3].magnitude)

        shear_moment = shearmomentgenerator.generate_numerical(self.beams[2], self.STEP_SIZE)

        #Test shear
        assert abs(shear_moment[0][0] - 7.5) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE)][0] - (-2.5)) < self.ALMOST
        assert abs(shear_moment[int(15/self.STEP_SIZE) - 1][0] - (-2.5)) < self.ALMOST
        assert abs(shear_moment[int(15/self.STEP_SIZE) + 1][0] - (-22.5)) < self.ALMOST
        assert abs(shear_moment[int(20/self.STEP_SIZE) - 1][0] - (-22.5)) < self.ALMOST
        assert abs(shear_moment[int(20/self.STEP_SIZE) + 1][0] - (10)) < self.ALMOST

        #Test moment
        assert abs(shear_moment[0][1] - 0) < self.ALMOST
        assert abs(shear_moment[int(10/self.STEP_SIZE)][1] - 25) < self.ALMOST
        assert abs(shear_moment[int(15/self.STEP_SIZE)][1] - 12.5) < self.ALMOST
        assert abs(shear_moment[int(20/self.STEP_SIZE)][1] - (-100)) < self.ALMOST
        assert abs(shear_moment[int(30/self.STEP_SIZE) -1][1] - 0) < self.ALMOST
Beispiel #8
0
    def test_shear_moment_error(self):

        with self.assertRaises(Shear_Moment_Error):
            shearmomentgenerator.generate_numerical(self.beams[0], self.STEP_SIZE)
Beispiel #9
0
    def do_plot(self, arguments, opts=None):
        """Plot the shear / moment diagram. Usage:
        plot [-s stepsize] (default step size 0.01)
        """

        step_size = 0.01

        annotate = False

        if opts.step != None:
            step_size = opts.step

        if opts.annotate != None:
            annotate = True

        #Generate the shear and moment points, using generate_numerical
        shear_moment = shearmomentgenerator.generate_numerical(
            self.beam, step_size)

        #Plot the points
        x = np.arange(0, self.beam.length, step_size)

        shear = [y[0] for y in shear_moment]
        moment = [y[1] for y in shear_moment]

        fig = plt.figure()

        shear_plot = fig.add_subplot(211)
        shear_plot.plot(x, shear)
        plt.title('Shear')

        moment_plot = fig.add_subplot(212)
        moment_plot.plot(x, moment)
        plt.title('Moment')

        #Experimental: annotate the plot with the magnitudes of the interactions
        if annotate:
            for interaction in self.beam.interactions:
                point_one = int(interaction.location / step_size) - 1
                point_two = int(interaction.location / step_size)

                shear_plot.annotate('(' + str(interaction.location) + ', ' +
                                    str(shear[point_one]) + ')',
                                    xy=(interaction.location,
                                        shear[point_one]),
                                    textcoords='offset points')

                if isinstance(interaction, Moment):
                    moment_plot.annotate('(' + str(interaction.location) +
                                         ', ' + str(moment[point_one]) + ')',
                                         xy=(interaction.location,
                                             moment[point_one]),
                                         textcoords='offset points')

                if interaction.location != self.beam.length:
                    shear_plot.annotate('(' + str(interaction.location) +
                                        ', ' + str(shear[point_two]) + ')',
                                        xy=(interaction.location,
                                            shear[point_two]),
                                        textcoords='offset points')

                    moment_plot.annotate('(' + str(interaction.location) +
                                         ', ' + str(moment[point_two]) + ')',
                                         xy=(interaction.location,
                                             moment[point_two]),
                                         textcoords='offset points')

        shear_plot.axis([
            min(x),
            max(x),
            min(shear) - self.PLOT_MARGIN * (max(shear) - min(shear)),
            max(shear) + self.PLOT_MARGIN * (max(shear) - min(shear))
        ])
        moment_plot.axis([
            min(x),
            max(x),
            min(moment) - self.PLOT_MARGIN * (max(moment) - min(moment)),
            max(moment) + self.PLOT_MARGIN * (max(moment) - min(moment))
        ])

        plt.show()