Exemplo n.º 1
0
    def shear_force(
        self,
        factor=None,
        figsize=None,
        verbosity=0,
        scale=1,
        offset=(0, 0),
        show=True,
        gridplot=False,
        include_structure=True,
        figure=None,
    ):
        if include_structure:
            self.plot_structure(
                figsize, 1, scale=scale, offset=offset, gridplot=gridplot, figure=figure
            )
        con = len(self.system.element_map[1].shear_force)
        if factor is None:
            max_force = max(
                map(
                    lambda el: np.max(np.abs(el.shear_force)),
                    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.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 and no shear, thus no shear force, so no need for plotting.
                continue

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

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

            axis_values = plot_values_shear_force(el, factor)
            shear_1 = el.shear_force[0]
            shear_2 = el.shear_force[-1]

            self.plot_result(
                axis_values, shear_1, shear_2, node_results=not bool(verbosity),
                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 show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 2
0
    def shear_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)
        if factor is None:
            max_force = max(map(lambda el: np.max(np.abs(el.shear_force)), 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.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 el.q_load is None:
                # If True there is no bending moment and no shear, thus no shear force, so no need for plotting.
                continue
            axis_values = plot_values_shear_force(el, factor)
            shear_1 = el.shear_force[0]
            shear_2 = el.shear_force[-1]

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

            self.plot_result(axis_values, shear_1, shear_2, node_results=node_results)
        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 3
0
    def displacements(self, factor=None, figsize=None, verbosity=0, scale=1, offset=(0, 0), show=True, linear=False,
                      gridplot=False):
        self.plot_structure(figsize, 1, scale=scale, offset=offset, gridplot=gridplot)
        if factor is None:
            # needed to determine the scaling factor
            max_displacement = max(map(
                lambda el: max(abs(el.node_1.ux), abs(el.node_1.uz), el.max_deflection) if el.type == 'general' else 0,
                                       self.system.element_map.values()))
            factor = det_scaling_factor(max_displacement, self.max_val_structure)

        for el in self.system.element_map.values():
            axis_values = plot_values_deflection(el, factor, linear)
            self.plot_result(axis_values, node_results=False)

            if el.type == "general":
                # index of the max deflection
                index = np.argmax(np.abs(el.deflection))

                if verbosity == 0:
                    x = (el.node_1.ux + el.node_2.ux) / 2
                    y = (-el.node_1.uz + -el.node_2.uz) / 2

                    if index != 0 or index != el.deflection.size:
                        self._add_element_values(axis_values[0], axis_values[1],
                                                 el.deflection[index] + (x ** 2 + y ** 2) ** 0.5, index, 3)
        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 4
0
    def displacements(self, factor=None, figsize=None, verbosity=0, scale=1, offset=(0, 0), show=True, linear=False,
                      gridplot=False):
        self.plot_structure(figsize, 1, scale=scale, offset=offset, gridplot=gridplot)
        if factor is None:
            # needed to determine the scaling factor
            max_displacement = max(map(
                lambda el: max(abs(el.node_1.ux), abs(el.node_1.uz), el.max_deflection) if el.type == 'general' else 0,
                                       self.system.element_map.values()))
            factor = det_scaling_factor(max_displacement, self.max_val_structure)

        for el in self.system.element_map.values():
            axis_values = plot_values_deflection(el, factor, linear)
            self.plot_result(axis_values, node_results=False)

            if el.type == "general":
                # index of the max deflection
                index = np.argmax(np.abs(el.deflection))

                if verbosity == 0:
                    x = (el.node_1.ux + el.node_2.ux) / 2
                    y = (-el.node_1.uz + -el.node_2.uz) / 2

                    if index != 0 or index != el.deflection.size:
                        self._add_element_values(axis_values[0], axis_values[1],
                                                 el.deflection[index] + (x ** 2 + y ** 2) ** 0.5, index, 3)
        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 5
0
    def shear_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)
        if factor is None:
            max_force = max(map(lambda el: np.max(np.abs(el.shear_force)), 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.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 el.q_load is None:
                # If True there is no bending moment and no shear, thus no shear force, so no need for plotting.
                continue
            axis_values = plot_values_shear_force(el, factor)
            shear_1 = el.shear_force[0]
            shear_2 = el.shear_force[-1]

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

            self.plot_result(axis_values, shear_1, shear_2, node_results=node_results)
        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 6
0
    def displacements(
            self,
            factor=None,
            figsize=None,
            verbosity=0,
            scale=1,
            offset=(0, 0),
            show=True,
            linear=False,
            gridplot=False,
    ):
        self.plot_structure(figsize,
                            1,
                            scale=scale,
                            offset=offset,
                            gridplot=gridplot)
        if factor is None:
            # needed to determine the scaling factor
            max_displacement = max(
                map(
                    lambda el: max(abs(el.node_1.ux), abs(el.node_1.uz), el.
                                   max_deflection)
                    if el.type == "general" else 0,
                    self.system.element_map.values(),
                ))
            factor = det_scaling_factor(max_displacement,
                                        self.max_val_structure)

        for el in self.system.element_map.values():
            axis_values = plot_values_deflection(el, factor, linear)
            self.plot_result(axis_values,
                             node_results=False,
                             fill_polygon=False)

            if el.type == "general":
                # index of the max deflection
                x = np.linspace(el.vertex_1.x, el.vertex_2.x,
                                el.deflection.size)
                y = np.linspace(el.vertex_1.y, el.vertex_2.y,
                                el.deflection.size)
                xd, yd = plot_values_deflection(el, 1.0, linear)
                deflection = ((xd - x)**2 + (yd - y)**2)**0.5
                index = np.argmax(np.abs(deflection))

                if verbosity == 0:

                    if index != 0 or index != el.deflection.size:
                        self._add_element_values(
                            axis_values[0],
                            axis_values[1],
                            deflection[index],
                            index,
                            3,
                        )
        if show:
            self.plot()
        else:
            return self.fig
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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
Exemplo n.º 12
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