Exemplo n.º 1
0
def convert_springs_to_connectors(assembly):
    """
    Converts all single noded springs to connector elements

    :param assembly:
    :type assembly: ada.Assembly
    """
    import numpy as np

    from ada import Node
    from ada.fem import Bc, Connector, ConnectorSection, FemSet

    for p in assembly.get_all_subparts():
        for spring in p.fem.springs.values():
            n1 = spring.nodes[0]
            n2 = Node(n1.p - np.array([0, 0, 10e-3]))
            assembly.fem.add_rp(spring.name + "_rp", n2)
            fs = FemSet(spring.name + "_bc", [n2], "nset")
            assembly.fem.add_set(fs)
            assembly.fem.add_bc(Bc(spring.name + "_bc", fs,
                                   [1, 2, 3, 4, 5, 6]))
            diag = []
            for dof, row in enumerate(spring.stiff):
                for j, stiffness in enumerate(row):
                    if dof == j:
                        diag.append(stiffness)

            con_sec = ConnectorSection(spring.name + "_consec", diag, [])
            assembly.fem.add_connector_section(con_sec)
            con = Connector(spring.name + "_con", spring.id, n1, n2, "bushing",
                            con_sec)
            assembly.fem.add_connector(con)
        p.fem._springs = dict()
        p.fem.elements.filter_elements(delete_elem=["SPRING1"])
Exemplo n.º 2
0
def get_connector_sections_from_bulk(bulk_str: str, parent: FEM) -> dict[str, ConnectorSection]:
    import numpy as np

    consecsd = dict()

    for m in cards.connector_behaviour.regex.finditer(bulk_str):
        d = m.groupdict()
        name = d["name"]
        comp = int(d["component"])

        res = np.fromstring(list_cleanup(d["bulk"]), sep=",", dtype=np.float64)
        size = res.size
        cols = comp + 1
        rows = int(size / cols)
        res_ = res.reshape(rows, cols)
        consecsd[name] = ConnectorSection(name, [res_], [], metadata=d, parent=parent)
    return consecsd
Exemplo n.º 3
0
def get_connector_sections_from_bulk(bulk_str, parent):
    """

    :param bulk_str:
    :param parent:
    :return:
    """

    consecsd = dict()

    for m in AbaCards.connector_behaviour.regex.finditer(bulk_str):
        d = m.groupdict()
        name = d["name"]
        comp = int(d["component"])

        res = np.fromstring(list_cleanup(d["bulk"]), sep=",", dtype=np.float64)
        size = res.size
        cols = comp + 1
        rows = int(size / cols)
        res_ = res.reshape(rows, cols)
        consecsd[name] = ConnectorSection(name, [res_], [], metadata=d)
    return consecsd
Exemplo n.º 4
0
 def add_connector_section(
         self, connector_section: ConnectorSection) -> ConnectorSection:
     connector_section.parent = self
     self.connector_sections[connector_section.name] = connector_section
     return connector_section