def _get_turn_task2(self): self.fold_task.x_1 u_z = 0.1 fixed_nodes_xzy = fix([7, 19], (0, 1, 2)) lift_nodes_z = fix([3, 15], (2), lambda t: t * u_z) dof_constraints = fixed_nodes_xzy + lift_nodes_z gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-5, MAX_ITER=1000, debug_level=0) load_nodes = [] FN = lambda F: lambda t: t * F F_ext_list = [(n, 2, FN(-10)) for n in load_nodes] fu_tot_poteng = FuPotEngTotal(kappa=np.array([1000]), F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=1) fu_tot_poteng.forming_task = st cp = st.formed_object cp.u[(3, 15), 2] = u_z return st
def _get_turn_task2(self): self.fold_task.x_1 u_z = 0.1 fixed_nodes_xzy = fix([7, 19], (0, 1, 2)) lift_nodes_z = fix([3, 15], (2), lambda t: t * u_z) dof_constraints = fixed_nodes_xzy + lift_nodes_z gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig( goal_function_type='total potential energy', gu={ 'cl': gu_constant_length, 'dofs': gu_dof_constraints }, acc=1e-5, MAX_ITER=1000, debug_level=0) load_nodes = [] FN = lambda F: lambda t: t * F F_ext_list = [(n, 2, FN(-10)) for n in load_nodes] fu_tot_poteng = FuPotEngTotal(kappa=np.array([1000]), F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=1) fu_tot_poteng.forming_task = st cp = st.formed_object cp.u[(3, 15), 2] = u_z return st
def _get_load_task(self): self.fold_task.x_1 dof_constraints = fix( [0, 2, 6], [2]) + fix([0, 2], [1]) + fix([6], [0]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, use_f_du=True, acc=1e-8, MAX_ITER=1000, debug_level=0) FN = lambda F: lambda t: t * F F_ext_list = [(n, 2, FN(-1)) for n in [1, 3]] print('F_ext_list', F_ext_list) fu_tot_poteng = FuPotEngTotal(kappa=10, fu_factor=1, F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=1) cp = st.formed_object cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 #cp.u[(4, 5), 2] = -0.001 #cp.u[(1, 3), 2] = -0.001 fu_tot_poteng.forming_task = st return st
def _get_load_task(self): self.fold_task.x_1 dof_constraints = fix( [0, 2, 6], [2]) + fix([0, 2], [1]) + fix([6], [0]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, use_f_du=True, acc=1e-8, MAX_ITER=1000, debug_level=0) FN = lambda F: lambda t: t * F F_ext_list = [(n, 2, FN(-1)) for n in [1, 3]] print 'F_ext_list', F_ext_list fu_tot_poteng = FuPotEngTotal(kappa=10, fu_factor=1, F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=1) cp = st.formed_object cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 #cp.u[(4, 5), 2] = -0.001 #cp.u[(1, 3), 2] = -0.001 fu_tot_poteng.forming_task = st return st
def _get_load_task(self): self.fold_task.x_1 cp = self.factory_task n_l_h = cp.N_h[0, (0, -1)].flatten() n_r_h = cp.N_h[-1, (0, -1)].flatten() dof_constraints = fix(n_l_h, [0, 1, 2]) + fix(n_r_h, [0, 1, 2]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, use_f_du=True, acc=1e-4, MAX_ITER=1000, debug_level=0) F_ext_list = [(n, 2, 100.0) for n in cp.N_h[1, :]] fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]), F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=1) cp = st.formed_object cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 fu_tot_poteng.forming_task = st return st
def _get_load_task(self): self.turn_task.x_1 fixed_nodes_yz = fix([0, 2, 20, 22], (1, 2)) # + \ fixed_nodes_x = fix([0, 2, 20, 22], (0)) # + \ # fix([1, 21], [0, 2]) link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74], [0, 1, 2], 1.0, [51, 52, 53, 59, 60, 61, 67, 68, 69, 75, 76, 77], [0, 1, 2], -1.0) dof_constraints = fixed_nodes_x + fixed_nodes_yz + link_bnd gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-5, MAX_ITER=1000, debug_level=0) load_nodes = [10, 11, 12] FN = lambda F: lambda t: t * F F_ext_list = [(n, 2, FN(-10)) for n in load_nodes] fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]), F_ext_list=F_ext_list) # (2 * n, 2, -1)]) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.turn_task, config=sim_config, n_steps=1) fu_tot_poteng.forming_task = st cp = st.formed_object cp.x_0 = self.turn_task.x_1 cp.u[:, :] = 0.0 return st
def _get_load_task(self): self.fold_task.x_1 cp = self.factory_task n_l_h = cp.N_h[0, (0, -1)].flatten() n_r_h = cp.N_h[-1, (0, -1)].flatten() dof_constraints = fix(n_l_h, [0, 1, 2]) + fix(n_r_h, [0, 1, 2]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig( goal_function_type='total potential energy', gu={ 'cl': gu_constant_length, 'dofs': gu_dof_constraints }, use_f_du=True, acc=1e-4, MAX_ITER=1000, debug_level=0) F_ext_list = [(n, 2, 100.0) for n in cp.N_h[1, :]] fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]), F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=1) cp = st.formed_object cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 fu_tot_poteng.forming_task = st return st
def _get_load_task(self): self.fold_task.x_1 cp = self.factory_task n_l_h = cp.N_h[0, (0, -1)].flatten() n_r_h = cp.N_h[-1, (0, -1)].flatten() dof_constraints = fix( [0, 2, 4], [0, 1, 2]) + fix([20, 22, 24], [0, 1, 2]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-6, MAX_ITER=1000, debug_level=0) FN = lambda F: lambda t: t * F F_max = 20 F_ext_list = [(cp.N_h[2, :], 2, FN(F_max))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]), F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=10) cp = st.formed_object cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 cp.u[[10, 11, 12, 13, 14], 2] = 0.001 fu_tot_poteng.forming_task = st return st
def _get_fold_deform_task(self): ft = self.factory_task self.init_displ_task.x_1 fixed_z = fix(self.fixed_z, (2)) fixed_y = fix(self.fixed_y, (1)) fixed_x = fix(self.fixed_x, (0)) link_z = link(self.link_z[0], [2], 1, self.link_z[1], [2], -1) dof_constraints = fixed_x + fixed_z + fixed_y + \ link_z gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) def FN(psi): return lambda t: psi * t psi_constr = [([(i, 1.0)], FN(self.psi_max)) for i in self.psi_lines] gu_constant_length = GuConstantLength() gu_psi_constraints = \ GuPsiConstraints(forming_task=ft, psi_constraints=psi_constr) sim_config = SimulationConfig( goal_function_type='gravity potential energy', gu={ 'cl': gu_constant_length, 'dofs': gu_dof_constraints, 'psi': gu_psi_constraints }, acc=1e-5, MAX_ITER=self.MAXITER, debug_level=0) fu_tot_poteng = FuPotEngTotal(kappa=np.array([self.kappa]), F_ext_list=[], rho=self.rho, exclude_lines=self.psi_lines) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.init_displ_task, config=sim_config, n_steps=self.n_steps) # # st = SimulationTask(previous_task=ft, # config=sim_config, n_steps=self.n_steps) fu_tot_poteng.forming_task = st # gu_psi_constraints.forming_task = st # # cp = st.formed_object # cp.u = it.u_1 return st
def _get_load_task(self): self.turn_task.x_1 fixed_nodes_yz = fix([0, 2, 20, 22], (1, 2)) # + \ fixed_nodes_x = fix([0, 2, 20, 22], (0)) # + \ # fix([1, 21], [0, 2]) link_bnd = [] if self.stiffening_boundary: link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74], [0, 1, 2], 1.0, [51, 52, 53, 59, 60, 61, 67, 68, 69, 75, 76, 77], [0, 1, 2], -1.0) dof_constraints = fixed_nodes_x + fixed_nodes_yz + link_bnd gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig( goal_function_type='total potential energy', gu={ 'cl': gu_constant_length, 'dofs': gu_dof_constraints }, acc=1e-5, MAX_ITER=1000, debug_level=0) def FN(F): return lambda t: t * F H = 0 P = 3.5 * self.load_factor F_ext_list = [(33, 2, FN(-P)), (34, 2, FN(-P)), (11, 2, FN(-P)), (39, 2, FN(-P)), (40, 2, FN(-P)), (4, 0, FN(0.1609 * H)), (4, 2, FN(-0.2385 * H)), (10, 2, FN(-0.3975 * H)), (16, 0, FN(-0.1609 * H)), (16, 2, FN(-0.2385 * H)), (6, 0, FN(0.1609 * H)), (6, 2, FN(-0.2385 * H)), (12, 2, FN(-0.3975 * H)), (18, 0, FN(-0.1609 * H)), (18, 2, FN(-0.2385 * H))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([5.28]), F_ext_list=F_ext_list) # load_nodes = [10, 11, 12] # FN = lambda F: lambda t: t * F # F_ext_list = [(n, 2, FN(-10)) for n in load_nodes] # fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]), # F_ext_list=F_ext_list) # (2 * n, 2, -1)]) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.turn_task, config=sim_config, n_steps=self.n_load_steps) fu_tot_poteng.forming_task = st cp = st.formed_object cp.x_0 = self.turn_task.x_1 cp.u[:, :] = 0.0 return st
def _get_load_task(self): self.turn_task.x_1 fixed_nodes_yz = fix([0, 2, 20, 22], (1, 2)) # + \ fixed_nodes_x = fix([0, 2, 20, 22], (0)) # + \ fixed_nodes_middle = fix([1, 21], [0, 1, 2]) # 'Gesamter Randbereich' # link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74, 71, 55], # [0, 1, 2], 1.0, # [51, 52, 53, 59, 60, 61, 67, # 68, 69, 75, 76, 77, 63, 47], # [0, 1, 2], -1.0) # 'Ohne mittlere Randknoten' # link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74], # [0, 1, 2], 1.0, # [51, 52, 53, 59, 60, 61, 67, # 68, 69, 75, 76, 77], # [0, 1, 2], -1.0) # 'Ohne aeussere Randknoten' # link_bnd = link([48, 49, 56, 57, 64, 65, 72, 73, 71, 55], # [0, 1, 2], 1.0, # [51, 52, 59, 60, 67, # 68, 75, 76, 63, 47], # [0, 1, 2], -1.0) # + link_bnd + # fixed_nodes_middle dof_constraints = fixed_nodes_x + fixed_nodes_yz gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-8, MAX_ITER=1000, debug_level=0) FN = lambda F: lambda t: t * F H = 0 P = 3.5 F_ext_list = [(33, 2, FN(-P)), (34, 2, FN(-P)), (11, 2, FN(-P)), (39, 2, FN(-P)), (40, 2, FN(-P)), (4, 0, FN(0.1609 * H)), (4, 2, FN(-0.2385 * H)), (10, 2, FN(-0.3975 * H)), (16, 0, FN(-0.1609 * H)), (16, 2, FN(-0.2385 * H)), (6, 0, FN(0.1609 * H)), (6, 2, FN(-0.2385 * H)), (12, 2, FN(-0.3975 * H)), (18, 0, FN(-0.1609 * H)), (18, 2, FN(-0.2385 * H))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([5.28]), F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.turn_task, config=sim_config, n_steps=1) fu_tot_poteng.forming_task = st cp = st.formed_object cp.x_0 = self.turn_task.x_1 cp.u[:, :] = 0.0 return st
def _get_load_task(self): self.fold_task.x_1 fat = self.factory_task fixed_corner_n = fat.N_grid[(0, 0, -1, -1), (1, -2, 1, -2)].flatten() fixed_n = fat.N_grid[(0, 0), (1, -2)].flatten() slide_z = fix(fat.N_grid[-1, -2], [2], lambda t: -0.8 * self.L_x * t) slide_x = fix(fat.N_grid[-1, -2], [0], lambda t: 0.1 * self.L_y * t) loaded_n = fat.N_grid[self.n_x / 2, self.n_y / 2] fixed_nodes_xyz = fix(fixed_n, (0, 2)) + slide_z #fixed_nodes_xyz = fix(fixed_corner_n, (0, 1, 2)) dof_constraints = fixed_nodes_xyz gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() diag_psi_mask = np.ones_like(fat.L_d_grid, dtype=np.bool_) diag_psi_mask[1:-1, 1:-1] = False diag_lines = fat.L_d_grid[diag_psi_mask].flatten() diag_psi_constraints = [([(i, 1.0)], 0) for i in diag_lines] gu_psi_constraints = \ GuPsiConstraints(forming_task=fat, psi_constraints=diag_psi_constraints) sim_config = SimulationConfig( goal_function_type='total potential energy', gu={ 'cl': gu_constant_length, 'dofs': gu_dof_constraints, 'psi': gu_psi_constraints }, acc=1e-5, MAX_ITER=1000, debug_level=0) def FN(F): return lambda t: t * F P = 0.0 * 30.5 * self.load_factor F_ext_list = [(loaded_n, 2, FN(-P))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([1.0]), F_ext_list=F_ext_list, thickness=1, exclude_lines=diag_lines) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=self.n_load_steps) fu_tot_poteng.forming_task = st cp = st.formed_object cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 return st
def _get_load_task(self): self.fold_task.x_1 fat = self.factory_task fixed_corner_n = fat.N_grid[(0, 0, -1, -1), (1, -2, 1, -2)].flatten() fixed_n = fat.N_grid[(0, 0), (1, -2)].flatten() slide_z = fix(fat.N_grid[-1, -2], [2], lambda t: -0.8 * self.L_x * t) slide_x = fix(fat.N_grid[-1, -2], [0], lambda t: 0.1 * self.L_y * t) loaded_n = fat.N_grid[self.n_x / 2, self.n_y / 2] fixed_nodes_xyz = fix(fixed_n, (0, 2)) + slide_z #fixed_nodes_xyz = fix(fixed_corner_n, (0, 1, 2)) dof_constraints = fixed_nodes_xyz gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() diag_psi_mask = np.ones_like(fat.L_d_grid, dtype=np.bool_) diag_psi_mask[1:-1, 1:-1] = False diag_lines = fat.L_d_grid[diag_psi_mask].flatten() diag_psi_constraints = [([(i, 1.0)], 0) for i in diag_lines] gu_psi_constraints = \ GuPsiConstraints(forming_task=fat, psi_constraints=diag_psi_constraints) sim_config = SimulationConfig( goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints, 'psi': gu_psi_constraints }, acc=1e-5, MAX_ITER=1000, debug_level=0 ) def FN(F): return lambda t: t * F P = 0.0 * 30.5 * self.load_factor F_ext_list = [(loaded_n, 2, FN(-P))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([1.0]), F_ext_list=F_ext_list, thickness=1, exclude_lines=diag_lines ) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=self.n_load_steps) fu_tot_poteng.forming_task = st cp = st.formed_object cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 return st
def _get_fold_deform_task(self): ft = self.factory_task self.init_displ_task.x_1 fixed_z = fix(self.fixed_z, (2)) fixed_y = fix(self.fixed_y, (1)) fixed_x = fix(self.fixed_x, (0)) link_z = link(self.link_z[0], [2], 1, self.link_z[1], [2], -1) dof_constraints = fixed_x + fixed_z + fixed_y + \ link_z gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) def FN(psi): return lambda t: psi * t psi_constr = [([(i, 1.0)], FN(self.psi_max)) for i in self.psi_lines] gu_constant_length = GuConstantLength() gu_psi_constraints = \ GuPsiConstraints(forming_task=ft, psi_constraints=psi_constr) sim_config = SimulationConfig(goal_function_type='gravity potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints, 'psi': gu_psi_constraints }, acc=1e-5, MAX_ITER=self.MAXITER, debug_level=0) fu_tot_poteng = FuPotEngTotal(kappa=np.array([self.kappa]), F_ext_list=[], rho=self.rho, exclude_lines=self.psi_lines) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.init_displ_task, config=sim_config, n_steps=self.n_steps) # # st = SimulationTask(previous_task=ft, # config=sim_config, n_steps=self.n_steps) fu_tot_poteng.forming_task = st # gu_psi_constraints.forming_task = st # # cp = st.formed_object # cp.u = it.u_1 return st
def _get_load_task(self): self.turn_task.x_1 fixed_nodes_yz = fix([0, 2, 20, 22], (1, 2)) # + \ fixed_nodes_x = fix([0, 2, 20, 22], (0)) # + \ # fix([1, 21], [0, 2]) link_bnd = [] if self.stiffening_boundary: link_bnd = link([48, 49, 50, 56, 57, 58, 64, 65, 66, 72, 73, 74], [0, 1, 2], 1.0, [51, 52, 53, 59, 60, 61, 67, 68, 69, 75, 76, 77], [0, 1, 2], -1.0) dof_constraints = fixed_nodes_x + fixed_nodes_yz + link_bnd gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-5, MAX_ITER=1000, debug_level=0) FN = lambda F: lambda t: t * F H = 0 P = 3.5 * self.load_factor F_ext_list = [(33, 2, FN(-P)), (34, 2, FN(-P)), (11, 2, FN(-P)), (39, 2, FN(-P)), (40, 2, FN(-P)), (4, 0, FN(0.1609 * H)), (4, 2, FN(-0.2385 * H)), (10, 2, FN(-0.3975 * H)), (16, 0, FN(-0.1609 * H)), (16, 2, FN(-0.2385 * H)), (6, 0, FN(0.1609 * H)), (6, 2, FN(-0.2385 * H)), (12, 2, FN(-0.3975 * H)), (18, 0, FN(-0.1609 * H)), (18, 2, FN(-0.2385 * H))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([5.28]), F_ext_list=F_ext_list) # load_nodes = [10, 11, 12] # FN = lambda F: lambda t: t * F # F_ext_list = [(n, 2, FN(-10)) for n in load_nodes] # fu_tot_poteng = FuPotEngTotal(kappa=np.array([10]), # F_ext_list=F_ext_list) # (2 * n, 2, -1)]) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.turn_task, config=sim_config, n_steps=self.n_load_steps) fu_tot_poteng.forming_task = st cp = st.formed_object cp.x_0 = self.turn_task.x_1 cp.u[:, :] = 0.0 return st
def create_fu(): cp_factory = create_cp_factory() # begin from oricreate.fu import FuPotEngTotal # Link the pattern factory with the goal function client. fu_poteng = FuPotEngTotal(forming_task=cp_factory, exclude_lines=[4, 5]) # Change the vertical coordinate to get # a non-zero value of potential energy cp = cp_factory.formed_object cp.u[4, 2] = -1.0 #cp.u[3, 2] = -1.0 # Note: the above assignments to array elements are not # registered by the change notification system. # In order to trigger the dependency chain notifying # the fu_poteng instance that something has changed # an assignment to an array as a whole is necessary: cp.u = cp.u print('F_V_du', cp.F_V_du) print('fu:', fu_poteng.get_f(cp.u)) print('f_du:\n', fu_poteng.get_f_du(cp.u)) # end return fu_poteng
def _get_load_task(self): self.fold_task.x_1 cp = self.factory_task n_l_h = cp.N_h[0, (0, -1)].flatten() n_r_h = cp.N_h[-1, (0, -1)].flatten() n_fixed_y = cp.N_h[(0, -1), 1].flatten() n_scheitel = cp.N_h[2, :] n_aussen = cp.N_v dof_constraints = fix( n_l_h, [0, 2]) + fix(n_r_h, [0, 2]) + fix(n_fixed_y, [0, 1]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-10, MAX_ITER=1000, debug_level=0) FN = lambda F: lambda t: t * F F_max = 2 F_min = 1 F_ext_list = [(7, 2, FN(F_max)), (6, 2, FN(F_min)), (8, 2, FN(F_min))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([4.97]), F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.fold_task, config=sim_config, n_steps=10) cp = st.formed_object cp.L = np.vstack([cp.L, np.array([[6, 7], [7, 8]], dtype='int_')]) cp.x_0 = self.fold_task.x_1 cp.u[:, :] = 0.0 cp.u[[6, 7, 8], 2] = 0.0001 fu_tot_poteng.forming_task = st return st
def create_fu(): cp_factory = create_cp_factory() # begin from oricreate.fu import FuPotEngTotal # Link the pattern factory with the goal function client. fu_poteng = FuPotEngTotal(forming_task=cp_factory, exclude_lines=[4, 5]) # Change the vertical coordinate to get # a non-zero value of potential energy cp = cp_factory.formed_object cp.u[4, 2] = -1.0 #cp.u[3, 2] = -1.0 # Note: the above assignments to array elements are not # registered by the change notification system. # In order to trigger the dependency chain notifying # the fu_poteng instance that something has changed # an assignment to an array as a whole is necessary: cp.u = cp.u print 'F_V_du', cp.F_V_du print 'fu:', fu_poteng.get_f(cp.u) print 'f_du:\n', fu_poteng.get_f_du(cp.u) # end return fu_poteng
dof_constraints = fix([1], [0, 1, 2]) + fix([0], [2]) + fix([2], [0, 2]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) sim_config = SimulationConfig(goal_function_type='total potential energy', debug_level=0, use_f_du=True, gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-7, MAX_ITER=1000) FN = lambda F: lambda t: t * F P = 1 F_ext_list = [(3, 2, FN(-P))] fu_tot_poteng = FuPotEngTotal(kappa=np.array([100]), fu_factor=1, F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng sim_task = SimulationTask(previous_task=cp_factory_task, config=sim_config, n_steps=10) cp = sim_task.formed_object cp.x_0 = np.copy(sim_task.previous_task.formed_object.X) cp.u[:, :] = 0.0 fu_tot_poteng.forming_task = sim_task cp.u[1, 2] = -0.0001 cp.u[3, 2] = -0.0001 sim_task.u_1
def _get_fold_self_weight_cntl(self): self.init_displ_task.x_1 f = self.factory_task cp = f.formed_object N_h = f.N_h N_i = f.N_i N_v = f.N_v fixed_nodes_x = fix( N_i[1, (0, 1)], (0)) fixed_nodes_y = fix( [N_h[1, 1].flatten()], (1)) fixed_nodes_z = fix( list(N_v[[0, 0, -1, -1], [0, -1, 0, -1]].flatten()) + list(N_i[[0, 0, -1, -1], [0, -1, 0, -1]].flatten()), (2) ) cntl_z = fix(N_h[(1, 2), 1], 2, lambda t: 0.1 * t) link_nodes_y = link( list(N_v[[0, -1], [0, -1]].flatten()), 1, 1.0, list(N_i[[0, -1], [0, -1]].flatten()), 1, -1.0, ) link_nodes_z = link( list(N_h[[1, 1, 1], [0, 1, -1]].flatten()), 2, 1.0, list(N_h[[2, 2, 2], [0, 1, -1]].flatten()), 2, -1.0, ) # link_nodes_z = link( # N_h[1, 1], 2, 1.0, # N_h[2, 1], 2, -1.0, # ) dof_constraints = fixed_nodes_x + fixed_nodes_z + fixed_nodes_y + \ link_nodes_z + \ link_nodes_y # link_nodes_yz + link_nodes_z gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() sim_config = SimulationConfig(goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints, }, acc=1e-5, MAX_ITER=1000, debug_level=0) def FN(F): return lambda t: t * F H = 0 P = 0.1 F_ext_list = [(N_i[1, 1], 2, FN(-P)), (N_i[1, -1], 2, FN(-P)), (N_h[(0, -1), 0], 2, FN(-P)), (N_h[(0, -1), -1], 2, FN(-P)) ] fu_tot_poteng = FuPotEngTotal(kappa=0.0, thickness=0.01, rho=23.6, F_ext_list=F_ext_list) sim_config._fu = fu_tot_poteng st = SimulationTask(previous_task=self.init_displ_task, config=sim_config, n_steps=self.n_fold_steps) fu_tot_poteng.forming_task = st cp = st.formed_object N_down = np.hstack([N_h[::3, :].flatten(), N_i[1::3, :].flatten() ]) print 'N_down', N_down N_up = np.hstack([N_i[::3, :].flatten(), N_i[2::3, :].flatten(), N_v[:, :].flatten()]) print 'N_up', N_up cp.u[N_down, 2] -= self.d_down cp.u[N_up, 2] += self.d_up cp.u[:, 2] += self.d_down return st
def _get_load_self_weight(self): self.fold_kinem_cntl.x_1 f = self.factory_task exclude_lines = np.arange(9, 17) cp = f.formed_object N_h = f.N_h N_i = f.N_i N_v = f.N_v fixed_nodes = np.hstack([N_h[[-1, -1], [0, -1]]]) fixed_nodes = [25, 27] fixed_nodes_xyz = fix( list(N_h[[0, 0, -1, -1], [0, -1, 0, -1]].flatten()), (2) #fixed_nodes, (0, 2) ) slided_nodes = np.hstack([N_h[[0, -1], [0, 0]]]) # , [22, 25]]) #slide_y = fix(slided_nodes, [1], lambda t: 1.8 * self.L_y * t) slide_x = fix([22, 24], [2], lambda t: 0.95 * (self.L_x) * t) slide_z = fix(N_h[[1, -2], [1, 1]], [2], lambda t: -0.3 * t) dof_constraints = fixed_nodes_xyz + slide_z gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) gu_constant_length = GuConstantLength() fix_psi_constr = [([(i, 1.0)], 0.0) for i in exclude_lines] gu_psi_constraints = \ GuPsiConstraints(forming_task=self.fold_kinem_cntl, psi_constraints=fix_psi_constr) sim_config = SimulationConfig( goal_function_type='total potential energy', gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints, 'psi': gu_psi_constraints }, acc=1e-7, MAX_ITER=1000, debug_level=0 ) loaded_n = N_h[:, 1].flatten() def FN(F): return lambda t: t * F P = 0.0 * 30.5 F_ext_list = [] # (loaded_n, 2, FN(-P))] thickness = 0.01 E_mod = 21.0e+4 I = 1.0 * thickness**3 / 12.0 kappa = E_mod * I print 'kappa', kappa sig_tu = 3000.0 m_u = sig_tu * 1.0 * thickness**2 / 6.0 print 'm_u', m_u fu_tot_poteng = FuPotEngTotal( exclude_lines=exclude_lines, kappa=np.array([kappa]), thickness=thickness, rho=23.6, m_u=m_u, F_ext_list=F_ext_list ) sim_config._fu = fu_tot_poteng st = SimulationTask( previous_task=self.fold_kinem_cntl, config=sim_config, n_steps=self.n_load_steps ) fu_tot_poteng.forming_task = st cp = st.formed_object cp.x_0 = self.fold_kinem_cntl.x_1 cp.u[:, :] = 0.0 return st
dof_constraints = fix([0], [0, 1, 2]) + fix([1], [1, 2]) \ + fix([n + 1], [2]) # + fix([n * 2], [1]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) sim_config = SimulationConfig(goal_function_type='total potential energy', debug_level=0, use_f_du=True, gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-7, MAX_ITER=1000) F_nodes = np.linspace(0, -10, n) FN = lambda F: lambda t: t * F F_ext_list = [(i + 1, 2, FN(F_n)) for i, F_n in enumerate(F_nodes)] fu_tot_poteng = FuPotEngTotal(kappa=np.array([5000.0]), fu_factor=1, F_ext_list=F_ext_list) # (2 * n, 2, -1)]) sim_config._fu = fu_tot_poteng sim_task = SimulationTask(previous_task=cp_factory_task, config=sim_config, n_steps=10) cp = sim_task.formed_object cp.x_0 = np.copy(sim_task.previous_task.formed_object.X) cp.u[:, :] = 0.0 fu_tot_poteng.forming_task = sim_task cp.u[1:n + 1, 2] = np.linspace(0, -0.001, n) cp.u[n + 1:(2 * n) + 1, 2] = np.linspace(0, -0.0005, n) print 'kinematic simulation: u', sim_task.u_1 cp = sim_task.formed_object
dof_constraints = fix([0], [0, 1, 2]) + fix([1], [1, 2]) \ + fix([n + 1], [2]) # + fix([n * 2], [1]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) sim_config = SimulationConfig(goal_function_type='total potential energy', debug_level=0, use_f_du=True, gu={'cl': gu_constant_length, 'dofs': gu_dof_constraints}, acc=1e-7, MAX_ITER=1000) F_nodes = np.linspace(0, -10, n) FN = lambda F: lambda t: t * F F_ext_list = [(i + 1, 2, FN(F_n)) for i, F_n in enumerate(F_nodes)] fu_tot_poteng = FuPotEngTotal(kappa=np.array([5000.0]), fu_factor=1, F_ext_list=F_ext_list) # (2 * n, 2, -1)]) sim_config._fu = fu_tot_poteng sim_task = SimulationTask(previous_task=cp_factory_task, config=sim_config, n_steps=10) cp = sim_task.formed_object cp.x_0 = np.copy(sim_task.previous_task.formed_object.X) cp.u[:, :] = 0.0 fu_tot_poteng.forming_task = sim_task cp.u[1:n + 1, 2] = np.linspace(0, -0.001, n) cp.u[n + 1:(2 * n) + 1, 2] = np.linspace(0, -0.0005, n) print('kinematic simulation: u', sim_task.u_1) cp = sim_task.formed_object
gu_constant_length = GuConstantLength() dof_constraints = fix([0], [0, 1, 2]) + fix([1], [1, 2]) \ + fix([2], [2]) gu_dof_constraints = GuDofConstraints(dof_constraints=dof_constraints) sim_config = SimulationConfig(goal_function_type='potential_energy', debug_level=0, use_f_du=False, gu={ 'cl': gu_constant_length, 'dofs': gu_dof_constraints }, acc=1e-5, MAX_ITER=100) fu_tot_poteng = FuPotEngTotal(kappa=10, F_ext_list=[(3, 2, -1), (4, 2, -1)]) sim_config._fu = fu_tot_poteng sim_task = SimulationTask(previous_task=cp_factory_task, config=sim_config, n_steps=1) cp.u[4, 2] = 0.001 print('kinematic simulation: u', sim_task.u_1) cp = sim_task.formed_object iL_phi = cp.iL_psi2 - cp.iL_psi_0 print('phi', iL_phi) iL_length = np.linalg.norm(cp.iL_vectors, axis=1) iL_m = sim_config._fu.kappa * iL_phi * iL_length print('moments', iL_m)