Open JungHulk opened 1 year ago
Convective heat transfer coefficient
Simple method to estimate air flow pass
https://www.electronics-cooling.com/1997/05/a-simple-method-to-estimate-heat-sink-air-flow-bypass/
"air prop table"
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 19 15:39:48 2023
@author: seungj.jung
"""
#### Excel Data base 만들기
import os
import pandas as pd
# from pandas import Series
import pickle
# excel = Dispatch('excel.Application') # win32com.client로 excel call
openfiledir = os.getcwd() + '\\' # 현재 폴더 위치
filename = 'Air_properties.xlsx' # 현재 폴더 위치의 해당 파일명의 .xls 파일 open
df = pd.read_excel(openfiledir + filename)
IndName = df['Temperature']
IndName[0] = "(Units)"
df.index = IndName # Index 지정
df.drop([1], inplace = True)
df.drop(['Unnamed: 0','Temperature'], axis = 1, inplace = True)
df.drop(df.index[1], inplace = True)
ColName = df.columns # Column 지정
with open('Air_prop.p','wb') as file:
pickle.dump(df, file)
"Unitconv_pickle_maker"
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 26 08:55:44 2023
@author: seungj.jung
"""
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 19 15:39:48 2023
@author: seungj.jung
"""
#### Excel Data base 만들기
import os
import pandas as pd
import pickle
import numpy as np
# excel = Dispatch('excel.Application') # win32com.client로 excel call
openfiledir = os.getcwd() + '\\' # 현재 폴더 위치
filename = 'Unitconv.xlsx' # 현재 폴더 위치의 해당 파일명의 .xls 파일 open
unit = np.array(["length", "area", "volume", "pressure"])
for i, n in enumerate(unit):
globals()['df_{}'.format(n)] = pd.read_excel(openfiledir + filename, sheet_name = n) # 각 sheet name 으로 dataframe 만들기
globals()['Indname_{}'.format(n)] = globals()['df_{}'.format(n)][format(n)] # Dataframe 별 index 지정
globals()['df_{}'.format(n)].index = globals()['Indname_{}'.format(n)] # Dataframe 에 index 설정
globals()['df_{}'.format(n)].drop(format(n), axis = 1, inplace = True) # Dataframe 첫 열 삭제
# for 문으로 저장하는건??
# df_length = pd.read_excel(openfiledir + filename, sheet_name = "length")
# Indname_length = df_length["length"]
# df_length.index = Indname_length
# df_length.drop('length', axis =1, inplace = True)
with open('Unitconv_length.p','wb') as file:
pickle.dump(df_length, file)
with open('Unitconv_area.p','wb') as file:
pickle.dump(df_area, file)
with open('Unitconv_volume.p','wb') as file:
pickle.dump(df_volume, file)
with open('Unitconv_pressure.p','wb') as file:
pickle.dump(df_pressure, file)
Unitconv.py
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 31 18:05:11 2023
@author: seungj.jung
"""
import os
import pandas as pd
import pickle
unitconv_length = pd.read_pickle('Unitconv_length.p')
unitconv_area = pd.read_pickle('Unitconv_area.p')
unitconv_volume = pd.read_pickle('Unitconv_volume.p')
unitconv_pressure = pd.read_pickle('Unitconv_pressure.p')
class unitconv:
def __init__(self,selection, fromunit, tounit, value):
self.type = selection # length, area, volume
self.funit = fromunit # 기존 단위
self.tunit = tounit # 변경하고자 하는 단위
self.value = value # 값
def cal(self):
if self.type == "length":
factor = unitconv_length.loc[self.funit, self.tunit]
sol = factor * self.value
elif self.type =="area":
factor = unitconv_area.loc[self.funit, self.tunit]
sol = factor * self.value
elif self.type =="volume":
factor = unitconv_volume.loc[self.funit, self.tunit]
sol = factor * self.value
elif self.type =="pressure":
factor = unitconv_pressure.loc[self.funit, self.tunit]
sol = factor * self.value
return sol
## a = unitconv("length","mm", "ft", 50)
## b = a.cal()
## a = unitconv("length","mm", "ft", 50).cal()
Fan_curve.py
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 1 10:49:05 2023
@author: seungj.jung
"""
## P-Q curve for electric Fan
import os
from openpyxl import load_workbook
import numpy as np
import pandas as pd
import pickle
import matplotlib.pyplot as plt
openfiledir = os.getcwd() + '\\' # 현재 폴더 위치
filename = 'Fan_curve.xlsx' # 현재 폴더 위치의 해당 파일명의 .xls 파일 open
df = pd.read_excel(openfiledir + filename)
# 1행, 1열 삭제
df.drop([1], inplace = True)
df.drop(['Unnamed: 0'], axis = 1, inplace = True)
ColName = df.loc[0]
df.columns = ColName
df.drop([0], inplace = True)
IndName = df["Pressure"]
df.drop(["Pressure"], axis = 1, inplace = True)
df.index = IndName
# with open('Fan_curve.p','wb') as file:
# pickle.dump(df, file)
# # a = df.loc[55.04][0]
class Fan:
def __init__(self, pressure):
self.pressure = pressure
def Flow(self):
if self.pressure > max(df.index) or self.pressure <0: #Temperature range 설정 (-40 ~ 80)
print("Out of range")
value = []
else:
for i in range(len(df.index)):
if self.pressure == df.index[i]:
value = df.loc[self.pressure][0]
elif self.pressure < df.index[i] and self.pressure > df.index[i+1]:
value = df.loc[df.index[i]][0] + (self.pressure - df.index[i]) * (df.loc[df.index[i+1]][0] -df.loc[df.index[i]][0]) / (df.index[i+1] -df.index[i])
return value
## 호출
# Flow = Fan(pressure).Flow()
class Plot:
def Curve():
step = 0.01
flow = []
pressure = []
if df.index[0] > df.index[-1]:
for i in range(int(df.index[-1]*100), int(df.index[0]*100), 1):
y = i *step
x = Fan(y).Flow()
flow.append(x)
pressure.append(y)
else:
for i in range(int(df.index[0]*100), int(df.index[-1]*100), 1):
y = i *step
x = Fan(y).Flow()
flow.append(x)
pressure.append(y)
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(1, 1, 1)
ax.plot(flow, pressure)
## plot setting
plt.rc('xtick', labelsize = 18)
ax.set_xlabel('Volumetric flow, Q (ft3/min)', fontsize=16)
ax.set_ylabel('Pressure, P (mmH2O)', fontsize=16)
ax.set_title('Fan P-Q Performance curve', fontsize=20, loc='center') # 'center', 'right'
plt.show()
return flow, pressure
## 호출
## Fan_curve = Plot.Curve()
example
start = time.time() # 시작시간
for i in range(10, 26, 5): # H
for j in range(2, 9, 2): # b
for k in range(10, 16, 1): # t
k = k/10 ## thickness 할때만 int 로 받아야 하므로 i/10
for l in range(20,41,5): # N
heatsink1 = Heatsink(i, 100, j, k, l, 90, 167) # H, L, b, t, N, W, k_fin
Cal1.setdata(T_ambient, 10, chip1, heatsink1)
Sol_dp = FindValue(1, Cal1, chip1, heatsink1)
V_flow = fan(Sol_dp).Flow() #ft3/min
Sol_temp = FindValue(0, Cal1, chip1, heatsink1, V_flow) # heat sink 평균온도 계산
Rsp = Cal1.cal_rsp(V_flow)
T_spot = Sol_temp + (Rsp*chip1.tot_power)
Check_resis = (T_spot - T_ambient) / chip1.tot_power
print(str(i).center(5), str(j).center(5), str(k).center(5), str(l).center(5), "Check_resis : ", "{:.6f}".format(Check_resis) ," ", "Target : ", "{:.6f}".format(target_resis))
if Check_resis < target_resis:
n = n+1
dp = unitconv("pressure", "mmWTR", "Pa", Sol_dp).cal()
Vol_f = unitconv("volume", "ft3", "m3", V_flow).cal()/60 # m3/s
Nu_m = Cal1.cal_temp(V_flow)[2][24]
Pr = Cal1.cal_temp(V_flow)[2][20]
Re_D = Cal1.cal_temp(V_flow)[2][22]
T_disch = Cal1.T_disch(V_flow)
list_heatsink.loc[n]=[heatsink1.H, heatsink1.L, heatsink1.b, heatsink1.L_fin, heatsink1.t, heatsink1.N, heatsink1.S, heatsink1.W, Sol_temp, T_spot, Rsp, Check_resis, dp, T_disch, Vol_f, Nu_m, Pr, Re_D]
end = time.time() # 계산 종료 시간
print(f"{end - start : .5f} sec") # 계산 시간
list_heatsink.drop([0], inplace = True) # 초기 조건 삭제