Пример #1
0
def _create_arrays(structure):

    # Vertices

    n = structure.number_of_vertices()
    B = zeros((n, 3), dtype=float64)
    P = zeros((n, 3), dtype=float64)
    X = zeros((n, 3), dtype=float64)
    S = zeros((n, 3), dtype=float64)
    V = zeros((n, 3), dtype=float64)

    k_i = structure.key_index()
    for key, vertex in structure.vertex.items():
        i = k_i[key]
        B[i, :] = vertex.get('B', [1, 1, 1])
        P[i, :] = vertex.get('P', [0, 0, 0])
        X[i, :] = [vertex[j] for j in 'xyz']

    # Edges

    m = structure.number_of_edges()
    u = zeros(m, dtype=int32)
    v = zeros(m, dtype=int32)
    E = zeros(m, dtype=float64)
    A = zeros(m, dtype=float64)
    s0 = zeros(m, dtype=float64)
    l0 = zeros(m, dtype=float64)
    ind_c = []
    ind_t = []

    uv_i = structure.uv_index()
    for ui, vi in structure.edges():
        i = uv_i[(ui, vi)]
        edge = structure.edge[ui][vi]
        E[i] = edge.get('E', 0)
        A[i] = edge.get('A', 0)
        l0[i] = edge.get('l0', structure.edge_length(ui, vi))
        s0[i] = edge.get('s0', 0)
        u[i] = k_i[ui]
        v[i] = k_i[vi]
        ct = edge.get('ct', None)
        if ct == 'c':
            ind_c.append(i)
        elif ct == 't':
            ind_t.append(i)
    f0 = s0 * A
    k0 = E * A / l0
    q0 = f0 / l0

    # Arrays

    C = connectivity_matrix([[k_i[i], k_i[j]] for i, j in structure.edges()],
                            'csr')
    Ct = C.transpose()
    M = mass_matrix(Ct=Ct, ks=k0, q=q0, c=1, tiled=False)
    rows, cols, vals = find(Ct)
    rows = array(rows, dtype=int32)
    cols = array(cols, dtype=int32)
    vals = array(vals, dtype=float64)
    nv = vals.shape[0]

    return X, B, P, S, V, E, A, C, Ct, f0, l0, ind_c, ind_t, u, v, M, k0, m, n, rows, cols, vals, nv
Пример #2
0
def _create_arrays(network):
    """ Create arrays for dynamic relaxation solver.

    Parameters:
        network (obj): Network to analyse.

    Returns:
        array: Nodal co-ordinates x, y, z.
        array: Constraint conditions Bx, By, Bz.
        array: Nodal loads Px, Py, Pz.
        array: Resultant nodal loads.
        array: Shear force components Sx, Sy, Sz.
        array: Nodal velocities Vx, Vy, Vz.
        array: Edge Young's moduli.
        array: Edge areas.
        array: Connectivity matrix.
        array: Transposed connectivity matrix.
        array: Edge initial forces.
        array: Edge initial lengths.
        list: Compression only edges indices.
        list: Tension only edges indices.
        array: Network edges' start points.
        array: Network edges' end points.
        array: Mass matrix.
        array: Edge axial stiffnesses.
    """

    # Vertices

    n = network.number_of_vertices()
    B = zeros((n, 3))
    P = zeros((n, 3))
    X = zeros((n, 3))
    S = zeros((n, 3))
    V = zeros((n, 3))
    k_i = network.key_index()
    for key in network.vertices():
        i = k_i[key]
        vertex = network.vertex[key]
        B[i, :] = vertex.get('B', [1, 1, 1])
        P[i, :] = vertex.get('P', [0, 0, 0])
        X[i, :] = [vertex[j] for j in 'xyz']
    Pn = normrow(P)

    # Edges

    uv_i = network.uv_index()
    edges = list(network.edges())
    m = len(edges)
    u = zeros(m, dtype=int64)
    v = zeros(m, dtype=int64)
    E = zeros((m, 1))
    A = zeros((m, 1))
    s0 = zeros((m, 1))
    l0 = zeros((m, 1))
    ind_c = []
    ind_t = []

    for c, uv in enumerate(edges):
        ui, vi = uv
        i = uv_i[(ui, vi)]
        edge = network.edge[ui][vi]
        E[i] = edge.get('E', 0)
        A[i] = edge.get('A', 0)
        l0[i] = edge.get('l0', network.edge_length(ui, vi))
        s0[i] = edge.get('s0', 0)
        u[c] = k_i[ui]
        v[c] = k_i[vi]
        ct = edge.get('ct', None)
        if ct == 'c':
            ind_c.append(i)
        elif ct == 't':
            ind_t.append(i)
    f0 = s0 * A
    ks = E * A / l0
    q0 = f0 / l0

    # Faces (testing)

    # if network.face:
    #     for face in faces:
    #         fdata = network.facedata[face]
    #         Eh = fdata.get('E', 0)
    #         th = fdata.get('t', 0)
    #         Ah = network.face_area(face)
    #         for ui, vi in network.face_edges(face):
    #             i = uv_i[(ui, vi)]
    #             ks[i] += 1.5 * Eh * Ah * th / l0[i]**2

    # Arrays

    C = connectivity_matrix([[k_i[ui], k_i[vi]] for ui, vi in edges], 'csr')
    Ct = C.transpose()
    M = mass_matrix(Ct=Ct, ks=ks, q=q0, c=1, tiled=False)

    return X, B, P, Pn, S, V, E, A, C, Ct, f0, l0, ind_c, ind_t, u, v, M, ks
