예제 #1
0
def rhombcp():

    cp = CreasePattern()

    cp.nodes = [[ 0, 0, 0 ],
                [ 1, 0, 0 ]]

    cp.crease_lines = [[ 0, 1 ]]

    cp.cnstr_lhs = [
                    [(0, 0, 1.0)],
                    [(0, 2, 1.0)],
                    [(1, 0, 1.0)],
                    [(1, 0, 1.0), (1, 1, 1.0)],
                    [(1, 2, 1.0)]
                    ]

    cp.cnstr_rhs = [0.0, 0.0, -1.99, 0.0, 0.0]

    X = np.zeros((cp.n_dofs,), dtype = float)
    X[1] = 0.01

    print 'initial lengths\n', cp.c_lengths
    print 'initial vectors\n', cp.c_vectors

    print 'initial R\n', cp.get_R(X)
    print 'initial dR\n', cp.get_dR(X)

    X = cp.solve(X)

    print '========== results =============='
    print 'solution X\n', X
    print 'final positions\n', cp.get_new_nodes(X)
    print 'final vectors\n', cp.get_new_vectors(X)
    print 'final lengths\n', cp.get_new_lengths(X)

    # initialise View
    my_model = CreasePatternView(data = cp)
    my_model.configure_traits()
예제 #2
0
    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

if __name__ == '__main__':

    cp = cp01(L_x = 14, L_y = 8, n_x = 4, n_y = 4,
              n_steps = 40, skew_coeff = 0.0)
    X0 = cp.generate_X0()
    #cp.set_next_node(X0)

    print 'n_dofs', cp.n_dofs
    print 'n_c', cp.n_c
    print 'necessary constraints', cp.n_dofs - cp.n_c
    print 'cnstr', len(cp.cnstr_lhs)

    X_vct = cp.solve(X0)

#    print 'new nodes'
#    print cp.get_new_nodes(X_vct)
#    print 'new lengths'
#    print cp.get_new_lengths(X_vct)

    # initialise View
    my_model = CreasePatternView(data = cp, show_cnstr = True)
    my_model.configure_traits()

예제 #3
0
def run():

    cp = CreasePattern(n_steps = 30, MAX_ITER = 1000)

    cp.nodes = [[ 0, 0, 0 ],
                [ 2, 0, 0 ],
                [ 4, 0, 0 ],
                [ 6, 0, 0 ],
                [ 8, 0, 0 ],
                [ 0, 1, 0 ],
                [ 1, 1, 0 ],
                [ 3, 1, 0 ],
                [ 5, 1, 0 ],
                [ 7, 1, 0 ],
                [ 8, 1, 0 ],
                ]

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

    cp.cnstr_lhs = [[(0, 2, 1.0)], # n0.z = 0.0
                    [(4, 2, 1.0)], # n4.z = 0.0
                    [(2, 2, 1.0)], # n2.z = control node
                    [(2, 0, 1.0)], # n2.x = 0
                    [(5, 1, 1.0)], # n5.y = 0
                    [(5, 1, 1.0), (6, 1, -1.0)], # n6.y = n3.y
                    [(5, 1, 1.0), (7, 1, -1.0)], # n7.y = n3.y
                    [(5, 1, 1.0), (8, 1, -1.0)], # n8.y = n3.y
                    [(5, 1, 1.0), (9, 1, -1.0)], # n9.y = n3.y
                    [(5, 1, 1.0), (10, 1, -1.0)], # n10.y = n3.y
                    [(0, 1, 1.0), (1, 1, -1.0)], # n1.y = n0.y
                    [(0, 1, 1.0), (2, 1, -1.0)], # n2.y = n0.y
                    [(0, 1, 1.0), (3, 1, -1.0)], # n3.y = n0.y
                    [(0, 1, 1.0), (4, 1, -1.0)], # n4.y = n0.y
                    ]

    # lift node 0 in z-axes
    cp.cnstr_rhs = np.zeros((14,), dtype = float)
    cp.cnstr_rhs[2] = 3.0

    X = np.zeros((cp.n_dofs,), dtype = float)
    X[2] = 0.0
    X[5] = 0.05
    X[8] = 0.0
    X[11] = 0.05
    X[14] = 0.0
    X[17] = -0.05
    X[20] = 0.05
    X[23] = 0.01
    X[26] = 0.01
    X[29] = 0.05
    X[32] = -0.05

    print 'initial lengths\n', cp.c_lengths
    print 'initial vectors\n', cp.c_vectors

    print 'initial R\n', cp.get_R(X)
    dR = cp.get_dR(X)
    np.savetxt('dR.arr', dR, '%g')
    np.savetxt
    print 'initial dR\n', cp.get_dR(X)

    X = cp.solve(X)

    print '========== results =============='
    print 'solution X\n', X
    print 'final positions\n', cp.get_new_nodes(X)
    print 'final vectors\n', cp.get_new_vectors(X)
    print 'final lengths\n', cp.get_new_lengths(X)

    # initialise View
    my_model = CreasePatternView(data = cp)

    my_model.configure_traits()