Esempio n. 1
0
def get_hinges_from_elem(elem, members, hinges_global, lcsysd, xvec, zvec,
                         yvec):
    """

    :param elem:
    :param members:
    :param hinges_global:
    :type elem: ada.Elem
    :return:
    """
    if len(elem.nodes) > 2:
        raise ValueError(
            "This algorithm was not designed for more than 2 noded elements")
    from ada.core.utils import unit_vector

    hinges = []
    for i, x in enumerate(members):
        if i >= len(elem.nodes):
            break
        if x == 0:
            continue
        if x not in hinges_global.keys():
            raise ValueError("fixno not found!")
        opt, trano, a1, a2, a3, a4, a5, a6 = hinges_global[x]
        n = elem.nodes[i]
        if trano > 0:
            csys = None
        else:
            csys = Csys(
                f"el{elem.id}_hinge{i + 1}_csys",
                coords=([
                    unit_vector(xvec) + n.p,
                    unit_vector(yvec) + n.p, n.p
                ]),
                parent=elem.parent,
            )
        dofs_origin = [1, 2, 3, 4, 5, 6]
        d = [
            int(x) for x, i in zip(dofs_origin, (a1, a2, a3, a4, a5, a6))
            if int(i) != 0
        ]

        hinges.append((n, d, csys))
    return hinges
Esempio n. 2
0
        def calc_sh_elem(el):
            """

            :param el:
            :type el: ada.Elem
            """
            locz = el.fem_sec.local_z if el.fem_sec.local_z is not None else normal_to_points_in_plane(
                el.nodes)
            locx = unit_vector(el.nodes[1].p - el.nodes[0].p)
            locy = np.cross(locz, locx)
            origin = el.nodes[0]
            t = el.fem_sec.thickness

            ln = global_2_local_nodes([locx, locy], origin, el.nodes)
            x, y, z = list(zip(*ln))
            area = poly_area(x, y)
            vol_ = t * area
            mass = vol_ * el.fem_sec.material.model.rho
            center = sum([e.p for e in el.nodes]) / len(el.nodes)

            return mass, center, vol_
Esempio n. 3
0
        def calc_sh_elem(el):
            """

            :param el:
            :type el: ada.Elem
            """
            locz = el.fem_sec.local_z if el.fem_sec.local_z is not None else normal_to_points_in_plane(el.nodes)
            locx = unit_vector(el.nodes[1].p - el.nodes[0].p)
            locy = np.cross(locz, locx)
            origin = el.nodes[0]
            t = el.fem_sec.thickness

            ln = global_2_local_nodes([locx, locy], origin, el.nodes)
            x, y, z = list(zip(*ln))
            area = poly_area(x, y)
            vol = t * area
            mass = vol * el.fem_sec.material.model.rho
            mass_per_node = mass / len(el.nodes)

            # Have not added offset to fem_section yet
            # adjusted_nodes = [e.p+t*normal for e in el.nodes]

            return mass_per_node, [e for e in el.nodes], vol
