強制対流による冷却を設定する(自然対流分を含む)
def main():
app = designer.GetApplication()
dialog = app.CreateDialogBox()
title_ja = "冷却(強制対流)"
title_en = "Cooling(Forced Convection)"
select_ja = "外表面"
select_en = "Outer Surface"
temperature_ja = "参照温度, ℃"
temperature_en = "Reference Temperature, ℃"
flow_speed_ja = "ファン流速, m/s"
flow_speed_en = "Fan Flow Speed, m/s"
select_axis_ja = "回転軸"
select_axis_en = "Axis of Rotation"
to_meter = 0.001
study_select_error_en = "Current Study is not Heat Study."
study_select_error_ja = "選択されているスタディは熱解析スタディではありません。"
no_face_selected_ja = "面が選択されていません。"
no_face_selected_en = "No Face is selected."
cancel_message_en = "Process is canceled."
cancel_message_ja = "処理が中断されました。"
currentStudy = app.GetCurrentStudy()
currentStudyType = currentStudy.GetScriptTypeName()
if not currentStudyType.startswith("Heat"):
show_error_exit_message(study_select_error_en, study_select_error_ja)
return
app.View().SelectFace()
dialog.SetTranslation(title_en, title_ja)
dialog.SetTranslation(select_en, select_ja)
dialog.SetTranslation(temperature_en, temperature_ja)
dialog.SetTranslation(flow_speed_en, flow_speed_ja)
dialog.SetTranslation(select_axis_en, select_axis_ja)
dialog.SetTitle(title_en)
dialog.SetModal(False)
dialog.AddSelectFaceList("outer_face", select_en)
dialog.AddReal("temperature", temperature_en, 20)
dialog.AddReal("flow_speed", flow_speed_en, 1)
dialog.AddAxisSelection("origin", "vector", select_axis_en)
ret = dialog.Show()
if ret==0:
show_cancel_exit_message(cancel_message_en, cancel_message_ja)
return
face_ids = dialog.GetValueAsIntegerList("outer_face")
mesh_group_ids = dialog.GetMeshGroupIndices("outer_face")
if len(face_ids)==0 and len(mesh_group_ids)==0:
show_cancel_exit_message(no_face_selected_en, no_face_selected_ja)
return
face_set_indices = dialog.GetSetIndices("outer_face")
temperature = dialog.GetValue("temperature")
origin = dialog.GetPoint("origin")
vector = dialog.GetPoint("vector")
case_height = currentStudy.GetFacesHeight(face_ids, vector)
currentModel = app.GetCurrentModel()
height_unit = currentModel.GetCurrentUnit("Length")
converted_height = currentModel.ConvertValueToSI(height_unit, case_height)
v_air = dialog.GetValue("flow_speed")
Lec = converted_height
ro_air = 1.1
mu_air = 2.0e-5
k_air = 0.03
Pr = 0.7
Re = Lec * v_air * ro_air / mu_air
if Re < 1e+4:
Nu = 0.66 * pow(Re, 0.5) * pow(Pr, 0.33)
else:
Nu = 0.066 * pow(Re, 0.75) * pow(Pr, 0.33)
hea = Nu * k_air / Lec
h0 = 5.988 # h0 = 1.0 / 0.167
condition = currentStudy.CreateCondition("HeatTransfer", "untitled")
condition.SetValue("Coefficient", hea + h0)
temp_unit = currentModel.GetCurrentUnit("Temperature")
converted_temp = currentModel.ConvertValueFromSI(temp_unit, currentModel.ConvertValueToSI("degC", temperature))
condition.SetValue("Temperature", converted_temp)
condition.ClearParts()
sel = condition.GetSelection()
for fid in face_ids:
sel.SelectFace(fid)
condition.AddSelected(sel)
for set_index in face_set_indices:
face_set = currentModel.GetSetList().GetSet(set_index)
condition.AddSet(face_set, 0)
for mesh_group_id in mesh_group_ids:
condition.AddGroup(currentStudy.GetMeshGroupList().GetMeshGroup(mesh_group_id), 0)
def show_error_exit_message(message_en, message_ja):
title_en = "Error"
title_ja = "エラー"
show_message(title_en, title_ja, message_en, message_ja)
def show_cancel_exit_message(message_en, message_ja):
title_en = "Cancel"
title_ja = "キャンセル"
show_message(title_en, title_ja, message_en, message_ja)
def show_message(title_en, title_ja, message_en, message_ja):
app = designer.GetApplication()
msgdlg = app.CreateDialogBox()
msgdlg.SetTranslation(title_en, title_ja)
msgdlg.SetTranslation(message_en, message_ja)
msgdlg.SetCancelButtonVisible(False)
msgdlg.SetTitle(title_en)
msgdlg.AddLabel(message_en)
msgdlg.Show()
main()


