return stack, False # remaining_plies = remaining_plies[good_permut] stack = np.hstack((stack_top, remaining_plies[good_permut], stack_bottom)) if stack.size != ss.size: raise Exception('This should not happen') return stack, True if __name__ == "__main__": print('\n*** Test for repair_diso_contig_from_outside_asym ***') ss_ini = np.array([-45, 0, 666, 666, 666, 90, 45, 90], int) ply_queue = [-45, 0, 45] constraints = Constraints( sym=False, dam_tol=False, diso=True, contig=True, delta_angle=45, n_contig=4, set_of_angles=[0, 45, -45, 90, 30, -30, 60, -60, 15, -15, 75, -75]) print_ss(ss_ini, 200) n_D1 = 6 print('ss_ini.size', ss_ini.size) print('ply_queue', ply_queue) ss, completed = repair_diso_contig_from_outside_asym( ss_ini, ply_queue, constraints, n_D1) print('Repair successful?', completed) print_ss(ss, 200)
if __name__ == "__main__": print('\n*** Test for the function repair_flexural_1 ***') constraints = Constraints( sym=True, ipo=True, dam_tol=False, diso=True, contig=True, delta_angle=45, n_contig=4) lampam_target = np.array([1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0]) ss = np.array([90, 90, 45, 0, 0, -45, 90, 45, 0, -45], int) if constraints.sym: ss = np.hstack((ss, np.flip(ss))) print('\nInitial stacking sequence') print_ss(ss) test, _ = internal_diso_contig(ss, constraints) if test.size < 1: raise Exception('Contiguity or disorientation rule not satisfied.') out_of_plane_coeffs = np.array([1/3, 1/3, 1/3, 0]) ss = repair_flexural_1( ss, out_of_plane_coeffs, lampam_target, constraints) print('\nFinal stacking sequence') print_ss(ss) test, _ = internal_diso_contig(ss, constraints) if test.size < 1: raise Exception('Contiguity or disorientation rule not satisfied.')
ipo=True, dam_tol=False, rule_10_percent=True, percent_0=10, percent_45=10, percent_90=10, percent_135=10, set_of_angles=[0, 45, 30, -30, -45, 60, -60, 90]) ss = np.array([ 0, 45, 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, 666, 45, 0 ], int) ply_queue = [90, 90, -45, 90, 90, 45, 0] mini_10 = calc_mini_10(constraints, ss.size) print('\nInitial stacking sequence') print_ss(ss, 40) excess_10 = calc_excess_10(ss, ply_queue, mini_10, sym=constraints.sym) print('\nexcess_10', excess_10) print('\n*** Test for the function calc_ind_plies ***') constraints = Constraints(sym=True, ipo=True, dam_tol=False, rule_10_percent=True, percent_0=10, percent_45=5, percent_90=10, percent_135=5, set_of_angles=[0, 45, 30, -30, -45, 60, -60, 90]) p_A = 50 ss = np.array([45, 90, 45, 0, -45, 0, 666, 666], int)
if __name__ == "__main__": print('\n*** Test for repair_diso_contig_from_outside_sym ***') constraints = Constraints( sym=True, bal=False, ipo=False, dam_tol=False, diso=True, contig=True, delta_angle=45, n_contig=5, set_of_angles=[0, 45, -45, 90, 30, -30, 60, -60, 75, -75, 15, -15]) ss = np.array([0, 45, -45, 666, 666, 666, 666], int) ss = np.hstack((ss, np.flip(ss))) ply_queue = [-45, 90, 90, 90] print_ss(ss, 40) n_D1 = 3 print('ss.size', ss.size) ss, completed = repair_diso_contig_from_outside_sym( ss, ply_queue, constraints, n_D1) print('Repair successful?', completed) print_ss(ss, 40) if not is_diso_ss(ss, constraints.delta_angle, dam_tol=False): raise Exception('Disorientation rule not satisfied') if not is_contig(ss, constraints.n_contig): raise Exception('Contiguity rule not satisfied')
n_D2=2, constraints=constraints) ss = np.array([ 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 45, 0, 0, 0, 0 ], int) if constraints.sym: ss = np.hstack((ss, 0, np.flip(ss))) ss = '90 90 90 90 0 0 0 90 0 0 90 0 0 45 0 90 0 0 45 0 0 90 0 0 0 0 0 45 0 0 0 0 0 0 0 0 0 0 45 0' ss = np.array(ss.split(' ')).astype(int) ss = np.hstack((ss, np.flip(ss))) print('\nInitial stacking sequence') print_ss(ss, 80) print(ss.size) ss_target = '90 90 90 90 90 90 45 45 45 45 45 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 45 45 45 45 45 45 90 90 90 90 90 90' ss_target = np.array(ss_target.split(' ')).astype(int) lampam_target = calc_lampam(ss_target) out_of_plane_coeffs = np.array([1, 1, 1, 1]) ss = repair_flexural_3(ss, out_of_plane_coeffs, lampam_target, constraints, parameters) print('\nFinal stacking sequence') print_ss(ss, 30)
percent_135=0, percent_45_135=10, set_of_angles=[0, 45, -45, 90]) # set_of_angles=[0, 45, 30, -30, 60, -60, -45, 90]) p_A = 70 in_plane_coeffs = np.array([0.5, 0.5, 0, 0]) ss_target = np.array([0], int) lampam_target = calc_lampam(ss_target) ss = np.array([45, 90, 45, 45, 0, -45, -45, 0, 666, 666], int) ss = np.hstack((ss, np.flip(ss))) ply_queue = [90, -45] print('\nInitial stacking sequence') print_ss(ss, 200) print('ply_queue', ply_queue) mini_10 = calc_mini_10(constraints, ss.size) print('mini_10', mini_10) ss_list, ply_queue_list, lampamA_list, objA_list = repair_membrane_1_ipo( ss, ply_queue, mini_10, in_plane_coeffs, p_A, lampam_target, constraints) # print('\nSolution stacking sequence') # print_ss(ss_list[0], 200) # print('ply_queue', ply_queue_list[0]) # lampamA = lampamA_list[0] # lampamA_check = calc_lampamA_ply_queue(ss, ss.size, ply_queue, constraints) # if not (abs(lampamA_check - lampamA) < 1e-10).all():
list_blocks.sort(key=operator.attrgetter('distance_middle'), reverse=True) return list_blocks if __name__ == "__main__": print('\n*** Test for the function find_list_blocks ***') constraints = Constraints( sym=False, contig=True, diso=True, n_contig=4, delta_angle=45, set_of_angles=[0, 45, -45, 90, 30, -30, 60, -60, 15, -15, 75, -75]) print('Initial stacking sequence') ss = np.array([-75, -45, -60, -30, 0], int) if constraints.sym: ss = np.hstack((ss, 90, np.flip(ss))) print_ss(ss, 40) n_plies = ss.size list_blocks = find_list_blocks(ss, n_plies, constraints) for elem in list_blocks: print(elem) print('\n*** Test for the function calc_delta_lampamD_swap ***\n') constraints = Constraints(sym=False) print('Result:', calc_delta_lampamD_swap( angle_first=45, angle_second=-45, pos_first=np.array([26], int), pos_second=np.array([22], int), n_plies=30, constraints=constraints))
constraints=constraints) ss = np.array([-60, -45, 90, 75, -75, -45, 0], int) if constraints.sym: ss = np.hstack((ss, np.flip(ss))) if not is_diso_ss(ss, delta_angle=constraints.delta_angle, dam_tol=constraints.dam_tol, dam_tol_rule=constraints.dam_tol_rule): raise Exception('Disorientation rule not satisfied initially') if not is_contig(ss, constraints.n_contig): raise Exception('Contiguity rule not satisfied initially') print('\nInitial stacking sequence') print_ss(ss, 1000) ss_target = 45 * np.ones((1, ), dtype=int) lampam_target = calc_lampam(ss_target) lampam_target = np.array([ -0.25662112, -0.01727515, -0.73962959, 0.08359081, 0.43671968, -0.7901057, 0.98404481, 0.65070345, 0.97056517, 0.7023994, 0.32539113, -0.35851357 ]) out_of_plane_coeffs = np.array([1, 1, 1, 1]) ss = repair_flexural(ss, constraints, out_of_plane_coeffs, parameters=parameters, lampam_target=lampam_target) print('\nFinal stacking sequence') print_ss(ss, 1000)
def repair_diso_contig_from_inside_sym( ss, ply_queue, constraints, n_D1): """ attempts at repairing the stacking sequence to satisfy the disorientation and contiguity rule for symmetric laminates with swaps from the inside out of the laminates INPUTS - ss: partially retrieved stacking sequence - ply_queue: queue of plies for innermost plies - constraints: design and manufacturing constraints - n_D1: number of plies in the last permutation """ stack_dam_tol, stack, ind_1, ind_2 = \ initialise_repair_diso_contig( ss, constraints, from_inside=True, n_D1=n_D1) # print('ind_1', ind_1) # print('ind_2', ind_2) for ind_ply_1 in ind_1: # print('ind_ply_1', ind_ply_1) angle_found = False for ind_ply_2 in ind_2: # print(' ind_ply_2', ind_ply_2) if ss[ind_ply_2] != 666: stack_test = np.hstack((ss[ind_ply_2], stack, ss[ind_ply_2])) # print('stack_test', stack_test) if constraints.diso and not is_diso( stack_test[0], stack_test[1], constraints.delta_angle): continue if constraints.contig and not is_contig( stack_test[:2*constraints.n_contig], constraints.n_contig): continue stack = stack_test ind_2 = np.delete(ind_2, np.argwhere(ind_2 == ind_ply_2)) angle_found = True # print_ss(stack, 13) break else: # let's pick a ply from the queue angles_to_test = order_plies_to_test( [stack[-1]], ply_queue, constraints) for angle in angles_to_test: stack_test = np.hstack((angle, stack, angle)) # print('stack_test', stack_test) if constraints.diso and not is_diso( stack_test[0], stack_test[1], constraints.delta_angle): continue if constraints.contig and not is_contig( stack_test[:2*constraints.n_contig], constraints.n_contig): continue stack = stack_test ind_2 = np.delete( ind_2, np.argwhere(ind_2 == ind_ply_2)[0]) ply_queue.remove(angle) angle_found = True print_ss(stack, 13) break if angle_found: break if not angle_found: # return semi-repaired stacking sequence for ind_ply_2 in ind_2: if ss[ind_ply_2] != 666: angle = ss[ind_ply_2] else: angle = ply_queue.pop(0) stack = np.hstack((angle, stack, angle)) stack = np.hstack((stack_dam_tol, stack, np.flip(stack_dam_tol))) return stack, False if stack.size + 2*stack_dam_tol.size \ < ss.size - 2*n_D1: # return semi-repaired stacking sequence raise Exception('This should not happen anymore') # print_ss(stack) # plies at the centre all designed simultaneously good_permut = [] real_n_D1 = ind_2.size remaining_plies = np.empty((real_n_D1,), int) for counter, ind in enumerate(ind_2): if ss[ind] != 666: remaining_plies[counter] = ss[ind] else: remaining_plies[counter] = ply_queue.pop(0) # print('remaining_plies', remaining_plies) for elem in itertools.permutations( range(real_n_D1)): ss_group = remaining_plies[np.array(elem, int)] if constraints.dam_tol: stack_test = np.hstack((stack_dam_tol[-1], ss_group)) else: stack_test = ss_group stack_test = np.hstack((stack_test, stack, np.flip(stack_test))) stack_test = stack_test[:2 + 2 * constraints.n_contig \ + real_n_D1] # print('stack_test', stack_test) if constraints.diso and not is_diso_ss( stack_test, constraints.delta_angle, dam_tol=False): continue if constraints.contig and not is_contig( stack_test, constraints.n_contig_c): continue good_permut.append(np.array(elem, int)) # print('good_permut', good_permut) good_permut = smallest_row(good_permut) if good_permut is None: # return semi-repaired stacking sequence stack = np.hstack((np.flip(remaining_plies), stack, remaining_plies)) stack = np.hstack((stack_dam_tol , stack, np.flip(stack_dam_tol))) return stack, False stack = np.hstack(( stack_dam_tol, remaining_plies[good_permut], stack, np.flip(remaining_plies[good_permut]), np.flip(stack_dam_tol))) if stack.size != ss.size: raise Exception('This should not happen') return stack, True
# delta_angle=45, # n_contig=3, # set_of_angles=[0, 45, -45, 30, -30, 60, -60, 90]) # adjacent_plies = [0] # queue = [-30, 0, 60, -45, 60, -30, 60] # print(order_plies_to_test(adjacent_plies, queue, constraints)) # # print('\n*** Test for the function smallest_row ***') # permut = [[0, 2, 1], [2, 1, 0], [1, 2, 0], [0, 1, 2]] # print('best_permut', smallest_row(permut)) # print('expectecd best_permut', [0, 1, 2]) print('\n*** Test for the function initialise_repair_diso_contig ***') ss = np.arange(10) ss = np.hstack((ss, np.flip(ss))) print_ss(ss) constraints = Constraints(sym=False, dam_tol=True, dam_tol_rule=3, diso=True, contig=True, delta_angle=45, n_contig=3) from_inside = True n_D1 = 3 if constraints.sym and not from_inside: stack, ind_1, ind_2 = initialise_repair_diso_contig( ss, constraints, from_inside, n_D1) print('stack', end='') print_ss(stack, 40)