def get_constrained_YCP(L_x, L_y, n_x, n_y, d):
    
    ycp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y)

    fixed_node = fix(ycp.N_h[0, -1], (0, 1, 2))
    planar_front_boundary = link(ycp.N_h[0, 0], 1, 1.0,
                                 ycp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(ycp.N_h[0, -1], 1, 1.0,
                                ycp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(ycp.N_h[0, 0], 0, 1.0,
                                  ycp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(ycp.N_h[0, 0], 2, 1.0,
                                  ycp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(ycp.N_v[0, :], 2, 1.0,
                                   ycp.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 = [([(ycp.N_h[-1, 1], 0, 1.0)], d)]

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

    init = Initialization(cp=ycp, tf_lst=[(caf, n_arr)])

    lift = Folding(source=init, n_steps=80, MAX_ITER=500,
                   goal_function_type='none',
                   dof_constraints=fixed_node +
                   planar_front_boundary +
                   planar_back_boundary +
                   linked_left_boundary_x +
                   linked_left_boundary_z +
                   linked_left_and_right_z +
                   linked_right_boundary_x +
                   cntrl_displ,
                   #                    tf_lst=[(caf, n_arr)]
                   )
    lift.u_t[-1]
    
    n_l_h_corner = ycp.N_h[0, (0, -1)].flatten()
    n_r_h_corner = ycp.N_h[-1, (0, -1)].flatten()
    n_lr_h_corner = ycp.N_h[(0, 0, -1, -1), (0, -1, 0, -1)].flatten()
    n_fixed_y = ycp.N_h[(0, -1), 2].flatten()
    
    hanging = Folding(source=lift,
                      goal_function_type='potential_energy',
                      n_steps=5,
                      MAX_ITER=1000,
                      dof_constraints=fix(n_l_h_corner, [0], 0) + \
                               fix(n_lr_h_corner, [2]) + \
                               fix(n_fixed_y, [1]) + \
                               fix(n_r_h_corner, [0], -0) 
                      )
    
    hanging.u_t[-1]
    return init, lift, hanging
Exemple #2
0
def get_constrained_YCP(L_x, L_y, n_x, n_y):
    ycp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y)

    fixed_node = fix(ycp.N_h[0, 0], (0, 1, 2))
    planar_front_boundary = link(ycp.N_h[0, 0], 1, 1.0,
                                 ycp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(ycp.N_h[0, -1], 1, 1.0,
                                 ycp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(ycp.N_h[0, 0], 0, 1.0,
                                  ycp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(ycp.N_h[0, 0], 2, 1.0,
                                  ycp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(ycp.N_v[0, :], 2, 1.0,
                                   ycp.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 = [([(ycp.N_h[-1, 1], 0, 1.0)], -0.2)]

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

    lift = Lifting(cp=ycp, n_steps=10,
                   dof_constraints=fixed_node +
                                   planar_front_boundary +
                                   planar_back_boundary +
                                   linked_left_boundary_x +
                                   linked_left_boundary_z +
                                   linked_left_and_right_z +
                                   linked_right_boundary_x +
                                   cntrl_displ,
                   init_tf_lst=[(caf, n_arr)])

    return lift
Exemple #3
0
def get_constrained_YCP(L_x, L_y, n_x, n_y, d):
    ycp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y)

    fixed_node = fix(ycp.N_h[0, 0], (0, 1, 2))
    planar_front_boundary = link(ycp.N_h[0, 0], 1, 1.0, ycp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(ycp.N_h[0, -1], 1, 1.0, ycp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(ycp.N_h[0, 0], 0, 1.0, ycp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(ycp.N_h[0, 0], 2, 1.0, ycp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(ycp.N_v[0, :], 2, 1.0, ycp.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 = [([(ycp.N_h[-1, 1], 0, 1.0)], d)]

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

    init = Initialization(cp=ycp, tf_lst=[(caf, n_arr)])

    lift = Folding(
        source=init,
        n_steps=10,
        MAX_ITER=500,
        goal_function_type="none",
        dof_constraints=fixed_node
        + planar_front_boundary
        + planar_back_boundary
        + linked_left_boundary_x
        + linked_left_boundary_z
        + linked_left_and_right_z
        + linked_right_boundary_x
        + cntrl_displ,
        #                    tf_lst=[(caf, n_arr)]
    )
    print "u", lift.u_t[-1]
    return init, lift
def get_constrained_YCP(L_x, L_y, n_x, n_y, d, n_steps):
    '''
    '''
    ycp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y)

    caf = CnstrTargetFace(
        F=[r_, s_, 5 * t_ * r_ * (1 - r_ / L_x) + 0.000015])
    n_arr = np.hstack([ycp.N_h[:, :].flatten(),
                       ycp.N_i[:, :].flatten()
                       ])

    init = Initialization(cp=ycp, tf_lst=[(caf, n_arr)])

    fixed_node = fix(ycp.N_h[0, -1], (0, 1, 2))
    planar_front_boundary = link(ycp.N_h[0, 0], 1, 1.0,
                                 ycp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(ycp.N_h[0, -1], 1, 1.0,
                                ycp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(ycp.N_h[0, 0], 0, 1.0,
                                  ycp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(ycp.N_h[0, 0], 2, 1.0,
                                  ycp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(ycp.N_v[0, :], 2, 1.0,
                                   ycp.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 = [([(ycp.N_h[-1, 1], 0, 1.0)], d)]

    lift = Folding(source=init, n_steps=n_steps, MAX_ITER=500,
                   goal_function_type='none',
                   dof_constraints=fixed_node +
                   planar_front_boundary +
                   planar_back_boundary +
                   linked_left_boundary_x +
                   linked_left_boundary_z +
                   linked_left_and_right_z +
                   linked_right_boundary_x +
                   cntrl_displ,
                   #
                   )

    m = Masking(source=lift, F_mask=[],
                L_mask=[])

    lift.u_1

    #al = InfocadLink(data=m, n_split=4)
    #al.model_name = 'bike_box2'
    # al.build_inp()

    return init, lift
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()
                  ])

    init = Initialization(cp=cp, tf_lst=[(caf, n_arr)])
    fold = Folding(source=init, n_steps=10, dof_constraints=cs)
    fold.u_1

    print 'nodal coordinates', fold.x_1
    print 'facets', fold.F
    print 'facet coordinates', fold.x_1[fold.F]

    v = CreasePatternView(root=init)
    v.configure_traits()

    return fold
Exemple #6
0
def get_constrained_YCP(L_x, L_y, n_x, n_y):
    
    ycp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y)
    
    fixed_node = fix(ycp.N_h[0, 0], (0, 1, 2))
    planar_front_boundary = link(ycp.N_h[0, 0], 1, 1.0,
                                 ycp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(ycp.N_h[0, -1], 1, 1.0,
                                 ycp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(ycp.N_h[0, 0], 0, 1.0,
                                  ycp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(ycp.N_h[0, 0], 2, 1.0,
                                  ycp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(ycp.N_v[0, :], 2, 1.0,
                                   ycp.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 = [([(ycp.N_h[-1, 1], 0, 1.0)], -1.15)]
    cs = fixed_node + planar_front_boundary + planar_back_boundary + linked_left_boundary_x + linked_left_boundary_z + linked_left_and_right_z + linked_right_boundary_x + cntrl_displ

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

    init = Initialization(cp=ycp, tf_lst=[(caf, n_arr)])
    fold = Folding(source=init, n_steps=10, dof_constraints=cs)
    fold.u_1

    print 'nodal coordinates', fold.x_1
    print 'facets', fold.F
    print 'facet coordinates', fold.x_1[fold.F]
    print "punkte" , fold.x_t[-1]
    print "hallo", ycp.F_L
    print "nodes_neighbors", ycp.N_neighbors
    v = CreasePatternView(root=init)
    v.configure_traits()

    return fold
linked_v_left_and_right_z = link(cp.N_v[0, :], 2, 1.0,
                                 cp.N_v[-1, :], 2, -1.0)
linked_h_left_and_right_z = link(cp.N_h[0, :], 2, 1.0,
                                 cp.N_h[-1, :], 2, -1.0)
linked_v_left_and_right_x = link(cp.N_v[0, :], 0, 1.0,
                                 cp.N_v[-1, :], 0, 1.0)
linked_h_left_and_right_x = link(cp.N_h[0, :], 0, 1.0,
                                 cp.N_h[-1, :], 0, 1.0)
linked_h_top_and_bottom_z = link(cp.N_h[1:-1, 0], 2, 1.0,
                                 cp.N_h[1:-1, -1], 2, -1.0)
linked_h_top_and_bottom_y = link(cp.N_h[:, 0], 1, 1.0,
                                 cp.N_h[:, -1], 1, 1.0)


fixed_v_left_z = fix(cp.N_v[0, 2], 2)


# trying
fixed_v_left_z_lower1 = fix(cp.N_v[0, (1, -2)], [2], -0.03)
fixed_v_left_z_lower2 = fix(cp.N_v[0, (0, -1)], [2], -0.096)

# absolut from maple-sheet
#fixed_v_left_z_lower1 = fix(cp.N_v[0,(1,-2)],[2], -0.024)
#fixed_v_left_z_lower2 = fix(cp.N_v[0,(0,-1)],[2], -0.096)

#fixed_h1_z = fix(cp.N_h[0,(2,3)],[2], -0.040)


# absolut from inital deformation
#fixed_v_left_z_lower1 = fix(cp.N_v[0,(1,-2)],[2], -0.0189)
cp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=4, n_y=10)

linked_v_left_and_right_z = link(cp.N_v[0, :], 2, 1.0,
                                 cp.N_v[-1, :], 2, -1.0)
linked_h_left_and_right_z = link(cp.N_h[0, :], 2, 1.0,
                                 cp.N_h[-1, :], 2, -1.0)
linked_v_left_and_right_x = link(cp.N_v[0, :], 0, 1.0,
                                 cp.N_v[-1, :], 0, 1.0)
linked_h_left_and_right_x = link(cp.N_h[0, :], 0, 1.0,
                                 cp.N_h[-1, :], 0, 1.0)
linked_h_top_and_bottom_z = link(cp.N_h[1:-1, 0], 2, 1.0,
                                 cp.N_h[1:-1, -1], 2, -1.0)
linked_h_top_and_bottom_y = link(cp.N_h[:, 0], 1, 1.0,
                                 cp.N_h[:, -1], 1, 1.0)
fixed_v_left_z = fix(cp.N_v[0, 2], 2)
fixed_v_left_z_lower1 = fix(cp.N_v[0, (1, -2)], [2], -v * 0.4)
fixed_v_left_z_lower2 = fix(cp.N_v[0, (0, -1)], [2], -v * 1.2)
fixed_v_sym_y = fix(cp.N_v[(0, -1), 2].flatten(), 1)

n_l_h_corner = cp.N_h[0, (0, -1)].flatten()
n_r_h_corner = cp.N_h[-1, (0, -1)].flatten()
n_lr_h_corner = cp.N_h[(0, 0, -1, -1), (0, -1, 0, -1)].flatten()
n_fixed_y = cp.N_v[(0, -1), 2].flatten()

ctrl_u_ratio = 1.5

corner_slides = [([(cp.N_h[0, 0], 0, L_x), (cp.N_h[0, 0], 1, -L_y * ctrl_u_ratio)], 0),
                 ([(cp.N_h[-1, 0], 0, L_x),
                   (cp.N_h[-1, 0], 1, L_y * ctrl_u_ratio)], 0),
                 ([(cp.N_h[-1, -1], 0, L_x),
Exemple #9
0
# ===============================================================================
# Flat folding the segment
# ===============================================================================
tf_yt_plus_phi2 = CnstrTargetFace(
    F=[r_ * sp.cos((1 - t_ * fold_fraction) * phi / 2.0), r_ * sp.sin((1 - t_ * fold_fraction) * phi / 2.0), s_]
)
tf_yt_minus_phi2 = CnstrTargetFace(
    F=[r_ * sp.cos(-(1 - t_ * fold_fraction) * phi / 2.0), r_ * sp.sin(-(1 - t_ * fold_fraction) * phi / 2.0), s_]
)

ff = Folding(
    source=form,
    name="flat folding",
    tf_lst=[(tf_yt_plus_phi2, n_tf_y_plus_phi2), (tf_yt_minus_phi2, n_tf_y_minus_phi2), (tf_y_0, n_tf_y_0)],
    dof_constraints=fix(cp.N_h[0, :].flatten(), [0, 2]),
    n_steps=20,
    MAX_ITER=500,
)
# ff.X_1

# ===============================================================================
# Assembling the folded dome
# ===============================================================================

rp = RotSymAssembly(name="folded-rot-sym", source=ff, n_segments=n_segs_folded, n_visible=n_segs_folded - 3)

# ===============================================================================
# Assembling the dome
# ===============================================================================
                 ([(cp.N_h[0, -1], 0, L_x), (cp.N_h[0, -1], 1, L_y)], 0),
                 ([(cp.N_h[2, 0], 2, 1.0), (cp.N_h[2, -1], 2, -1.0)], 0),
                 ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[3, -1], 2, -1.0)], 0),
                 ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[2, 0], 2, -1.0)], 0),
                 ([(cp.N_h[0, 2], 2, 1.0), (cp.N_h[-1, 2], 2, -1.0)], 0),
                 ]

face_z_t = CnstrTargetFace(
    F=[r_, s_, -0.6 * t_ * (r_ * (1 - r_ / L_x) + s_ * (1 - s_ / L_y))])
init = Initialization(cp=cp, tf_lst=[(face_z_t, cp.N)], t_init=0.1)
fold = Folding(source=init,
               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.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]

N_x_0 = np.hstack([cp.N_k[n_x / 2, :].flatten()])  # , cp.N_i[0, :].flatten()])
N_z_t = np.hstack([cp.N_k[:, :].flatten(), cp.N_h[:, :].flatten()])

init = Initialization(cp=cp, n_steps=1,
                      tf_lst=[(face_z_t, N_z_t),
                              ],
                      t_init=0.1
                      )

init.t_arr
init.u_t[-1]
z_0 = init.x_1[cp.N_h[2, 0], 2]

N_l = np.hstack([cp.N_h[0, :].flatten()])
N_r = np.hstack([cp.N_h[-1, :].flatten()])

hanging = Folding(source=init, n_steps=10, name='hanging',
                  goal_function_type='potential_energy',
                  dof_constraints=fix(cp.N_h[(3, 4), :], 2, z_0) +
                  fix(cp.N_k[(1, 2, 3, 4, 5), 0], 1, 0.04) +
                  fix(cp.N_k[(1, 2, 3, 4, 5), -1], 1, -0.04) +
                  link(N_l, 0, 1.0, N_r, 0, 1.0),
                  acc=1e-6, MAX_ITER=500,
                  )

hanging.u_t[-1]


v = CreasePatternView(root=init)
v.configure_traits()


A = -0.1   #0.1

B = 0.05   #0.05


face_z_t = CnstrTargetFace(F=[r_, s_, 4 * A * t_ * r_ * (1 - r_ / L_x) + 4 * B * t_ * s_ * (1 - s_ / L_y)])
init = Initialization(cp=cp, tf_lst=[(face_z_t, cp.N)], t_init=1.0)
fold = Folding(source=init,
               goal_function_type='target_faces',
               n_steps=2,
               MAX_ITER=1000,
               tf_lst=[(face_z_t, cp.N)],
               dof_constraints=fix(cp.N_v[0,2], [0],1.0)
                               )                
#               dof_constraints=fix([0, 1], [0], v) + fix([0, 1, 6, 7], [2]) + \
#                               fix([0], [1]) + fix([6, 7], [0], -v))
fold.u_t[-1]

cpw = CreasePatternView(root=init)
cpw.configure_traits()





#al = AbaqusLink(data = fold, n_split = 3)
#al.model_name = 'hp_shell'
#al.build_inp()
#          ([(cp.N_h[-1, -1], 0, L_x), (cp.N_h[-1, -1], 1, -L_y)], 0),
#          ([(cp.N_h[0, -1], 0, L_x), (cp.N_h[0, -1], 1, L_y)], 0),
#          ([(cp.N_h[2, 0], 2, 1.0), (cp.N_h[2, -1], 2, -1.0)], 0),
#          ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[3, -1], 2, -1.0)], 0),
#          ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[2, 0], 2, -1.0)], 0),
#          ([(cp.N_h[0, 2], 2, 1.0), (cp.N_h[-1, 2], 2, -1.0)], 0),
#          ]

face_z_t = CnstrTargetFace(F=[r_, s_, -0.6 * t_ * (r_ * (1 - r_ / L_x) + s_ * (1 - s_ / L_y))])
init = Initialization(cp=cp, tf_lst=[(face_z_t, cp.N)], t_init=0.1)
fold = FormFinding(
    source=init,
    goal_function_type="potential_energy",
    n_steps=1,
    MAX_ITER=30,
    # tf_lst=[(face_z_t, cp.N)],
    dof_constraints=fix(all_fixed, [0, 1, 2])
    + fix(n_left_right, [0])
    + fix(n_vertical_boundaries, [0, 1, 2])
    + fix(n_horizontal_boundaries, [0, 1])
    + fix(n_midnode, [2], -0.5)
    + fix(n_i, [0])
    + fix(n_midnode, [0, 1]),
)
#               dof_constraints=fix([0, 1], [0], v) + fix([0, 1, 6, 7], [2]) + \
#                               fix([0], [1]) + fix([6, 7], [0], -v))
fold.u_t[-1]

cpw = CreasePatternView(root=init)
cpw.configure_traits()
                                        (tf_upper_z_t, n_tf_upper_z_t),
                                        (tf_lower_z_t, n_tf_lower_z_t),
                                        (tf_x_1, n_tf_x_1),
                                        (tf_z_0, n_tf_z_0),
                                        (tf_y_0, n_tf_y_0),
                                        ],
                   n_steps=3, MAX_ITER=500,
                   )
form.X_1

#===============================================================================
# Unfolding the segment
#===============================================================================
uf = Folding(source=form, name='unfolding', unfold=True, tf_lst=[(tf_upper_z_t, cp.N),
                                                                 ],
             dof_constraints=fix(cp.N_h[:, 1].flatten(), [1]),
             n_steps=10, MAX_ITER=500)
#uf.X_1

#===============================================================================
# Assembling the dome
#===============================================================================
rp = MonoShapeAssembly(source=form,
                       translations=[[0, 0, 0],
                                     [2, 0, 0],
                                     [0, 0, 0],
                                     [1, math.sqrt(3), 0],
                                     [2, 0, 0],
                                     [1, math.sqrt(3), 0],
                                     ],
                       rotation_axes=[[0, 0, 1],
n_r_h = cp.N_h[-1, (0, -1)].flatten()
n_lr_h = cp.N_h[(0, 0, -1, -1), (0, -1, 0, -1)].flatten()
n_fixed_y = cp.N_h[(0, -1), 2].flatten()

corner_slides = [([(cp.N_h[0, 0], 0, L_x), (cp.N_h[0, 0], 1, -L_y)], 0),
         ([(cp.N_h[-1, 0], 0, L_x), (cp.N_h[-1, 0], 1, L_y)], 0),
         ([(cp.N_h[-1, -1], 0, L_x), (cp.N_h[-1, -1], 1, -L_y)], 0),
         ([(cp.N_h[0, -1], 0, L_x), (cp.N_h[0, -1], 1, L_y)], 0),
         ([(cp.N_h[2, 0], 2, 1.0), (cp.N_h[2, -1], 2, -1.0)], 0),
         ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[3, -1], 2, -1.0)], 0),
         ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[2, 0], 2, -1.0)], 0),
         ([(cp.N_h[0, 2], 2, 1.0), (cp.N_h[-1, 2], 2, -1.0)], 0),
         ]

face_z_t = CnstrTargetFace(F=[r_, s_, -0.6 * t_ * (r_ * (1 - r_ / L_x) + s_ * (1 - s_ / L_y))])
init = Initialization(cp=cp, tf_lst=[(face_z_t, cp.N)], t_init=0.1)
fold = Folding(source=init,
               goal_function_type='potential_energy',
               n_steps=40,
               MAX_ITER=1000,
               #tf_lst=[(face_z_t, cp.N)],
               dof_constraints=fix(n_l_h, [0], v) + fix(n_lr_h, [2]) + \
                               fix(n_fixed_y, [1]) + fix(n_r_h, [0], -v) + \
                               corner_slides)
#               dof_constraints=fix([0, 1], [0], v) + fix([0, 1, 6, 7], [2]) + \
#                               fix([0], [1]) + fix([6, 7], [0], -v))
fold.u_t[-1]

cpw = CreasePatternView(root=init)
cpw.configure_traits()
                              ],
                      t_init=0.1
                      )

init.t_arr
init.u_t[-1]

fold = Folding(source=init, n_steps=10,
               tf_lst=[(face_x_0, N_x_0),
                       ],
               dof_constraints=dof_cons,
               MAX_ITER=500,
               )

# fold.u_t[-1]
z_0 = init.x_1[cp.N_h[2, 0], 2]

hanging = Folding(source=init, n_steps=10, name='hanging',
                  goal_function_type='potential_energy',
                  dof_constraints=fix(cp.N_h[(0, -1), :], 2, z_0) + \
                                   fix(cp.N_h[0, (2, 3)], 0, 0.1) + \
                                   fix(cp.N_h[-1, (2, 3)], 0, -0.1),
                  acc=1e-6, MAX_ITER=500,
               )

hanging.u_t[-1]


v = CreasePatternView(root=init)
v.configure_traits()
    #n = L_y / 2
#    y[2], y[3], y[4], y[5] = -0.0256, 0.0256, -0.011, 0.011
#    y[2], y[3], y[4], y[5] = -1.333, 1.333, -1, 1
#    x[2], x[3], x[8] , x[9] = 0.1477 , 0.1477, 0.0818, 0.2136
#    x[2], x[3], x[8] , x[9] = 4, 4, 2, 5
    x[2], x[3], x[8] , x[9] = 3.43, 3.43, 1.93, 4.93
    return np.c_[x, y, z]




cp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=2, n_y=2,
                            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
    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()
    ([(cp.N_h[0, -1], 0, L_x), (cp.N_h[0, -1], 1, L_y)], 0),
    ([(cp.N_h[2, 0], 2, 1.0), (cp.N_h[2, -1], 2, -1.0)], 0),
    ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[3, -1], 2, -1.0)], 0),
    ([(cp.N_h[3, 0], 2, 1.0), (cp.N_h[2, 0], 2, -1.0)], 0),
    ([(cp.N_h[0, 2], 2, 1.0), (cp.N_h[-1, 2], 2, -1.0)], 0),
]

face_z_t = CnstrTargetFace(F=[r_, s_, -0.6 * t_ * (r_ * (1 - r_ / L_x) + s_ * (1 - s_ / L_y))])
init = Initialization(cp=cp, tf_lst=[(face_z_t, cp.N)], t_init=0.1)
fold = Folding(
    source=init,
    goal_function_type="potential_energy",
    n_steps=10,
    MAX_ITER=1000,
    # tf_lst=[(face_z_t, cp.N)],
    dof_constraints=fix(n_l_h, [0], v) + fix(n_lr_h, [2]) + fix(n_fixed_y, [1]) + fix(n_r_h, [0], -v)
    # corner_slides
)
#               dof_constraints=fix([0, 1], [0], v) + fix([0, 1, 6, 7], [2]) + \
#                               fix([0], [1]) + fix([6, 7], [0], -v))
fold.u_t[-1]
mid_nodes = cp.N_h[(1, 2), 1].flatten()
print "mid nodes", mid_nodes
deflection = np.average(fold.u_t[-1][mid_nodes][:, 2])
print "deflection", deflection

n_l_h = cp.N_h[0, (0, -1)].flatten()
n_r_h = cp.N_h[-1, (0, -1)].flatten()
n_lr_h = cp.N_h[(0, -1), ::2].flatten()

hanging_ff = FormFinding(
Exemple #20
0
def get_constrained_YCP(L_x, L_y, n_x, n_y, d, n_steps):
    '''
    '''
    ycp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y)

    caf = CnstrTargetFace(
        F=[r_, s_, 5 * t_ * r_ * (1 - r_ / L_x) + 0.000015])
    n_arr = np.hstack([ycp.N_h[:, :].flatten(),
                       ycp.N_i[:, :].flatten()
                       ])

    init = Initialization(cp=ycp, tf_lst=[(caf, n_arr)])
    
#    m = Masking(source=init, F_mask=[42, 96, 43, 97, 0, 54, 1, 24, 78, 6, 12, 36, 90, 18, 72, 19, 48,
#                                     102, 49, 103, 46, 100, 47, 101, 58, 5, 59, 29, 83, 65,
#                                     52, 106, 53, 107, 76, 23, 77, 41, 95, 71],
#                L_mask=[0, 1, 28, 29, 40, 41, 52, 53, 148, 149, 124, 100, 76, 160, 58, 7,
#                        32, 44, 33, 45, 152, 128, 57, 129, 153, 5, 6, 105, 81, 165, 135, 13,
#                        20, 93, 177, 75, 26, 147, 27, 158, 98, 123, 159, 99, 38, 50, 39, 51,
#                        14, 112, 172, 70, 142, 21, 22, 118, 154, 94, 119, 155, 34, 46, 35, 47])
    

    fixed_node = fix(ycp.N_h[0, -1], (0, 1, 2))
    planar_front_boundary = link(ycp.N_h[0, 0], 1, 1.0,
                                 ycp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(ycp.N_h[0, -1], 1, 1.0,
                                ycp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(ycp.N_h[0, 0], 0, 1.0,
                                  ycp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(ycp.N_h[0, 0], 2, 1.0,
                                  ycp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(ycp.N_v[0, :], 2, 1.0,
                                   ycp.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 = [([(ycp.N_h[-1, 1], 0, 1.0)], d)]

    lift = Folding(source=init, n_steps=n_steps, MAX_ITER=500,
                   goal_function_type='none',
                   dof_constraints=fixed_node +
                   planar_front_boundary +
                   planar_back_boundary +
                   linked_left_boundary_x +
                   linked_left_boundary_z +
                   linked_left_and_right_z +
                   linked_right_boundary_x +
                   cntrl_displ,
                   #
                   )
    
    lift.u_1

    H = lift.x_1[ycp.N_i[1, 0], 2]
    L_x = lift.x_1[ycp.N_h[-1, 0], 0] - lift.x_1[ycp.N_h[0, 0], 0]
    L_y = lift.x_1[ycp.N_h[0, -1], 1] - lift.x_1[ycp.N_h[0, 0], 1]

    P = 0.20

    fexpr = get_fr(r_, L_x, H) + (get_fr(s_, L_y, -2 * P) + P) * 0.3 * t_

    face_z_t = CnstrTargetFace(
        F=[r_, s_, fexpr])

    n_arr = np.hstack([ycp.N_h[2, :].flatten(),
                       ycp.N_i[(1, 2), :].flatten(),
                       ])

    bend = Folding(source=lift, tf_lst=[(face_z_t, n_arr)],
                   MAX_ITER=200,
                   n_steps=1)

    bend.u_1

    fixed_nodes = np.hstack([ycp.N_h[np.ix_((0, -1,), (2, 3, 4))].flatten(),
                             ycp.N_h[2, (0, -1)].flatten()])
    fixed_node_constraints = fix(fixed_nodes, (0, 1, 2))

    hang = Folding(source=bend,
                   goal_function_type='potential_energy',
                   MAX_ITER=200,
                   dof_constraints=fixed_node_constraints,
                   n_steps=1)

    hang.u_1

    
    """Export of geometry in a file with generation of extra elements"""
#    al = InfocadLink(data = hang, n_split = 1)
#    al.model_name = 'hp_shell'
#    al.build_inp()

    """Export of geometry in a file without generation of finite elements"""
    #Output nodes
    #inpu = fold.x_0 
    out = hang.x_1
    fac = hang.F
    
    
    
    """
    #print out
    nodes = "*Node"
    for i in range(len(out)):   
        temp_node = ' %i \t %.4f \t %.4f \t %.4f\n' % (i + 1, out[i][0], out[i][1], out[i][2])
        temp_node = temp_node.replace('.', ',')
        nodes += temp_node
            
    facets = "*Elements" 
    for i in range(len(fac)):
        temp_facet = ' %i\tSH36\t%i\t%i\t%i\t\t\t\t\t\t1\n' % (i + 1, fac[i][0] + 1, fac[i][1] + 1, fac[i][2] + 1)
        facets += temp_facet

    part = nodes
    part += facets

    fname = 'spant_dach.inp'
    inp_file = open(fname, 'w')
    inp_file.write(part)
    inp_file.close()
    print'inp file %s written' % fname
    """

    m = Masking(source=hang, F_mask=[42, 96, 43, 97, 0, 54, 1, 24, 78, 6, 12, 36, 90, 18, 72, 19, 48,
                                     102, 49, 103, 46, 100, 47, 101, 58, 5, 59, 29, 83, 65,
                                     52, 106, 53, 107, 76, 23, 77, 41, 95, 71],
                L_mask=[0, 1, 28, 29, 40, 41, 52, 53, 148, 149, 124, 100, 76, 160, 58, 7,
                        32, 44, 33, 45, 152, 128, 57, 129, 153, 5, 6, 105, 81, 165, 135, 13,
                        20, 93, 177, 75, 26, 147, 27, 158, 98, 123, 159, 99, 38, 50, 39, 51,
                        14, 112, 172, 70, 142, 21, 22, 118, 154, 94, 119, 155, 34, 46, 35, 47])

    return init, lift
Exemple #21
0
def get_constrained_YCP(L_x, L_y, n_x, n_y, d, n_steps):
    '''
    '''
    ycp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y)

    caf = CnstrTargetFace(
        F=[r_, s_, 5 * t_ * r_ * (1 - r_ / L_x) + 0.000015])
    n_arr = np.hstack([ycp.N_h[:, :].flatten(),
                       ycp.N_i[:, :].flatten()
                       ])

    init = Initialization(cp=ycp, tf_lst=[(caf, n_arr)])

    fixed_node = fix(ycp.N_h[0, -1], (0, 1, 2))
    planar_front_boundary = link(ycp.N_h[0, 0], 1, 1.0,
                                 ycp.N_h[1:, 0], 1, -1.0)
    planar_back_boundary = link(ycp.N_h[0, -1], 1, 1.0,
                                ycp.N_h[1:, -1], 1, -1.0)
    linked_left_boundary_x = link(ycp.N_h[0, 0], 0, 1.0,
                                  ycp.N_h[0, 1:], 0, -1.0)
    linked_left_boundary_z = link(ycp.N_h[0, 0], 2, 1.0,
                                  ycp.N_h[0, 1:], 2, -1.0)
    linked_left_and_right_z = link(ycp.N_v[0, :], 2, 1.0,
                                   ycp.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 = [([(ycp.N_h[-1, 1], 0, 1.0)], d)]

    lift = Folding(source=init, n_steps=n_steps, MAX_ITER=500,
                   goal_function_type='none',
                   dof_constraints=fixed_node +
                   planar_front_boundary +
                   planar_back_boundary +
                   linked_left_boundary_x +
                   linked_left_boundary_z +
                   linked_left_and_right_z +
                   linked_right_boundary_x +
                   cntrl_displ,
                   #
                   )

    lift.u_1

    H = lift.x_1[ycp.N_i[1, 0], 2]
    L_x = lift.x_1[ycp.N_h[-1, 0], 0] - lift.x_1[ycp.N_h[0, 0], 0]
    L_y = lift.x_1[ycp.N_h[0, -1], 1] - lift.x_1[ycp.N_h[0, 0], 1]

    P = 0.2
    fexpr = get_fr(r_, L_x, H) + (get_fr(s_, L_y, -2 * P) + P) * 0.3 * t_

    face_z_t = CnstrTargetFace(
        F=[r_, s_, fexpr])

    n_arr = np.hstack([ycp.N_h[2, :].flatten(),
                       ycp.N_i[(1, 2), :].flatten(),
                       ])

    bend = Folding(source=lift, tf_lst=[(face_z_t, n_arr)],
                   MAX_ITER=200,
                   n_steps=1)

    bend.u_1

    fixed_nodes = np.hstack([ycp.N_h[np.ix_((0, -1,), (2, 3, 4))].flatten(),
                             ycp.N_h[2, (0, -1)].flatten()])
    fixed_node_constraints = fix(fixed_nodes, (0, 1, 2))

    hang = Folding(source=bend,
                   goal_function_type='potential_energy',
                   MAX_ITER=200,
                   dof_constraints=fixed_node_constraints,
                   n_steps=1)

    hang.u_1

    return init, lift
Exemple #22
0
def geo_trans(X):
    x, y, z = X.T
    #y_ = (y - L_y / 2) * (1 - (0.8)/ L_x * x)
    n = L_y / 2
    y = y - 0.0455
    y[2], y[3], y[4], y[5] = -0.0256, 0.0256, -0.011, 0.011
    x[2], x[3], x[8] , x[9] = 0.1477 , 0.1477, 0.0818, 0.2136
    return np.c_[x, y, z]




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

fix_left_z_x= fix(cp.N_v[0,0],[0,2])
fix_mid_y= fix(cp.N_v[:,0],[1])
fix_mid_y2= fix(cp.N_i[:,0],[1])
left_boundery_x= link(cp.N_h[0,0],0,1.0, cp.N_h[0,-1],0,-1.0)
left_boundery_y= link(cp.N_h[0,0],1,1.0, cp.N_h[0,-1],1,1.0)
right_boundery_x= link(cp.N_h[-1,0],0,1.0, cp.N_h[-1,-1],0,-1.0)
#right_boundery_y= link(cp.N_h[-1,0],1,1.0, cp.N_h[-1,-1],1,1.0)
#mid_boundery_x= link(cp.N_h[1,0],0,1.0, cp.N_h[1,-1],0,-1.0)
mid_boundery_y= link(cp.N_h[1,0],1,1.0, cp.N_h[1,-1],1,-1.0)
cntrl_displ = [([(cp.N_h[1,-1], 1, 1.0)], -0.01)]
"""cs= fix_left_z_x+
                                                  fix_mid_y+
                                                    fix_mid_y2+
                                                    left_boundery_x+
                                                    left_boundery_y+
                                                    right_boundery_x+
                       F=[[0, 1, 2], [1, 2, 3],
                          [2, 3, 4], [3, 4, 5],
                          [4, 5, 6], [5, 6, 7]
                          ]
                       )

    face_z_t = CnstrTargetFace(F=[r_, s_, -t_ * r_ * (1 - r_ / 3.0)])

    init = Initialization(cp=cp,
                          tf_lst=[(face_z_t, [2, 3, 4, 5])],
                          t_init=0.5)
    init.t_arr
    init.u_t[-1]

    fold = Folding(goal_function_type='target_faces',
                   dof_constraints=fix([0, 1], [0, 2]) + fix([6, 7], [2]) + fix([6, 7], [0], -0.2) + fix([0], [1]),
                   tf_lst=[(face_z_t, [2, 3, 4, 5])],
                   source=init, n_steps=1,
                   acc=1e-6, MAX_ITER=500,
                   )

    print fold.goal_function

    print 'u_t', fold.u_t[-1]

#    u = np.zeros_like(cp.X)
#    print 'f', oc.get_f(u)
#    print 'f_du', oc.get_f_du(u)

    cpw = CreasePatternView(root=init)
    cpw.configure_traits()
                      t_init=1.0 / 8.
                      )

init.t_arr
init.u_t[-1]

fold = Folding(source=init, n_steps=8,
               tf_lst=[(face_z_t, N_z_t),
                       (face_z_0, N_z_0)],
               dof_constraints=link(cp.N_h[0, 0], 0, 1.0, cp.N_h[0, -1], 0, -1.0) + \
                               link(cp.N_h[0, 1], 0, 1.0, cp.N_h[0, -2], 0, -1.0),
               acc=1e-6, MAX_ITER=500,
               )

fold.u_t[-1]

hanging = Folding(source=init, n_steps=20, name='hanging',
                  goal_function_type='potential_energy',
               dof_constraints=fix(cp.N_h[0, 0], 2) + \
                               fix(cp.N_h[1, 0], 2) + \
                               fix(cp.N_h[0, -1], 2) + \
                               fix(cp.N_h[1, -1], 2),
               acc=1e-6, MAX_ITER=500,
               )

fold.u_t[-1]

v = CreasePatternView(root=init)
v.configure_traits()