Exemplo n.º 1
0
    def axial_force(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)

        node_results = True if verbosity == 0 else False
        if factor is None:
            max_force = max(map(
                lambda el: max(abs(el.N_1), abs(el.N_2)),
                self.system.element_map.values()))
            factor = det_scaling_factor(max_force, self.max_val_structure)

        for el in self.system.element_map.values():
            if math.isclose(el.N_1, 0, rel_tol=1e-5, abs_tol=1e-9):
                continue
            else:
                axis_values = plot_values_axial_force(el, factor)

                self.plot_result(axis_values, el.N_1, el.N_2, node_results=node_results)

                point = (el.vertex_2 - el.vertex_1) / 2 + el.vertex_1
                if el.N_1 < 0:
                    point.displace_polar(alpha=el.angle + 0.5 * np.pi, radius=0.5 * el.N_1 * factor, inverse_z_axis=True)

                    if verbosity == 0:
                        self.one_fig.text(point.x, point.y, "-", ha='center', va='center',
                                          fontsize=20, color='b')
                if el.N_1 > 0:
                    point.displace_polar(alpha=el.angle + 0.5 * np.pi, radius=0.5 * el.N_1 * factor, inverse_z_axis=True)

                    if verbosity == 0:
                        self.one_fig.text(point.x, point.y, "+", ha='center', va='center',
                                          fontsize=14, color='b')

        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 2
0
    def axial_force(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)

        node_results = True if verbosity == 0 else False
        if factor is None:
            max_force = max(map(
                lambda el: max(abs(el.N_1), abs(el.N_2)),
                self.system.element_map.values()))
            factor = det_scaling_factor(max_force, self.max_val_structure)

        for el in self.system.element_map.values():
            if math.isclose(el.N_1, 0, rel_tol=1e-5, abs_tol=1e-9):
                continue
            else:
                axis_values = plot_values_axial_force(el, factor)

                self.plot_result(axis_values, el.N_1, el.N_2, node_results=node_results)

                point = (el.vertex_2 - el.vertex_1) / 2 + el.vertex_1
                if el.N_1 < 0:
                    point.displace_polar(alpha=el.angle + 0.5 * np.pi, radius=0.5 * el.N_1 * factor, inverse_z_axis=True)

                    if verbosity == 0:
                        self.one_fig.text(point.x, point.y, "-", ha='center', va='center',
                                          fontsize=20, color='b')
                if el.N_1 > 0:
                    point.displace_polar(alpha=el.angle + 0.5 * np.pi, radius=0.5 * el.N_1 * factor, inverse_z_axis=True)

                    if verbosity == 0:
                        self.one_fig.text(point.x, point.y, "+", ha='center', va='center',
                                          fontsize=14, color='b')

        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 3
0
    def axial_force(
        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].axial_force)

        if factor is None:
            max_force = max(
                map(
                    lambda el: max(
                        abs(el.N_1),
                        abs(el.N_2),
                        abs(((el.all_qn_load[0] + el.all_qn_load[1]) / 16) * el.l ** 2),
                    ),
                    self.system.element_map.values(),
                )
            )
            factor = det_scaling_factor(max_force, self.max_val_structure)

        color_counter = 0
        for el in self.system.element_map.values():
            if (
                math.isclose(el.N_1, 0, rel_tol=1e-5, abs_tol=1e-9)
                and math.isclose(el.N_2, 0, rel_tol=1e-5, abs_tol=1e-9)
                and math.isclose(el.all_qn_load[0], 0, rel_tol=1e-5, abs_tol=1e-9)
                and math.isclose(el.all_qn_load[1], 0, rel_tol=1e-5, abs_tol=1e-9)
            ):
                continue
            else:
                axis_values = plot_values_axial_force(el, factor, con)
                color = 1 if el.N_1 < 0 else 0
                self.plot_result(
                    axis_values,
                    el.N_1,
                    el.N_2,
                    node_results=not bool(verbosity),
                    color=self.cs.color_list[color_counter],
                    label=round(el.N_1, 2)
                )

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

                point = (el.vertex_2 - el.vertex_1) / 2 + el.vertex_1
                if el.N_1 < 0:
                    point.displace_polar(
                        alpha=el.angle + 0.5 * np.pi,
                        radius=0.5 * el.N_1 * factor,
                        inverse_z_axis=True,
                    )

                    if verbosity == 0:
                        self.one_fig.text(
                            point.x,
                            point.y,
                            "-",
                            ha="center",
                            va="center",
                            fontsize=settings.size,
                            color=self.cs.axial_text,
                        )
                if el.N_1 > 0:
                    point.displace_polar(
                        alpha=el.angle + 0.5 * np.pi,
                        radius=0.5 * el.N_1 * factor,
                        inverse_z_axis=True,
                    )

                    if verbosity == 0:
                        self.one_fig.text(
                            point.x,
                            point.y,
                            "+",
                            ha="center",
                            va="center",
                            fontsize=settings.size,
                            color=self.cs.axial_text,
                        )

        if show:
            self.plot()
        else:
            return self.fig