Esempio n. 4
0
    def get_femsecs(match):
        d = match.groupdict()
        geono = str_to_int(d["geono"])
        next(total_geo)
        transno = str_to_int(d["transno"])
        elno = str_to_int(d["elno"])
        elem = fem.elements.from_id(elno)

        matno = str_to_int(d["matno"])

        # Go no further if element has no fem section
        if elem.type in ElemShapes.springs + ElemShapes.masses:
            next(importedgeom_counter)
            elem.metadata["matno"] = matno
            return None

        mat = fem.parent.materials.get_by_id(matno)
        if elem.type in ElemShapes.beam:
            next(importedgeom_counter)
            sec = fem.parent.sections.get_by_id(geono)
            n1, n2 = elem.nodes
            v = n2.p - n1.p
            if vector_length(v) == 0.0:
                xvec = [1, 0, 0]
            else:
                xvec = unit_vector(v)
            zvec = lcsysd[transno]
            crossed = np.cross(zvec, xvec)
            ma = max(abs(crossed))
            yvec = tuple([roundoff(x / ma, 3) for x in crossed])

            fix_data = str_to_int(d["fixno"])
            ecc_data = str_to_int(d["eccno"])

            members = None
            if d["members"] is not None:
                members = [
                    str_to_int(x)
                    for x in d["members"].replace("\n", " ").split()
                ]

            hinges = None
            if fix_data == -1:
                hinges = get_hinges_from_elem(elem, members, hinges_global,
                                              lcsysd, xvec, zvec, yvec)

            offset = None
            if ecc_data == -1:
                offset = get_ecc_from_elem(elem, members, eccentricities,
                                           fix_data)

            fem_set = FemSet(sec.name, [elem],
                             "elset",
                             metadata=dict(internal=True),
                             parent=fem)
            fem.sets.add(fem_set, append_suffix_on_exist=True)
            fem_sec = FemSection(
                name=sec.name,
                sec_type="beam",
                elset=fem_set,
                section=sec,
                local_z=zvec,
                local_y=yvec,
                material=mat,
                offset=offset,
                hinges=hinges,
                parent=fem,
            )
            return fem_sec

        elif elem.type in ElemShapes.shell:
            next(importedgeom_counter)
            sec_name = f"sh{elno}"
            fem_set = FemSet(sec_name, [elem],
                             "elset",
                             parent=fem,
                             metadata=dict(internal=True))
            fem.sets.add(fem_set)
            fem_sec = FemSection(
                name=sec_name,
                sec_type="shell",
                thickness=roundoff(thicknesses[geono]),
                elset=fem_set,
                material=mat,
                parent=fem,
            )
            return fem_sec
        else:
            raise ValueError("Section not added to conversion")
Esempio n. 5
0
    def test_basic_arc2(self):
        from ada.core.utils import (
            angle_between,
            intersect_line_circle,
            linear_2dtransform_rotate,
            local_2_global_nodes,
            unit_vector,
        )

        origin = (0, 0, 0)
        xdir = (1, 0, 0)
        normal = (0, -1, 0)

        p1 = np.array([-150, 100])
        p2 = np.array([-74, 81])
        p3 = np.array([-20, 0])
        radius = 40

        v1 = unit_vector(p2 - p1)
        v2 = unit_vector(p2 - p3)

        alpha = angle_between(v1, v2)
        s = radius / np.sin(alpha / 2)

        dir_eval = np.cross(v1, v2)

        if dir_eval < 0:
            theta = -alpha / 2
        else:
            theta = alpha / 2

        A = p2 - v1 * s

        center = linear_2dtransform_rotate(p2, A, np.rad2deg(theta))
        start = intersect_line_circle((p1, p2), center, radius)
        end = intersect_line_circle((p3, p2), center, radius)

        vc1 = np.array([start[0], start[1], 0.0]) - np.array(
            [center[0], center[1], 0.0])
        vc2 = np.array([end[0], end[1], 0.0]) - np.array(
            [center[0], center[1], 0.0])

        arbp = angle_between(vc1, vc2)

        if dir_eval < 0:
            gamma = arbp / 2
        else:
            gamma = -arbp / 2
        midp = linear_2dtransform_rotate(center, start, np.rad2deg(gamma))
        glob_c = local_2_global_nodes([center], origin, xdir, normal)[0]
        glob_s = local_2_global_nodes([start], origin, xdir, normal)[0]
        glob_e = local_2_global_nodes([end], origin, xdir, normal)[0]
        glob_midp = local_2_global_nodes([midp], origin, xdir, normal)[0]

        res_center = (-98.7039754, 0.0, 45.94493759)
        res_start = (-89.00255040102925, 0, 84.75063760025732)
        res_end = (-65.4219636289688, 0, 68.1329454434532)
        res_midp = (-75.66203793182973, 0, 78.64156001325857)

        for r, e in zip(res_start, glob_s):
            assert roundoff(r, 5) == roundoff(e, 5)

        for r, e in zip(res_end, glob_e):
            assert roundoff(r, 4) == roundoff(e, 4)

        for r, e in zip(res_midp, glob_midp):
            assert roundoff(r, 4) == roundoff(e, 4)

        for r, e in zip(res_center, glob_c):
            assert roundoff(r, 4) == roundoff(e, 4)