Exemple #1
0
# numerical data

n = network.number_of_nodes()

node_index = {node: index for index, node in enumerate(network.nodes())}

fixed = list(network.nodes_where({'is_anchor': True}))
free = list(network.nodes_where({'is_anchor': False}))

fixed[:] = [node_index[node] for node in fixed]
free[:] = [node_index[node] for node in free]

edges = [(node_index[u], node_index[v]) for u, v in network.edges()]

X = network.nodes_attributes('xyz')
R = network.nodes_attributes(['rx', 'ry', 'rz'])
P = network.nodes_attributes(['px', 'py', 'pz'])
Q = network.edges_attribute('q')

# compute equilibrium

X, Q, F, L, R = dr(X, edges, fixed, P, Q)

# update network

update_network()

# visualize result

artist = CablenetArtist(network, layer="ITA20::L5::FormFinding")
Exemple #2
0
fixed = list(network.nodes_where({'is_anchor': True}))
free = list(network.nodes_where({'is_anchor': False}))

# visualize dynamic process

layer = "ITA20::L5::FormFinding"
artist = NetworkArtist(network, layer=layer)

tol = 0.01
kmax = 100

update_residuals(network)

for k in range(kmax):
    R = network.nodes_attributes(['rx', 'ry', 'rz'], keys=free)
    res = sum(length_vector(r) for r in R)
    if res < tol:
        break

    artist.draw_nodes(color={node: (255, 0, 0) for node in fixed})
    artist.draw_edges()

    draw_reactions(network, layer, (0, 255, 0))
    draw_residuals(network, layer, (0, 255, 255), tol)

    compas_rhino.rs.Redraw()
    compas_rhino.wait()

    update_geometry(network)
    update_residuals(network)