Пример #1
0
network = network_from_bmesh(draw_plane(Lx=1, Ly=1, dx=ds, dy=ds))
vertices = list(network.vertices())
edges = list(network.edges())
n = len(vertices)
m = len(edges)
Xt = zeros((n, 3))
network.set_vertices_attributes(vertices, {'B': [0, 0, 1], 'P': [0, 0, 1 / n]})
for c, key in enumerate(vertices):
    x, y, z = network.vertex_coordinates(key)
    if (x == 1) and (y == 1):
        network.set_vertex_attribute(key, 'B', [0, 0, 0])
    zt = 1 - 0.5 * (x**2 + y**2)
    Xt[c, :] = [x, y, zt]
network.set_edges_attributes(edges, {'E': 1, 'A': 1, 'ct': 't'})

clear_layers([0])

# Run optimisation

tol = 0.001 / n
bounds = [[0.7 * ds, 1.3 * ds]] * m
fopt, uopt = de_solver(fn,
                       bounds,
                       population=20,
                       iterations=10**4,
                       args=(tol, Xt, edges),
                       limit=0.002)

# Update Network and plot

for c, uv in enumerate(edges):
Пример #2
0
    bpy.context.collection.objects.link(object)
    if layer:
        set_objects_layer(objects=[object], layer=layer)
    return object


# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    from compas_blender.utilities import clear_layers
    from compas_blender.utilities import set_objects_show_names

    clear_layers(layers=['Collection 1', 'Collection 2'])

    n = 10

    points = [{
        'pos': [0, 0, i],
        'radius': 0.2,
        'name': 'pt{0}'.format(i)
    } for i in range(n)]
    lines = [{
        'start': [1, 1, i],
        'end': [1, 0, i],
        'radius': 0.1,
        'color': [1, 0, 1]
    } for i in range(n)]
    cyls = [{
Пример #3
0
from math import pi


__author__    = ['Andrew Liew <*****@*****.**>']
__copyright__ = 'Copyright 2018, BLOCK Research Group - ETH Zurich'
__license__   = 'MIT License'
__email__     = '*****@*****.**'


# Structure

mdl = Structure(name='beam_simple', path='/home/al/temp/')

# Clear

clear_layers(layers=[0, 1, 2, 3])

# Lines

L = 1.0
m = 100
x = [i * L / m for i in range(m + 1)]
vertices = [[xi, 0, 0] for xi in x]
edges = [[i, i + 1] for i in range(m)]
bmesh = xdraw_mesh(name='beam', vertices=vertices, edges=edges, layer=0)

# Points

n = 5
xdraw_spheres([{'pos': [0, 0, 0], 'layer': 1, 'radius': 0.01},
               {'pos': [L, 0, 0], 'layer': 2, 'radius': 0.01}])
        ind = closest_points_points(X, Xt, distances=False)
        points = vstack([X, Xt[ind, :]])
        n = X.shape[0]
        lines = [[i, i + n] for i in range(n)]
        bmesh = draw_bmesh('norms', vertices=points, edges=lines, layer=19)
    return X


def fn(dofs, *args):
    network, Xt, div, factor, tol, steps, ds = args
    X = update(dofs, network, Xt, div, factor, tol, steps, ds, refresh=0, bmesh=0, plot=0)
    ind = closest_points_points(X, Xt, distances=False)
    return 1000 * mean(normrow(X - Xt[ind, :]))


clear_layers([19])

# Geometry input

L = 0.88
m = 20
n = m + 1
E = 5 * 10**9
I = 2 * 10**(-11)
A = 0.005**2

# Solver input

div = 10
factor = 1.0
tol = 0.01
Пример #5
0
    bpy.context.collection.objects.link(object)
    if layer:
        set_objects_layer(objects=[object], layer=layer)
    return object


# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    from compas_blender.utilities import clear_layers
    from compas_blender.utilities import set_objects_show_names

    clear_layers(layers=['Collection'])

    n = 10

    points = [{
        'pos': [0, 0, i],
        'radius': 0.2,
        'name': 'pt{0}'.format(i)
    } for i in range(n)]
    lines = [{
        'start': [1, 1, i],
        'end': [1, 0, i],
        'radius': 0.1,
        'color': [1, 0, 1]
    } for i in range(n)]
    cyls = [{