Пример #1
0
def cp02(L_x=4, L_y=4, n_x=2, n_y=4, n_steps=80):

    cp = RhombusCreasePattern(n_steps=n_steps, L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y, show_iter=False, MAX_ITER=500)

    n_h = cp.n_h
    n_i = cp.n_i
    n_v = cp.n_v

    cp.cnstr_lhs = [
        [(n_h[0, 0], 2, 1.0)],  # 0
        [(n_h[0, -1], 2, 1.0)],  # 1
        [(n_h[-1, 0], 2, 1.0)],  # 2
        [(n_h[-1, -1], 2, 1.0)],  # 3
        [(n_h[0, 1], 2, 1.0)],  # 4
        [(n_h[-1, 1], 2, 1.0)],  # 5
        [(n_h[1, 1], 2, 1.0)],  # 6
        [(n_h[0, 0], 1, 1.0), (n_h[1, 0], 1, -1.0)],  # 7
        [(n_h[0, 0], 1, 1.0), (n_h[-1, 0], 1, -1.0)],  # 8
        [(n_h[0, -1], 1, 1.0), (n_h[1, -1], 1, -1.0)],  # 9
        [(n_h[0, -1], 1, 1.0), (n_h[-1, -1], 1, -1.0)],  # 10
        [(n_h[1, 1], 0, 1.0)],  # 11
        [(n_h[0, -1], 1, 1.0)],  # 12
        [(n_h[1, 1], 1, 1.0), (n_h[0, 1], 1, -1.0)],  # 13
        [(n_h[1, 1], 1, 1.0), (n_h[-1, 1], 1, -1.0)],  # 14
        #                    [(n_h[1, 1], 2, 1.0), (n_h[1, 0], 2, -1.0)], # 13
        #                    [(n_h[1, 1], 1, 1.0), (n_h[1, -1], 2, -1.0)], # 14
    ]

    # lift node 0 in z-axes
    cp.cnstr_rhs = np.zeros((15,), dtype=float)
    cp.cnstr_rhs[6] = 1.999999999

    return cp
Пример #2
0
def cp04(L_x=4, L_y=4, n_x=2, n_y=4, n_steps=100):

    cp = RhombusCreasePattern(n_steps=n_steps, L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y, show_iter=False, MAX_ITER=500)

    n_h = cp.n_h
    n_i = cp.n_i
    n_v = cp.n_v

    z_nodes = n_h[(0, -1), :].flatten()
    z_cnstr = [[(n, 2, 1.0)] for n in z_nodes]

    y_links = []
    for n_arr in n_h.T:
        for n in n_arr[1:]:
            y_links.append([(n_arr[0], 1, 1.0), (n, 1, -1.0)])

    x_cnstr = [[(n_h[0, 0], 0, 1.0)]]

    y_cnstr = [[(n_h[0, -1], 1, 1.0)], [(n_h[0, 0], 1, 1.0)]]

    cp.cnstr_lhs = z_cnstr + y_links + x_cnstr + y_cnstr

    # lift node 0 in z-axes
    cp.cnstr_rhs = np.zeros((len(cp.cnstr_lhs),), dtype=float)
    cp.cnstr_rhs[-1] = 3.9

    return cp
Пример #3
0
def cp05(L_x=4, L_y=4, n_x=2, n_y=4, n_steps=100, skew_coeff=0.0):
    """Exploit symmetric constraints
    """
    cp = RhombusCreasePattern(n_steps=n_steps, L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y, show_iter=False, MAX_ITER=500)

    n_h = cp.n_h
    n_i = cp.n_i
    n_v = cp.n_v

    z_nodes = n_h[(0, -1), :].flatten()
    z_cnstr = [[(n, 2, 1.0)] for n in z_nodes]

    y_links = []
    for n_arr in n_h[:, (0, -1)].T:
        for idx, n in enumerate(n_arr[1:]):
            n_x = len(n_arr)
            coeff = skew_coeff * float(idx + 1) / float(n_x)
            y_links.append([(n_arr[0], 1, 1.0 - coeff), (n, 1, -1.0)])

    for n_arr in n_h[:, 1:-1].T:
        y_links.append([(n_arr[0], 1, 1.0), (n_arr[-1], 1, -1.0)])

    x_links = []
    z_links = []
    #    for n0, n1 in zip(n_h[1:-1, 0], n_h[1:-1, -1]):
    #        x_links.append([(n0, 0, 1.0), (n1, 0, 1.0)])
    #        z_links.append([(n0, 2, 1.0), (n1, 2, -1.0)])
    for n in n_v[0, 1:]:
        z_links.append([(n_v[0, 0], 2, 1.0), (n, 2, -1.0)])

    n_h_idx = n_y / 4
    x_cnstr = [[(n_h[0, n_h_idx], 0, 1.0)]]

    y_cnstr = [[(n_h[0, n_h_idx], 1, 1.0)]]

    cntrl = [[(n_h[-1, n_h_idx], 0, 1.0)]]
    # cntrl = [[(n_h[-1, 0], 1, 1.0)]]

    cp.cnstr_lhs = z_cnstr + x_links + y_links + z_links + x_cnstr + y_cnstr + cntrl

    # lift node 0 in z-axes
    cp.cnstr_rhs = np.zeros((len(cp.cnstr_lhs),), dtype=float)
    cp.cnstr_rhs[-1] = -L_x * 0.1

    return cp
