Esempio n. 1
0
def line_test_crane(n_steps = 10, dx = 1.0):

    """

    """

    cp = CreasePattern(n_steps = n_steps)

    cp.nodes = [[0.75, 0.333, 0],
                [0.75, 0.667, 0],
                [2.25, 0.333, 0],
                [2.25, 0.667, 0],
                [1.5, 0.5, 1.5],
                [0, 0.5, 1],
                [3, 0.5, 1],
                [0.8, 0.5, 1.266],
                [2.2, 0.5, 1.266]
#                [0.8, 0.333, 1.0533],
#                [0.8, 0.667, 1.0533],
#                [2.2, 0.333, 1.0533],
#                [2.2, 0.667, 1.0533],
                ]

    cp.crease_lines = [[ 4, 5 ],
                       [ 4, 6 ],
                       [ 7, 0],
                       [ 7, 1],
                       [ 8, 2],
                       [ 8, 3]]
#                       [ 7, 9 ],
#                       [ 7, 10 ],
#                       [ 8, 11 ],
#                       [ 8, 12 ],

#                       [ 0, 9 ],
#                       [ 1, 10],
#                       [ 2, 11],
#                       [ 3, 12]]

    cp.facets = [[0, 1, 2]]

    cp.grab_pts = []

    cp.line_pts = [[7, 0],
                   [8, 1]]

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

                    ]

    cp.cnstr_rhs = np.zeros((cp.n_dofs,))
    cp.cnstr_rhs[0] = dx

    X = np.zeros((cp.n_dofs,), dtype = float)
    X[14] = 0.0001
    X[2] = 0.0001
   # X[10] = 0.01
  #  X[11] = 0.01

    print 'necessary constraints', cp.n_dofs - cp.n_c - cp.n_g * cp.n_d - cp.n_l * 2
    print 'cnstr', len(cp.cnstr_lhs)
    cp.show_iter = True
    X = cp.solve(X)

    return cp
Esempio n. 2
0
def rhombus_3x3_crane(n_steps = 10, dx = 0.7):
    """
        This example shows a 3x2 rhombus creasepattern.

    """
    cpr = YoshimuraCreasePattern(n_steps = n_steps,
                              L_x = 3,
                              L_y = 3,
                              n_x = 3,
                              n_y = 6,
                              MAX_ITER = 5000)

    X_rcp = cpr.generate_X0()
    X_rcp = X_rcp.reshape((-1, 3))
    X_rcp[:, 2] += -0.1559

    cp = CreasePattern(n_steps = n_steps, MAX_ITER = 500)

    cp.nodes = cpr.nodes

    cp.crease_lines = cpr.crease_lines

    cp.facets = cpr.facets

    grab_nodes = [[0.5, 0.333, 0], #31
                  [0.5, 0.667, 0],
                  [0.5, 1.333, 0],
                  [0.5, 1.667, 0],
                  [0.5, 2.333, 0], #35
                  [0.5, 2.667, 0],
                  [1.5, 0.333, 0],
                  [1.5, 0.667, 0],
                  [1.5, 1.333, 0],
                  [1.5, 1.667, 0],
                  [1.5, 2.333, 0],
                  [1.5, 2.667, 0],
                  [2.5, 0.333, 0],
                  [2.5, 0.667, 0],
                  [2.5, 1.333, 0], #45
                  [2.5, 1.667, 0],
                  [2.5, 2.333, 0],
                  [2.5, 2.667, 0]]#48



    cp.nodes = np.vstack([cp.nodes, grab_nodes])





    cp.grab_pts = [[31, 0],
                   [32, 21],
                   [33, 1],
                   [34, 22],
                   [35, 2],
                   [36, 23],
                   [37, 3],
                   [38, 24],
                   [39, 4],
                   [40, 25],
                   [41, 5],
                   [42, 26],
                   [43, 6],
                   [44, 27],
                   [45, 7],
                   [46, 28],
                   [47, 8],
                   [48, 29]
                   ]




    cnstr_lhs_3 = [[(31, 1, 1.0)],
                   [(31, 1, 1.0), (36, 1, 1.0)],
                   [(16, 2, 1.0)],
                   [(17, 2, 1.0)],
                   [(18, 2, 1.0)],
                   [(19, 2, 1.0)],
                   [(20, 2, 1.0)],
                   [(21, 2, 1.0)],
                   [(17, 1, 1.0)],
                   [(20, 1, 1.0)],
                   [(20, 0, 1.0)],
                   [(37, 1, 1.0), (42, 1, 1.0)],
                   [(31, 2, 1.0), (36, 2, -1.0)],
                   [(37, 2, 1.0), (42, 2, -1.0)],
                   [(43, 1, 1.0), (48, 1, 1.0)],
                   [(43, 2, 1.0), (48, 2, 1.0)],
                   [(33, 1, 1.0), (34, 1, 1.0)],
                   [(39, 1, 1.0), (40, 1, 1.0)],
                   [(45, 1, 1.0), (46, 1, 1.0)],
                   [(19, 0, 1.0), (21, 0, -1.0)],
                   [(1, 2, 1.0), (2, 0, -1.0)]

                    ]
    cp.cnstr_lhs = cnstr_lhs_3

    cp.cnstr_rhs = np.zeros((cp.n_dofs,))
    cp.cnstr_rhs[0] = dx


    X_ext = np.zeros((cp.n_dofs - len(X_rcp.reshape((-1,))),), dtype = float)
    X0 = np.hstack([X_rcp.reshape((-1,)), X_ext])








    X0 *= 0.1
    #np.set_printoptions(threshold='nan')
    print 'dR', cp.get_dR(X0)
    print 'R', cp.get_R(X0)

    cp.set_next_node(X0)

    print 'L_vct', cp.grab_pts_L
    print 'n_dofs', cp.n_dofs
    print 'n_c', cp.n_c
    print 'n_g', cp.n_g
    print 'necessary constraints', cp.n_dofs - cp.n_c - cp.n_g * 3 - cp.n_l * 2
    print 'cnstr', len(cp.cnstr_lhs)

    cp.show_iter = True
    X = cp.solve(X0)
    return cp