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_i[0, 0], 0, 1.0)], d)] 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 = Folding(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
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
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): 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
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): 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
cp = YoshimuraCreasePattern(L_x=L_x, L_y=L_y, n_x=n_x, n_y=n_y) A = 0.4 B = 1.0 s_term = A * t_ * s_ * (1 - s_ / L_y) #* r_ / L_x face_z_t = CnstrTargetFace(F=[r_, s_, t_ * (B * r_ * (1 - r_ / L_x) - s_term)]) n_arr = np.hstack([cp.N_h[1:-1, :].flatten(), cp.N_i[:, :].flatten()]) n_arr_0 = np.hstack([cp.N_h[(0, -1), :].flatten(), cp.N_v[:, :].flatten()]) face_z_0 = CnstrTargetFace(F=[r_, s_, 0]) init = Initialization(cp=cp, tf_lst=[(face_z_t, n_arr)], t_init=0.1) form = FormFinding(source=init, tf_lst=[(face_z_t, n_arr), (face_z_0, n_arr_0)], n_steps=2, MAX_ITER=500, dof_constraints=link(cp.N_v[0, :], 0, 1., cp.N_v[-1, :], 0, 1.) ) form.U_1 uf = Folding(name='develop', source=form, unfold=True, tf_lst=[(face_z_t, cp.N)], n_steps=10, MAX_ITER=500) #face_y1_t = CnstrTargetFace(F=[r_, t_ * L_y / 2., s_]) #face_y2_t = CnstrTargetFace(F=[r_, L_y - t_ * L_y / 2., s_]) face_y1_t = CnstrTargetFace(F=[r_, L_y / 2., s_]) ff = Folding(name='fold flat', source=form, tf_lst=[(face_y1_t, cp.N)], n_steps=1, MAX_ITER=500) v = CreasePatternView(root=init) v.configure_traits()
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
import numpy as np from oricrete.folding2 import \ YoshimuraCreasePattern, CnstrTargetFace, \ Reshaping, Folding, Initialization, CreasePatternView, \ link, fix, r_, s_, t_ from oricrete.folding2.infocad_link import InfocadLink #from oricrete.folding2.abaqus_link import AbaqusLink L_x = 2.42 L_y = 3.01 v = 0.15 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)
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()
# , cp.N_i[0, :].flatten()]) N_x_t_left = np.hstack([cp.N_h[n_l, :].flatten()]) # , cp.N_i[-1, :].flatten()]) N_x_t_right = np.hstack([cp.N_h[n_r, :].flatten()]) N_z_t = np.hstack([cp.N_k[:, :].flatten(), cp.N_h[:, :].flatten()]) N_z_0 = np.hstack([cp.N_h[(n_l, n_r, n_r, n_l), (0, 0, -1, -1)].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] fold = Folding(source=init, n_steps=8, tf_lst=[(face_x_t_left, N_x_t_left), (face_x_t_right, N_x_t_right), (face_z_0, N_z_0)], dof_constraints=link( cp.N_j[:, 0], 2, 1.0, cp.N_j[:, -1], 2, -1.0) + link(N_l, 2, 1.0, N_r, 2, -1.0), MAX_ITER=500, ) fold.u_t[-1] v = CreasePatternView(root=init) v.configure_traits()
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
L_y = 5 cp = WaterBombCreasePattern(L_x=L_x, L_y=L_y, n_x=1, n_y=5) t_end = 0.1 face_x_t_left = CnstrTargetFace(F=[t_end * L_x / 2.0 * t_, r_, s_]) face_x_t_right = CnstrTargetFace(F=[L_x * (1.0 - 1.0 / 2.0 * t_end * t_), r_, s_]) face_z_t = CnstrTargetFace(F=[r_, s_, t_]) N_x_t_left = np.hstack([cp.N_h[0, :].flatten()]) # , cp.N_i[0, :].flatten()]) N_x_t_right = np.hstack([cp.N_h[-1, :].flatten()]) # , cp.N_i[-1, :].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] fold = Folding( source=init, n_steps=8, tf_lst=[(face_x_t_left, N_x_t_left), (face_x_t_right, N_x_t_right)], dof_constraints=link(cp.N_j[:, 0], 2, 1.0, cp.N_j[:, -1], 2, -1.0), MAX_ITER=500, ) fold.u_t[-1] v = CreasePatternView(root=init) v.configure_traits()
#=============================================================================== # Form-finding object #=============================================================================== form = FormFinding(source=init, tf_lst=[(tf_y_plus_phi2, n_tf_y_plus_phi2), (tf_y_minus_phi2, n_tf_y_minus_phi2), (tf_par_upper_z_t, n_tf_upper_z_t), (tf_par_lower_z_t, n_tf_lower_z_t), (tf_x_R_i, n_tf_x_R_i), (tf_z_0, n_tf_z_0), (tf_z_H1, n_tf_z_H1), (tf_z_H2, n_tf_z_H2), (tf_z_H3, n_tf_z_H3), (tf_y_0, n_tf_y_0), ], dof_constraints=link(cp.N_h[:, 0], [0], 1.0, cp.N_h[:, -1], [0], -1.0), n_steps=1, MAX_ITER=500, ) form.X_1 #=============================================================================== # Assembling the dome #=============================================================================== rp = RotSymAssembly(source=form, center=[0.0, 0, 0], n_segments=n_segs, n_visible=n_segs) rp.X_1 v = CreasePatternView(root=init) v.configure_traits()
lower_nodes = cp.N_h[:, :mid_node_idx].flatten() upper_nodes = cp.N_h[:, -1:mid_node_idx:-1].flatten() print 'lower', lower_nodes print 'upper', upper_nodes init = Initialization(cp=cp, tf_lst=[(face_z_t, np.hstack([cp.N_h.flatten(), cp.N_i.flatten()]))], t_init=0.1) fold_to_target_face = Folding(source=init, 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() ]))], dof_constraints=fix(cp.N_h[:, mid_node_idx], 1) + \ link(cp.N_v[-1, :mid_node_idx], 2, 1.0, cp.N_v[-1, -1:mid_node_idx - 1:-1], 2, -1.0) + \ link(cp.N_v[0, :mid_node_idx], 2, 1.0, cp.N_v[0, -1:mid_node_idx - 1:-1], 2, -1.0) + \ # # regularity of the fold angle on the left and right boundary [([(cp.N_h[0, 0], 2, 1.0), (cp.N_v[0, 0], 2, -1.0), (cp.N_h[0, 1], 2, -1.0), (cp.N_v[0, 1], 2, 1.0), ], 0.0), ([(cp.N_h[0, -1], 2, 1.0), (cp.N_v[0, -1], 2, -1.0), (cp.N_h[0, -2], 2, -1.0), (cp.N_v[0, -2], 2, 1.0), ], 0.0), ([(cp.N_h[-1, 0], 2, 1.0), (cp.N_v[-1, 0], 2, -1.0), (cp.N_h[-1, 1], 2, -1.0), (cp.N_v[-1, 1], 2, 1.0), ], 0.0), ([(cp.N_h[-1, -1], 2, 1.0), (cp.N_v[-1, -1], 2, -1.0), (cp.N_h[-1, -2], 2, -1.0), (cp.N_v[-1, -2], 2, 1.0), ], 0.0), ] ) cpw = CreasePatternView(root=init) cpw.configure_traits()
face_z_t = CnstrTargetFace(F=[r_, s_, 0.47 * t_]) N_z_t = np.hstack([cp.N_k[:, :].flatten()]) #, cp.N_h[:, :].flatten()]) N_z_0 = np.hstack([cp.N_i[:, :].flatten(), cp.N_j[:, :].flatten()]) print cp.N_k[:, :] print cp.N_j[:, :] init = Initialization(cp=cp, n_steps=1, tf_lst=[(face_z_t, N_z_t), ], 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] v = CreasePatternView(root=init) v.configure_traits()
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+ #right_boundery_y+ #mid_boundery_x+ mid_boundery_y+
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()]) N_l = np.hstack([cp.N_h[0, :].flatten()]) N_r = np.hstack([cp.N_h[-1, :].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] 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.02) + fix(cp.N_k[(1, 2, 3, 4, 5), -1], 1, -0.02) + link(N_l, 0, 1.0, N_r, 0, 1.0) + link(N_l, 2, 1.0, N_r, 2, -1.0), acc=1e-6, MAX_ITER=500, ) hanging.u_t[-1] v = CreasePatternView(root=init) v.configure_traits()
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()
# 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 caf = CnstrTargetFace(F=[r_, s_, 4 * 0.4 * t_ * r_ * (1 - r_ / L_x) + 0.15]) n_arr = np.hstack([cp.N_h[:, :].flatten(),