示例#1
0
def check_lay_up_rules(ss,
                       constraints,
                       no_ipo_check=False,
                       no_bal_check=False,
                       equality_45_135=False,
                       equality_0_90=False,
                       n_plies=None):
    """
    checks the manufacturability of a stacking sequence
    """
    if n_plies is not None and ss.size != n_plies:
        raise Exception("Wrong number of plies")

    if constraints.dam_tol:
        if not is_dam_tol(ss, constraints):
            print_ss(ss)
            raise Exception("Damage tolerance constraint not satisfied")

    if not no_bal_check and constraints.bal:
        if not is_balanced(ss, constraints):
            raise Exception("Balance constraint not satisfied")

    if not no_ipo_check and constraints.ipo:
        lampamA = calc_lampamA(ss, constraints)
        if (abs(lampamA[2:4]) > 1e-10).any():
            print_ss(ss)
            print('lampamA', lampamA)
            #            print('ipo')
            raise Exception("In plane orthotropy constraint not satisfied")

    if constraints.diso:
        if hasattr(constraints, 'dam_tol_rule'):
            if not is_diso_ss(ss, constraints.delta_angle, constraints.dam_tol,
                              constraints.dam_tol_rule):
                raise Exception("Disorientation constraint not satisfied")
        else:
            if not is_diso_ss(ss, constraints.delta_angle, constraints.dam_tol,
                              constraints.n_plies_dam_tol):
                raise Exception("Disorientation constraint not satisfied")

    if constraints.contig:
        if not is_contig(ss, constraints.n_contig):
            raise Exception("Contiguity constraint not satisfied")

    if constraints.rule_10_percent:
        if not is_ten_percent_rule(constraints,
                                   stack=ss,
                                   equality_45_135=equality_45_135,
                                   equality_0_90=equality_0_90):
            raise Exception("10% rule not satisfied")
    return 0
示例#2
0
                            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)
        return stack, False

    ss_group = remaining_plies[good_permut]
    stack = np.hstack((stack_top, ss_group[:real_n_D1 // 2], stack,
                       ss_group[real_n_D1 // 2:], 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_inside_asym ***')
    ss_ini = np.array([
        90, -45, -45, 0, 0, -45, -45, 0, 45, 90, 90, 90, 90, -45, 0, 45, 0,
        -45, 90, -45, 90, 45, 90, 90, 90, 90, -45, -45, -45, 0, 0, -45, -45,
        90, -45, -45, 0, -45, -45, 0, 0, 0, 45, 45, 0, 45, 45, 0, 45, 0
    ], int)
    constraints = Constraints(sym=False,
                              dam_tol=True,
                              diso=True,
                              contig=True,
                              delta_angle=45,
                              n_contig=4,
                              set_of_angles=[0, 45, -45, 90])
    print_ss(ss_ini, 200)
    n_D1 = 4
    ply_queue = []
    print('ss_ini.size', ss_ini.size)
    ss, completed = repair_diso_contig_from_inside_asym(
        ss_ini, ply_queue, constraints, n_D1)
    print('Repair successful?', completed)
    print_ss(ss - ss_ini, 200)
示例#4
0
from src.LAYLA_V02.targets import Targets
from src.LAYLA_V02.parameters import Parameters
from src.LAYLA_V02.constraints import Constraints
from src.LAYLA_V02.optimiser import LAYLA_optimiser
from src.CLA.lampam_functions import calc_lampam_2
from src.LAYLA_V02.materials import Material
from src.divers.pretty_print import print_lampam, print_ss, print_list_ss

#==============================================================================
# Targets
#==============================================================================
# Total number of plies
n_plies = 61
# Stacking sequence target
ss_target = np.array([45, 90, -45, 0, 0], dtype='int16')
print_ss(ss_target, 200)

# Calculation of target lamination parameters
lampam = calc_lampam_2(ss_target)
print_lampam(lampam)

targets = Targets(n_plies=n_plies, lampam=lampam, stack=ss_target)

#==============================================================================
# Type of optimisations
#==============================================================================
optimisation_type = 'A'  # only in-plane lamination parameters optimised
optimisation_type = 'D'  # only out-of-plane lamination parameters optimised
optimisation_type = 'AD'  # in- and out-of-plane lamination parameters optimised

#==============================================================================
示例#5
0
        ss[ss.size // 2 + ss.size % 2:] = np.flip(ss[:ss.size // 2])

    if count_obj:
        return ss, n_obj_func_D_calls
    return ss

if __name__ == "__main__":

    print('\n*** Test for the function repair_flexural_2 ***')
    constraints = Constraints(
        sym=True,
        dam_tol=False,
        diso=True,
        contig=True,
        delta_angle=45,
        n_contig=4,)
    parameters = Parameters(
        repair_flexural_switch=True, n_D2=3, constraints=constraints)
    ss = np.array([45, 0, 45, 90, -45, -45, 0], int)
    if constraints.sym:
        ss = np.hstack((ss, np.flip(ss)))
    print('\nInitial stacking sequence')
    print_ss(ss, 80)
    print(ss.size)
    ss_target = 0*np.ones((1,), dtype=int)
    lampam_target = calc_lampam(ss_target)
    out_of_plane_coeffs = np.array([1/3, 1/3, 1/3, 0])
    ss = repair_flexural_2(
        ss, out_of_plane_coeffs, lampam_target, constraints, parameters)
    print_ss(ss, 30)
示例#6
0
if __name__ == "__main__":  
    'Test'
    
    import sys
    sys.path.append(r'C:\LAYLA')
    from src.LAYLA_V02.constraints import Constraints
    from src.divers.pretty_print import print_ss, print_list_ss
    
    constraints = Constraints()
    constraints.diso = True
    constraints.delta_angle = 45
    constraints.contig = True
    constraints.n_contig = 2

    print('*** Test for the function external_diso_contig ***\n')
    print('Input stacking sequences:\n')
    ss = np.array([[-45, -45, 0, 45, 90], 
                   [0, 45, 45, 45, 45],
                   [0, 0, 0, 45, 45]])
    print_list_ss(ss)
    print('Stacking sequence of adajacent sublaminate:\n')
    ss_before = np.array([-45])
    print_ss(ss_before)
    n_plies_group = 5 
    middle_ply = 0
    test, _ = external_diso_contig(ss, n_plies_group, constraints, ss_before, ss)
    if test.shape[0]:
        print('Stacking sequences satisfying the rule:\n')
        print_list_ss(test)
    else:
        print('No stacking sequence satisfy the rule\n')

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))
示例#8
0
                [1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0])
        else:
            lampam_to_be_optimised = np.array(
                [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1])

    # Lamination parameters sensitivities from the first-lebel optimiser
    first_level_sensitivities = np.ones((12, ), float)

    parameters = Parameters(
        constraints=constraints,
        p_A=p_A,
        n_D1=n_D1,
        n_D2=n_D2,
        n_D3=n_D3,
        first_level_sensitivities=first_level_sensitivities,
        lampam_to_be_optimised=lampam_to_be_optimised,
        repair_membrane_switch=repair_membrane_switch,
        repair_flexural_switch=repair_flexural_switch)

    targets = Targets(n_plies=ss.size, lampam=lampam_target)

    ss, completed, n_obj_func_D_calls = repair_ss(ss,
                                                  constraints,
                                                  parameters,
                                                  targets,
                                                  count_obj=True)
    print('Repair successful?', completed)
    print_ss(ss, 20)
    print('n_obj_func_D_calls', n_obj_func_D_calls)
    check_lay_up_rules(ss, constraints)
示例#9
0
        90,
        90,
        90,
        45,
        0,
        0,
        0,
        0,
        0,
        -45,
        90,
        90,
        90,
        45,
        0,
        -45,
        0,
        0,
        0,
        0,
        -45,
        90,
        90,
        90,
    ])
    print_ss(ss, 8)
    test = internal_diso_contig_mod(ss, constraints, table_int)

    print('Modified internal disorientation and contiguity rule verified?')
    print(test)
