def __fix_vent(self, R_hs): with open(self.__hs_folder + "\\" + 'ventilacao.txt', 'r') as vent_file: vent_x_axis = vent_file.readline() vent_y_axis = vent_file.readline() # Filtrar as strings em branco e passar para float vent_x_axis = list(filter(lambda item: type(item) is not str, list(map(lambda x: funcs.atof(x.rstrip()), vent_x_axis.split(" "))))) vent_y_axis = list(filter(lambda item: type(item) is not str, list(map(lambda x: funcs.atof(x.rstrip()), vent_y_axis.split(" "))))) return list(map(lambda y: y * interp1d(vent_x_axis, vent_y_axis)(self.__vent)[()], R_hs))
def __fix_temp(self, delta_T, R_hs): with open(self.__hs_folder + "\\" + 'DeltaTemp.txt', 'r') as delta_temp_file: temp_x_axis = delta_temp_file.readline() temp_y_axis = delta_temp_file.readline() # Filtrar as strings em branco temp_x_axis = list(filter(lambda item: type(item) is not str, list(map(lambda x: funcs.atof(x.rstrip()), temp_x_axis.split(" "))))) temp_y_axis = list(filter(lambda item: type(item) is not str, list(map(lambda x: funcs.atof(x.rstrip()), temp_y_axis.split(" "))))) return list(map(lambda x, y: x / y, R_hs, list(map(lambda x: 1 + interp1d(temp_y_axis, temp_x_axis)(x), delta_T))))
def __load_heat_sink(self): with open(self.__hs_folder + "\\" + 'dissipadores.txt', 'r') as hs_file: self.__dimension = hs_file.readline().split(":")[1].replace("\n", "") keys = tuple(map(lambda x: x.replace("\n", ""), hs_file.readline().split(" "))) hs_aux = tuple([line.split(" ") for line_num, line in enumerate(hs_file)]) hs_dict_aux = {keys[j]: tuple([hs_aux[i][j] for i in range(len(hs_aux))]) for j in range(len(keys))} # Info of the heatsink's database self.__info_hs_db = dict( zip(hs_dict_aux.keys(), tuple(map(lambda x: tuple([funcs.atof(i) for i in x]), hs_dict_aux.values())))) self.__info_hs_db['DimensionalFactor'] = { 'mm': 100, 'cm': 10, 'dm': 1, 'inches': 3.937 }[self.__dimension.lower().lstrip()] self.__info_hs_db['Width'] = tuple( map(lambda x: round(x / self.__info_hs_db['DimensionalFactor'], 4), self.__info_hs_db['Width'])) self.__info_hs_db['Height'] = tuple( map(lambda x: round(x / self.__info_hs_db['DimensionalFactor'], 4), self.__info_hs_db['Height'])) self.__info_hs_db['Peso'] = tuple( map(lambda x: round(x / 10, 4), self.__info_hs_db['Peso'])) self.__info_hs_db = pd.DataFrame(self.__info_hs_db)
def __load_Rth(self): with open(self.__thermal_folder + "\\dados_termicos.txt", 'r') as thermal_file: read_Rth_hs = [line.split(";")[:-2] for line_num, line in enumerate(thermal_file)] # Split the loaded variable into a dict with the name of the Rth and its value read_Rth_hs_dict_aux = [dict(zip(i[0].split(","), i[1:])) for i in read_Rth_hs] # Transform the list of dicts into a single dict info_Rth_hs_dict_aux = {} for d in read_Rth_hs_dict_aux: info_Rth_hs_dict_aux.update(d) # Transform all string numbers to float self.__info_Rth_hs_dict = dict(zip(info_Rth_hs_dict_aux.keys(), tuple(map(lambda x: funcs.atof(x), info_Rth_hs_dict_aux.values())))) for key, value in self.__info_Rth_hs_dict.items(): if value == 0: self.__info_Rth_hs_dict[key] = self.__Rth_cs self.__info_Rth_hs_dict = pd.DataFrame(self.__info_Rth_hs_dict, index=[os.path.basename(os.path.normpath(self.__thermal_folder))])
def __read_and_save_inductors(self): number_of_files = len([item for item in sorted(os.listdir(self.__inductor_folder), key=funcs.natural_keys) if os.path.isfile(os.path.join(self.__inductor_folder, item)) and item.startswith( "Inverter")]) d = [] for file in [item for item in sorted(os.listdir(self.__inductor_folder), key=funcs.natural_keys) if os.path.isfile(os.path.join(self.__inductor_folder, item)) and item.startswith("Inverter")]: with open(self.__inductor_folder + "\\" + file, 'r') as inductor_file: # aux = [line.split(";")[1:-2] for line_num, line in enumerate(transistor_file) if re.match(".\)", line)] aux = [line.split("=") for line_num, line in enumerate(inductor_file)] if len(aux) == 25: d.append( { 'Fsw': copy.deepcopy(funcs.atof(aux[0][1].rstrip().split(' ')[1])), 'L_ind': copy.deepcopy(funcs.atof(aux[1][1].rstrip().split(' ')[1])), 'deltaI': copy.deepcopy(funcs.atof(aux[2][1].rstrip().split(' ')[1])), 'Flag': copy.deepcopy(funcs.atof(aux[3][1].rstrip().split(' ')[1])), 'L_init': copy.deepcopy(funcs.atof(aux[4][1].rstrip().split(' ')[1])), 'L_sat': copy.deepcopy(funcs.atof(aux[5][1].rstrip().split(' ')[1])), 'Error': copy.deepcopy(funcs.atof(aux[6][1].rstrip().split(' ')[1])), 'Material': copy.deepcopy(aux[7][1].lstrip().rstrip()), 'Part_Number': copy.deepcopy(aux[8][1].lstrip().rstrip()), 'Number_coils': copy.deepcopy(funcs.atof(aux[9][1].rstrip().split(' ')[1])), 'I_dens': copy.deepcopy(funcs.atof(aux[10][1].rstrip().split(' ')[1])), 'Fill_Factor': copy.deepcopy(funcs.atof(aux[11][1].rstrip().split(' ')[1])), 'Number_layers': copy.deepcopy(funcs.atof(aux[12][1].rstrip().split(' ')[1])), 'Number_paralel': copy.deepcopy(funcs.atof(aux[13][1].rstrip().split(' ')[1])), 'Loss_total': copy.deepcopy(funcs.atof(aux[15][1].rstrip().split(' ')[1])), 'Loss_core': copy.deepcopy(funcs.atof(aux[16][1].rstrip().split(' ')[1])), 'Loss_copper': copy.deepcopy(funcs.atof(aux[17][1].rstrip().split(' ')[1])), 'Loss_copper_skin': copy.deepcopy(funcs.atof(aux[18][1].rstrip().split(' ')[1])), 'Delta_Temp': copy.deepcopy(funcs.atof(aux[19][1].rstrip().split(' ')[1])), 'R_60hz': copy.deepcopy(funcs.atof(aux[20][1].rstrip().split(' ')[1])), 'R_fsw': copy.deepcopy(funcs.atof(aux[21][1].rstrip().split(' ')[1])), 'Vol_total': copy.deepcopy(funcs.atof(aux[22][1].rstrip().split(' ')[1])), 'Weight_core': copy.deepcopy(funcs.atof(aux[23][1].rstrip().split(' ')[1])), 'Weight_copper': copy.deepcopy(funcs.atof(aux[24][1].rstrip().split(' ')[1])) } ) # Preciso salvar todos os arquivos que nao existem? else: d.append( { 'Fsw': copy.deepcopy(funcs.atof(aux[0][1].rstrip().split(' ')[1])), 'L_ind': copy.deepcopy(funcs.atof(aux[1][1].rstrip().split(' ')[1])), 'deltaI': copy.deepcopy(funcs.atof(aux[2][1].rstrip().split(' ')[1])), 'Material': copy.deepcopy(aux[3][1].lstrip().rstrip()), 'Flag': copy.deepcopy(funcs.atof(aux[4][1].rstrip().split(' ')[1])), 'L_init': None, 'L_sat': None, 'Error': None, 'Part_Number': None, 'Number_coils': None, 'I_dens': None, 'Fill_Factor': None, 'Number_layers': None, 'Number_paralel': None, 'Diam_wires': None, 'Loss_total': None, 'Loss_core': None, 'Loss_copper': None, 'Loss_copper_skin': None, 'Delta_Temp': None, 'R_60hz': None, 'R_fsw': None, 'Vol_total': None, 'Weight_core': None, 'Weight_copper': None } ) self.__result_inductor = pd.DataFrame(d)
def __fix_len(self): with open(self.__hs_folder + "\\" + 'CorrigirComprimento.txt', 'r') as len_file: len_x_axis = len_file.readline() len_y_axis = len_file.readline() len_x_axis = list(filter(lambda item: type(item) is not str, list(map(lambda x: funcs.atof(x.rstrip()), len_x_axis.split(" "))))) len_y_axis = list(filter(lambda item: type(item) is not str, list(map(lambda x: funcs.atof(x.rstrip()), len_y_axis.split(" "))))) len_x_axis = list(map(lambda x: x / self.info_hs_db['DimensionalFactor'].iloc[0], len_x_axis)) len_y_axis_Rth = {'Rth_len': tuple([[Rth * factor for factor in len_y_axis] for Rth in self.info_hs_db['Rth']]), 'Part_number': tuple([[Code] for Code in self.info_hs_db['Code']])} min_len = (self.height + self.leg) max_len = max(len_x_axis) # self.__info_hs['HS_len'] = [None] * len(self.__info_hs['R_hs']) self.__info_hs['HS_len'] = pd.Series([None for _ in range(len(self.__info_hs))], index=self.__info_hs.index) self.__result_hs = defaultdict(list) d = [] aux = copy.deepcopy(self.__info_hs) for n in range(len(len_y_axis_Rth['Part_number'])): max_y = max(len_y_axis_Rth['Rth_len'][n]) min_y = min(len_y_axis_Rth['Rth_len'][n]) for i in range(len(self.__info_hs)): if aux['R_hs'][i] > max_y: aux.at[i, 'R_hs'] = max_y # aux['R_hs'][i] = max_y if aux['R_hs'][i] < min_y: # self.__info_hs['R_hs'][i] = min_y # aux['HS_len'][i] = aux['HS_len'][i].replace(aux['HS_len'][i], None) aux.at[i, 'HS_len'] = None # aux['HS_len'][i] = None # esta assim no programa original else: if self.__hs_config == 1: aux.at[i, 'HS_len'] = \ interp1d(len_y_axis_Rth['Rth_len'][n], len_x_axis)(aux.at[i, 'R_hs'])[()] flag = 0 if aux['HS_len'][i] is not None: # for tam in [x * 0.0001 for x in range(self.__info_hs['HS_len'][i], max_len)]: for tam in funcs.drange(aux.at[i, 'HS_len'], max_len, 0.0001): if tam >= min_len: flag = 1 aux.at[i, 'HS_len'] = tam break if not flag: aux.at[i, 'HS_len'] = None d.append( { 'deltaI': copy.deepcopy(aux['deltaI'][i]), 'Fsw': copy.deepcopy(aux['Fsw'][i]), 'Part_Number': len_y_axis_Rth['Part_number'][n][0], 'Width': self.__info_hs_db['Width'][n], 'Height': self.__info_hs_db['Height'][n], 'Length': copy.deepcopy(aux['HS_len'][i]), 'Volume': funcs.multiply(self.__info_hs_db['Width'][n], self.__info_hs_db['Height'][n], copy.deepcopy(aux['HS_len'][i])), 'Peso': funcs.multiply(copy.deepcopy(aux['HS_len'][i]), self.__info_hs_db['Peso'][n]) } ) self.__result_hs = pd.DataFrame(d)