Esempio n. 1
0
        if mass[i - 1] < mass_goal_ratio * mass_full:
            mass_goal_i = mass[i - 1] + (mass_addition_ratio - mass_removal_ratio) * mass_full
        elif mass[i - 1] >= mass_goal_ratio * mass_full:
            if not i_violated:
                i_violated = i  # to start decaying
                check_tolerance = True
            mass_goal_i = mass_goal_ratio * mass_full

    # switch element states
    if ratio_type == "absolute":
        mass_referential = mass_full
    elif ratio_type == "relative":
        mass_referential = mass[i - 1]
    [elm_states, mass] = beso_lib.switching(elm_states, domains_from_config, domain_optimized, domains, FI_step_max,
                                            domain_density, domain_thickness, domain_shells, area_elm, volume_elm,
                                            sensitivity_number, mass, mass_referential, mass_addition_ratio,
                                            mass_removal_ratio, compensate_state_filter, mass_excess, decay_coefficient,
                                            FI_violated, i_violated, i, mass_goal_i, domain_same_state)

    # filtering state
    mass_not_filtered = mass[i]  # use variable to store the "right" mass
    for ft in filter_list:
        if ft[0] and ft[1]:
            if ft[0] == "casting":
                continue  # to evaluate other filters
            if len(ft) == 2:
                domains_to_filter = list(opt_domains)
            else:
                domains_to_filter = []
                for dn in ft[2:]:
                    domains_to_filter += domains[dn]
Esempio n. 2
0
        if mass[i - 1] < mass_goal_ratio * mass_full:
            mass_goal_i = mass[i - 1] + (mass_addition_ratio - mass_removal_ratio) * mass_full
        elif mass[i - 1] >= mass_goal_ratio * mass_full:
            if not i_violated:
                i_violated = i  # to start decaying
                check_tolerance = True
            mass_goal_i = mass_goal_ratio * mass_full

    # switch element states
    if ratio_type == "absolute":
        mass_referential = mass_full
    elif ratio_type == "relative":
        mass_referential = mass[i - 1]
    [elm_states, mass] = beso_lib.switching(elm_states, domains_from_config, domain_optimized, domains, FI_step_max,
                                            domain_density, domain_thickness, domain_shells, area_elm, volume_elm,
                                            sensitivity_number, mass, mass_referential, mass_addition_ratio,
                                            mass_removal_ratio, compensate_state_filter, mass_excess, decay_coefficient,
                                            FI_violated, i_violated, i, mass_goal_i, domain_same_state)

    # filtering state
    mass_not_filtered = mass[i]  # use variable to store the "right" mass
    for ft in filter_list:
        if ft[0] and ft[1]:
            if ft[0] == "casting":
                continue  # to evaluate other filters
            if len(ft) == 2:
                domains_to_filter = list(opt_domains)
            else:
                domains_to_filter = []
                for dn in ft[2:]:
                    domains_to_filter += domains[dn]
Esempio n. 3
0
    def Swith_Element_State(self):
        '''
        # switch element states
        '''
        global i, mass_referential, elm_states, mass, elm_states_before_last, elm_states_last, continue_iterations

        if ratio_type == "absolute":
            mass_referential = mass_full
        elif ratio_type == "relative":
            mass_referential = mass[i - 1]
        [elm_states, mass] = beso_lib.switching(
            elm_states, domains_from_config, domain_optimized, domains,
            FI_step_max, domain_density, domain_thickness, domain_shells,
            area_elm, volume_elm, sensitivity_number, mass, mass_referential,
            mass_addition_ratio, mass_removal_ratio, decay_coefficient,
            FI_violated, i_violated, i, mass_goal_i)

        # check for oscillation state
        if elm_states_before_last == elm_states:  # oscillating state
            msg = "OSCILLATION: model turns back to " + str(
                i - 2) + "th iteration\n"
            beso_lib.write_to_log(file_name, msg)
            print(msg)
            continue_iterations = False
        elm_states_before_last = elm_states_last.copy()
        elm_states_last = elm_states.copy()

        # filtering state
        for ft in filter_list:
            if ft[0] and ft[1]:
                if len(ft) == 2:
                    domains_to_filter = list(opt_domains)
                else:
                    domains_to_filter = []
                    for dn in ft[2:]:
                        domains_to_filter += domains[dn]

                if ft[0].split()[0] in [
                        "erode", "dilate", "open", "close", "open-close",
                        "close-open", "combine"
                ]:
                    if ft[0].split()[1] == "state":
                        # the same filter as for sensitivity numbers
                        elm_states_filtered = beso_filters.run_morphology(
                            elm_states, near_elm, opt_domains,
                            ft[0].split()[0])
                        # compute mass difference
                        for dn in domains_from_config:
                            if domain_optimized[dn] is True:
                                for en in domain_shells[dn]:
                                    if elm_states[en] != elm_states_filtered[
                                            en]:
                                        mass[i] += area_elm[en] * (
                                            domain_density[dn][
                                                elm_states_filtered[en]] *
                                            domain_thickness[dn][
                                                elm_states_filtered[en]] -
                                            domain_density[dn][elm_states[en]]
                                            * domain_thickness[dn][
                                                elm_states[en]])
                                        elm_states[en] = elm_states_filtered[
                                            en]
                                for en in domain_volumes[dn]:
                                    if elm_states[en] != elm_states_filtered[
                                            en]:
                                        mass[i] += volume_elm[en] * (
                                            domain_density[dn][
                                                elm_states_filtered[en]] -
                                            domain_density[dn][elm_states[en]])
                                        elm_states[en] = elm_states_filtered[
                                            en]
        print("mass = {}".format(mass[i]))
        print("Swith_Element_State")