def get_constrained_YCP(L_x, L_y, n_x, n_y):
    def geo_trans(X):
        x, y, z = X.T
        y = y - 1.1

#    y[2], y[3], y[4], y[5] = -1.428, 1.428, -1, 1
        y[2], y[3], y[4], y[5] = -0.7488, 0.7488, -0.275, 0.275 
#    x[2], x[3], x[8] , x[9] = 3.43, 3.43, 1.93, 4.93
        x[2], x[3], x[8] , x[9] = 3.6925, 3.6925, 2.045, 5.34
        return np.c_[x, y, z]




    cp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y,
                            geo_transform=geo_trans)

    fixed_node = fix(cp.N_h[0, 0], (0, 1, 2))
    planar_front_boundary = link(cp.N_h[0, 0], 1, 1.0,
                             cp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(cp.N_h[0, -1], 1, 1.0,
                            cp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(cp.N_h[0, 0], 0, 1.0,
                              cp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(cp.N_h[0, 0], 2, 1.0,
                              cp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(cp.N_v[0, :], 2, 1.0,
                               cp.N_v[1, :], 2, -1.0)
#    linked_right_boundary_x = link(ycp.N_v[-1, 0], 0, 1.0,
#                                   ycp.N_v[-1, 1:], 0, -1.0)
    cntrl_displ = [([(cp.N_v[1, 0], 0, 1.0)], -1)]
    cs=fixed_node+planar_front_boundary+planar_back_boundary+linked_left_boundary_x+linked_left_boundary_z+linked_left_and_right_z+cntrl_displ

    caf = CnstrTargetFace(F=[r_, s_, 4 * 0.4 * t_ * r_ * (1 - r_ / L_x) + 0.15])
    n_arr = np.hstack([cp.N_h[:, :].flatten(),
                   cp.N_i[:, :].flatten()
                  ])

    fold = Folding(cp=cp, n_steps=10, dof_constraints= cs,
               init_tf_lst=[(caf, n_arr)] )
    fold.show()
    return fold
fold.u_t[-1]

fold_further = Folding(source=fold,
                       name='fold further',
                       goal_function_type='potential_energy',
                       n_steps=4,
                       MAX_ITER=1000,
                       dof_constraints=fix(n_l_h, [0], v) + fix(n_lr_h, [2]) +
                       fix(n_fixed_y, [1]) + fix(n_r_h, [0], -v)
                       )
fold_further.u_t[-1]


and_fold_further = Folding(source=fold_further,
                           name='and fold further',
                           goal_function_type='potential_energy',
                           n_steps=4,
                           MAX_ITER=1000,
                           dof_constraints=fix(n_l_h, [0], 0) + fix(n_lr_h, [2]) +
                           fix(n_fixed_y, [1]) + fix(n_r_h, [0], 0)
                           )
u_0 = np.zeros_like(fold_further.u_t[-1])
u_0[12, 0] += 0.2
and_fold_further.U_0 = u_0.flatten()

and_fold_further.u_t[-1]


cpw = CreasePatternView(root=init)
cpw.configure_traits()
from oricrete.folding2 import \
    YoshimuraCreasePattern, CnstrTargetFace, Folding, fix, link, r_, s_, t_
import numpy as np

def geo_trans(X):
    x, y, z = X.T
    y_ = (y - 0.4) * (1 - 0.6 / 1.2 * x)
    return np.c_[x, y_, z]

cp = YoshimuraCreasePattern(L_x=1.2, L_y=0.8, n_x=4, n_y=8,
                            geo_transform=geo_trans)
face_z_t = CnstrTargetFace(F=[r_, s_, 1.0 * t_ * r_ * (1 - r_ / 1.2)])

fold_to_target_face = Folding(cp=cp, n_steps=10,
                              tf_lst=[(face_z_t, np.hstack([cp.N_h[:, (0, -1)].flatten(),
                                                            cp.N_h[(0, -1), 1:-1].flatten(),
                                                            cp.N_i[(0, -1), :].flatten()
                                                            ]))],
                              init_tf_lst=[(face_z_t, np.hstack([cp.N_h.flatten(),
                                                                 cp.N_i.flatten()]))],
                              )
fold_to_target_face.show()
from oricrete.folding2 import \
    YoshimuraCreasePattern, Initialization, CnstrTargetFace, Folding, link, r_, s_, t_

cp = YoshimuraCreasePattern(L_x=1.2, L_y=0.8, n_x=3, n_y=4)
face_z_t = CnstrTargetFace(F=[r_, s_, 0.8 * t_ * r_ * (1 - r_ / 1.2)])
fold = Folding(source=cp, n_steps=8,
               tf_lst=[(face_z_t, cp.N)],
               init_tf_lst=[(face_z_t, cp.N)])

fold.show()

fold2 = Folding(cp=cp, n_steps=8, unfold=True,
                tf_lst=[(face_z_t, cp.N)])
fold2.X = fold.x_t[-1]
print fold2.t_arr
fold2.show()
Exemple #5
0
cs= [                        ([(0, 1, 1.0)], 0.005),
                                ([(1, 1, 1.0)], -0.005),
                                ([(2, 1, 1.0)], 0.005),
                                ([(3, 1, 1.0)], -0.005),
                                ([(4, 1, 1.0)], 0.005),
                                ([(5, 1, 1.0)], -0.005),
                                ([(6, 0, 1.0)], 0.0),
                                ([(6, 1, 1.0)], 0.0),
                                ([(6, 2, 1.0)], 0.0),
                                ([(7, 1, 1.0)], 0.0),
                                ([(8, 1, 1.0)], 0.0),
                                ]

t_x= link(cp.N_h[:,0],0,-1.0 , cp.N_h[:,1],0,1.0)
t_y= link(cp.N_h[:,0],1,1.0 , cp.N_h[:,1],1,1.0)
#t_z= link(cp.N_h[0,0],2,-1.0 , cp.N_h[0,1],2,1.0)
t_fix=fix(cp.N_v[0,0],[0,1,2])
t_fix2=fix(cp.N_v[-1,0],[1])
cntrl_displ = [([(cp.N_v[-1,0], 0, 1.0)], -0.01)]
#cs= t_x+t_y+t_fix+t_fix2+cntrl_displ

print "cs",cs


face_z_t = CnstrTargetFace(F=[r_, s_, 0.8 * t_ * r_ * (1 - r_ / L_x)])
fold = Folding(cp=cp, n_steps=8, dof_constraints= cs,
               init_tf_lst=[(face_z_t, cp.N)] )
fold.show()
print fold.x_t[-1]

    x, y, z = X.T
    y_ = (y - 0.4) * (1 - 0.6 / 1.2 * x)
    return np.c_[x, y_, z]

cp = YoshimuraCreasePattern(L_x=1.2, L_y=0.8, n_x=3, n_y=8,
                            )
face_z_t = CnstrTargetFace(F=[r_, s_, 0.6 * t_ * r_ * (1 - r_ / 1.2)])
fold_to_target_face = Folding(cp=cp, n_steps=8,
                              tf_lst=[(face_z_t, cp.N)],
                              init_tf_lst=[(face_z_t, cp.N)])

U_t = fold_to_target_face.u_t[-1]

face_z = CnstrTargetFace(F=[r_, s_, 0.6 * r_ * (1 - r_ / 1.2)])

mid_node_idx = 8 / 4

narrow = Folding(cp=cp,
                 n_steps=14,
                 tf_lst=[(face_z, np.hstack([cp.N_h[(0, 1), :].flatten()]))],
                 U_0=U_t,
                 dof_constraints=fix(cp.N_h[:, mid_node_idx], 1) + \
                                 link(cp.N_h[0, mid_node_idx - 1], 2, 1.0, cp.N_h[0, mid_node_idx + 1], 2, -1.0) + \
                                 link(cp.N_h[-1, 0], 2, 1.0, cp.N_h[-1, 1:], 2, -1.0) + \
                                 link(cp.N_h[-1, 0], 0, 1.0, cp.N_h[-1, 1:], 0, -1.0) + \
                                 [([(cp.N_h[-1, 0], 1, 1.0)], 0.05),
                                  ([(cp.N_h[-1, -1], 1, 1.0)], -0.05)]
                 )

narrow.show()
Exemple #7
0
                            [0, 3],
                            [1, 3],
                            [1, 4],
                            [2, 3],
                            [2, 5],
                            [3, 4],
                            [3, 5],
                            [3, 6],
                            [4, 6],
                            [5, 6]],
                       F=[[0, 1, 3],
                            [0, 3, 2],
                            [1, 4, 3],
                            [2, 3, 5],
                            [3, 6, 5],
                            [3, 4, 6]])

    caf = CnstrTargetFace(F=[r_, s_, 4 * 0.4 * t_ * r_ * (1 - r_ / 3)])

    ff = FormFinding(cp=cp, n_steps=1)

    ff.tf_lst = [(caf, [0, 1, 2, 3, 4, 5, 6])]

    # Unfolding
    uf = Folding(cp=ff.cp, tf_lst=ff.tf_lst, n_steps=10)
    uf.unfold = True
    print 'x_t', uf.x_t[-1]



Exemple #8
0
from oricrete.folding2 import CreasePattern, Folding, CreasePatternView

triangle = CreasePattern(X=[[0, 0, 0],
                            [1, 0, 0],
                            [1, 1, 0]],
                         L=[[0, 1],
                            [1, 2],
                            [2, 0]],
                         F=[[0, 1, 2]]
                         )

lift = Folding(cp=triangle,
               n_steps=10,
               dof_constraints=[([(0, 0, 1.0)], 0.0),
                                ([(0, 1, 1.0)], 0.0),
                                ([(0, 2, 1.0)], 0.0),
                                ([(1, 1, 1.0)], 0.0),
                                ([(1, 2, 1.0)], 0.0),
                                ([(2, 2, 1.0)], 0.5)
                                ]
               )

lift.U_0[8] = 0.1

v = CreasePatternView(root=lift.source)
v.configure_traits()