Пример #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
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()