Exemplo n.º 1
0
    def bending_moment(
            self,
            factor=None,
            figsize=None,
            verbosity=0,
            scale=1,
            offset=(0, 0),
            show=True,
            gridplot=False,
    ):
        self.plot_structure(figsize,
                            1,
                            scale=scale,
                            offset=offset,
                            gridplot=gridplot)
        con = len(self.system.element_map[1].bending_moment)
        if factor is None:
            # maximum moment determined by comparing the node's moments and the sagging moments.
            max_moment = max(
                map(
                    lambda el: max(el.bending_moment, )
                    if el.type == "general" else 0,
                    self.system.element_map.values(),
                ))
            factor = det_scaling_factor(max_moment, self.max_val_structure)

        # determine the axis values
        for el in self.system.element_map.values():
            if (math.isclose(el.node_1.Ty, 0, rel_tol=1e-5, abs_tol=1e-9) and
                    math.isclose(el.node_2.Ty, 0, rel_tol=1e-5, abs_tol=1e-9)
                    and not el.all_q_load):
                # If True there is no bending moment, so no need for plotting.
                continue
            axis_values = plot_values_bending_moment(el, factor, con)
            if verbosity == 0:
                node_results = True
            else:
                node_results = False
            self.plot_result(
                axis_values,
                abs(el.node_1.Ty),
                abs(el.node_2.Ty),
                node_results=node_results,
            )

            if el.all_q_load:
                m_sag = min(el.bending_moment)
                index = find_nearest(el.bending_moment, m_sag)[1]
                offset = -self.max_val_structure * 0.05

                if verbosity == 0:
                    x = axis_values[0][index] + np.sin(-el.angle) * offset
                    y = axis_values[1][index] + np.cos(-el.angle) * offset
                    self.one_fig.text(x, y, "%s" % round(m_sag, 1), fontsize=9)
        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 2
0
    def bending_moment(self, factor=None, figsize=None, verbosity=0, scale=1, offset=(0, 0), show=True, gridplot=False):
        self.plot_structure(figsize, 1, scale=scale, offset=offset, gridplot=gridplot)
        con = len(self.system.element_map[1].bending_moment)
        if factor is None:
            # maximum moment determined by comparing the node's moments and the sagging moments.
            max_moment = max(map(lambda el: max(abs(el.node_1.Ty),
                                                abs((el.node_1.Ty - el.node_2.Ty) * 0.5 - 1 / 8
                                                    * el.all_q_load * el.l**2),) if el.type == 'general' else 0,
                                 self.system.element_map.values()))
            factor = det_scaling_factor(max_moment, self.max_val_structure)

        # determine the axis values
        for el in self.system.element_map.values():
            if math.isclose(el.node_1.Ty, 0, rel_tol=1e-5, abs_tol=1e-9) and \
                    math.isclose(el.node_2.Ty, 0, rel_tol=1e-5, abs_tol=1e-9) and not el.all_q_load:
                # If True there is no bending moment, so no need for plotting.
                continue
            axis_values = plot_values_bending_moment(el, factor, con)
            if verbosity == 0:
                node_results = True
            else:
                node_results = False
            self.plot_result(axis_values, abs(el.node_1.Ty), abs(el.node_2.Ty), node_results=node_results)

            if el.all_q_load:
                m_sag = min(el.bending_moment)
                index = find_nearest(el.bending_moment, m_sag)[1]
                offset = -self.max_val_structure * 0.05

                if verbosity == 0:
                    x = axis_values[0][index] + np.sin(-el.angle) * offset
                    y = axis_values[1][index] + np.cos(-el.angle) * offset
                    self.one_fig.text(x, y, "%s" % round(m_sag, 1),
                                      fontsize=9)
        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 3
0
    def bending_moment(
        self,
        factor=None,
        figsize=None,
        verbosity=0,
        scale=1,
        offset=(0, 0),
        show=True,
        gridplot=False,
        figure=None,
    ):
        self.plot_structure(figsize, 1, scale=scale, offset=offset, gridplot=gridplot, figure=figure)
        con = len(self.system.element_map[1].bending_moment)
        if factor is None:
            # maximum moment determined by comparing the node's moments and the sagging moments.
            max_moment = max(
                map(
                    lambda el: max(
                        abs(el.node_1.Ty),
                        abs(el.node_2.Ty),
                        abs(((el.all_qp_load[0] + el.all_qp_load[1]) / 16) * el.l ** 2),
                    )
                    if el.type == "general"
                    else 0,
                    self.system.element_map.values(),
                )
            )
            factor = det_scaling_factor(max_moment, self.max_val_structure)

        color_counter = 0
        # determine the axis values
        for el in self.system.element_map.values():
            if (
                math.isclose(el.node_1.Ty, 0, rel_tol=1e-5, abs_tol=1e-9)
                and math.isclose(el.node_2.Ty, 0, rel_tol=1e-5, abs_tol=1e-9)
                and math.isclose(el.all_qp_load[0], 0, rel_tol=1e-5, abs_tol=1e-9)
                and math.isclose(el.all_qp_load[1], 0, rel_tol=1e-5, abs_tol=1e-9)
            ):
                # If True there is no bending moment, so no need for plotting.
                continue
            axis_values = plot_values_bending_moment(el, factor, con)

            iteration_factor = np.linspace(0, 1, con)
            x = iteration_factor * el.l
            eq = np.polyfit(x, el.bending_moment, 3)

            x3, x2, x = symbols("x³ x² x")
            section_function = str(round(-eq[0], 2) * x3 + round(-eq[1], 2) * x2 + round(-eq[2], 2) * x +
                                   round(-eq[3], 2))

            if verbosity == 0:
                node_results = True
            else:
                node_results = False

            self.plot_result(
                axis_values,
                abs(el.node_1.Ty),
                abs(el.node_2.Ty),
                node_results=node_results,
                color=self.cs.color_list[color_counter],
                label=section_function,
            )

            color_counter += 1
            if color_counter > len(self.cs.color_list) - 1:
                color_counter = 0

            if el.all_qp_load:
                m_sag = min(el.bending_moment)
                index = find_nearest(el.bending_moment, m_sag)[1]
                offset = -self.max_val_structure * 0.05

                if verbosity == 0:
                    x = axis_values[0][index] + np.sin(-el.angle) * offset
                    y = axis_values[1][index] + np.cos(-el.angle) * offset
                    self.one_fig.text(x, y, "%s" % round(m_sag, 1), fontsize=settings.size)
        if show:
            self.plot()
        else:
            return self.fig