Пример #3
0
def _create_arrays(structure):
    # Vertices
    n = structure.number_of_nodes()
    B = zeros((n, 3), dtype=float64)
    P = zeros((n, 3), dtype=float64)
    X = zeros((n, 3), dtype=float64)
    S = zeros((n, 3), dtype=float64)
    V = zeros((n, 3), dtype=float64)
    k_i = structure.key_index()
    for key in structure.nodes():
        i = k_i[key]
        B[i, :] = structure.node_attribute(key, 'B')
        P[i, :] = structure.node_attribute(key, 'P')
        X[i, :] = structure.node_attributes(key, 'xyz')

    # Edges
    m = structure.number_of_edges()
    u = zeros(m, dtype=int32)
    v = zeros(m, dtype=int32)
    E = zeros(m, dtype=float64)
    A = zeros(m, dtype=float64)
    s0 = zeros(m, dtype=float64)
    l0 = zeros(m, dtype=float64)
    ind_c = []
    ind_t = []
    uv_i = structure.uv_index()
    for key in structure.edges():
        i = uv_i[key]
        E[i] = structure.edge_attribute(key, 'E')
        A[i] = structure.edge_attribute(key, 'A')
        if structure.edge_attribute(key, 'l0'):
            l0[i] = structure.edge_attribute(key, 'l0')
        else:
            l0[i] = structure.edge_length(*key)
        if structure.edge_attribute(key, 's0'):
            s0[i] = structure.edge_attribute(key, 's0')
        else:
            s0[i] = 0
        u[i] = k_i[key[0]]
        v[i] = k_i[key[1]]
        ct = structure.edge_attribute(key, 'ct')
        if ct == 'c':
            ind_c.append(i)
        elif ct == 't':
            ind_t.append(i)
    f0 = s0 * A
    k0 = E * A / l0
    q0 = f0 / l0

    print(k0)

    # Other
    C = connectivity_matrix([[k_i[i], k_i[j]] for i, j in structure.edges()],
                            'csr')
    Ct = C.transpose()
    M = mass_matrix(Ct=Ct, ks=k0, q=q0, c=1, tiled=False)
    rows, cols, vals = find(Ct)
    rows = array(rows, dtype=int32)
    cols = array(cols, dtype=int32)
    vals = array(vals, dtype=float64)
    nv = vals.shape[0]

    return X, B, P, S, V, E, A, C, Ct, f0, l0, ind_c, ind_t, u, v, M, k0, m, n, rows, cols, vals, nv