Пример #4
0
def cp01(L_x = 4, L_y = 4, n_x = 1, n_y = 2,
         n_steps = 100, skew_coeff = 0.0):
    '''Exploit symmetric constraints
    '''
    cp = RhombusCreasePattern(n_steps = n_steps,
                              L_x = L_x,
                              L_y = L_y,
                              n_x = n_x,
                              n_y = n_y,
                              show_iter = False,
                              MAX_ITER = 500)

    n_h = cp.n_h
    n_i = cp.n_i
    n_v = cp.n_v
    n_h_idx = n_y / 4

    x_links = []
    y_links = []
    z_links = []

    z_nodes = n_h[(0, 0, -1, -1), (0, -1, -1, 0)].flatten()
    print 'z_nodes', z_nodes

    #z_cnstr = [[(n, 2, 1.0)] for n in z_nodes]
    x_cnstr = [[(n_h[0, 0], 0, 1.0)]]
    y_cnstr = [[(n_h[0, 0], 1, 1.0)]]
    z_cnstr = [[(n_h[0, 0], 2, 1.0)]]

    for n_arr in n_h[:, (0, -1)].T:
        for idx, n in enumerate(n_arr[1:]):
            n_x = len(n_arr)
            coeff = skew_coeff * float(idx + 1) / float(n_x)
            y_links.append([(n_arr[0], 1, 1.0 - coeff), (n, 1, -1.0)])

    for n in n_h[0, 1:]:
        z_links.append([(n_h[0, 0], 2, 1.0), (n, 2, -1.0)])
        x_links.append([(n_h[0, 0], 0, 1.0), (n, 0, -1.0)])
    #x_links.append([(n_h[0, -1], 0, 1.0), (n_h[0, -1], 1, -0.5)])

    for n in n_v[-1, 1:]:
        x_links.append([(n_v[-1, 0], 0, 1.0), (n, 0, -1.0)])

    for n0, n1 in zip(n_v[0, :], n_v[-1, :]):
        z_links.append([(n0, 2, 1.0), (n1, 2, -1.0)])

    #cntrl = [[(n_h[-1, -1], 1, 1.0)]]
    cntrl = [[(n_h[-1, 1], 0, 1.0)]]

    print 'x_cnstr', len(x_cnstr)
    print 'y_cnstr', len(y_cnstr)
    print 'z_cnstr', len(z_cnstr)
    print 'x_links', len(x_links)
    print 'y_links', len(y_links)
    print 'z_links', len(z_links)

    cp.cnstr_lhs = z_cnstr + x_links + y_links + z_links + x_cnstr + y_cnstr + cntrl
    #cp.cnstr_lhs = z_cnstr

    # lift node 0 in z-axes
    cp.cnstr_rhs = np.zeros((len(cp.cnstr_lhs),), dtype = float)
    cp.cnstr_rhs[-1] = -L_x * 0.34

#    cp.cnstr_rhs[-1] = -L_y * 0.9999

    return cp
Пример #5
0
#-------------------------------------------------------------------------------
#
# Copyright (c) 2009, IMB, RWTH Aachen.
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in simvisage/LICENSE.txt and may be redistributed only
# under the conditions described in the aforementioned license.  The license
# is also available online at http://www.simvisage.com/licenses/BSD.txt
#
# Thanks for using Simvisage open source!
#
# Created on Nov 9, 2011 by: rch

from bearigami.forming.rhombus_crease_pattern import RhombusCreasePattern

if __name__ == '__main__':

    cp = RhombusCreasePattern()

    cp.solve()