示例#10
0
                              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)
示例#11
0
    #    print('\n\n*** Test for the function calc_current_10_2 ***')
    #    ss = np.array([
    #        45, 45, 90, 45, 45, 90, -45, 0, 0, -45, 90,
    #        -45, 0, 0, -45, 90, 45, 45, 90, 45, 45], int)
    #    print('\nInitial stacking sequence')
    #    print_ss(ss, 40)
    #    current_10 = calc_current_10_2(ss, sym=constraints.sym)
    #    print('\ncurrent_10', current_10)
    #
    print('\n*** Test for the function repair_10_bal***')
    ss_ini = np.array([60, 45, 60, 0], int)
    ss_ini = np.array([60, 45, 60, 15, -15, 30, 45], int)
    ss_ini = np.array([-45, 45, -45, 0, 0, 0, -45, 90, 45, 45], int)

    if constraints.sym:
        #        ss_ini = np.hstack((ss_ini, 0, np.flip(ss_ini)))
        ss_ini = np.hstack((ss_ini, np.flip(ss_ini)))

#    ss_ini = "60 15 60 -15 90 60"
#    ss_ini = np.array(ss_ini.split()).astype(int)

    print('\nInitial stacking sequence')
    print_ss(ss_ini, 2000)
    print('ss_ini.zize', ss_ini.size)
    mini_10 = calc_mini_10(constraints, ss_ini.size)
    print('mini_10', mini_10)
    ss, ply_queue = repair_10_bal(ss_ini, mini_10, constraints)
    print('\nSolution stacking sequence')
    print_ss(ss, 2000)
    print('ply_queue', ply_queue)
示例#12
0
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
示例#13
0
        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

if __name__ == "__main__":
    print('\n*** Test for repair_diso_contig_from_inside_sym ***')
    ss = np.array([0, 90, 45, 45, 666, 666, 666], int)
    ss = np.hstack((ss, 0, np.flip(ss)))
    constraints = Constraints(sym=True,
                              dam_tol=True,
                              diso=True,
                              contig=True,
                              delta_angle=45,
                              n_contig=3,
                              set_of_angles=[0, 45, -45, 90])
    print_ss(ss, 40)
    n_D1 = 4
    ply_queue = [-45, -45, 0]
    print('ss.size', ss.size)
    ss, completed = repair_diso_contig_from_inside_sym(ss, ply_queue,
                                                       constraints, n_D1)
    print('Repair successful?', completed)
    print_ss(ss, 40)
示例#14
0
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.')