Example #1
0
# Initial configuration

lines = []
for u, v in network.edges():
    lines.append({
        'start': network.vertex_coordinates(u, 'xy'),
        'end': network.vertex_coordinates(v, 'xy'),
        'color': '#cccccc',
        'width': 1.0
    })

plotter.draw_lines(lines)
plotter.draw_vertices(radius=0.005, facecolor={key: '#ff0000' for key in pins})
plotter.draw_edges()
plotter.update()

# Callback for dynamic visualization


def plot_iterations(X, radius=0.005):

    for i in network.vertices():
        x, y, z = X[i, :]
        network.set_vertex_attributes(i, 'xyz', [x, y, z])

    plotter.update_vertices(radius)
    plotter.update_edges()
    plotter.update(pause=0.01)

                                   {'vertex_degree': 1}))

# assign random prescribed force densities to the edges
for uv in network.edges():
    network.set_edge_attribute(uv, 'qpre', 1.0 * random.randint(1, 7))

# make a plotter for (dynamic) visualization
plotter = NetworkPlotter(network, figsize=(10, 7))

# plot the starting configuration
plotter.draw_vertices(facecolor={
    key: '#000000'
    for key in network.vertices_where({'is_fixed': True})
})
plotter.draw_edges()
plotter.update(pause=1.0)

# run the DR
network_dr(network, callback=callback)

# plot the final configuration
plotter.draw_vertices(facecolor={
    key: '#000000'
    for key in network.vertices_where({'is_fixed': True})
})
plotter.draw_edges()
plotter.update(pause=1.0)

# keep the plot alive
plotter.show()
Example #3
0
# Initial configuration

lines = []
for u, v in network.edges():
    lines.append({
        'start': network.vertex_coordinates(u, 'xy'),
        'end': network.vertex_coordinates(v, 'xy'),
        'color': '#cccccc',
        'width': 1.0
    })

plotter.draw_lines(lines)
plotter.draw_vertices(radius=0.005, facecolor={key: '#ff0000' for key in pins})
plotter.draw_edges()
plotter.update()

# Callback for dynamic visualization


def plot_iterations(X, radius=0.005):

    for i in network.vertices():
        x, y, z = X[i, :]
        network.set_vertex_attributes(i, 'xyz', [x, y, z])

    plotter.update_vertices(radius)
    plotter.update_edges()
    plotter.update(pause=0.01)