自然対流による冷却を設定する
def main():
app = designer.GetApplication()
dialog = app.CreateDialogBox()
title_ja = "冷却(自然対流)"
title_en = "Cooling(Natural Convection)"
select_ja = "外表面"
select_en = "Outer Surface"
temperature_ja = "参照温度, ℃"
temperature_en = "Reference Temperature, degC"
study_select_error_en = "Current Study is not Heat Study."
study_select_error_ja = "選択されているスタディは熱解析スタディではありません。"
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.SetTitle(title_en)
dialog.SetModal(False)
dialog.AddSelectFaceList("outer_face", select_en)
dialog.AddReal("temperature", temperature_en, 20)
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")
face_set_indices = dialog.GetSetIndices("outer_face")
temperature = dialog.GetValue("temperature")
h0 = 5.988 # h0 = 1.0 / 0.167
condition = currentStudy.CreateCondition("HeatTransfer", "untitled")
condition.SetValue("Coefficient", h0)
condition.SetValue("Temperature", temperature)
condition.ClearParts()
sel = condition.GetSelection()
for fid in face_ids:
sel.SelectFace(fid)
condition.AddSelected(sel)
currentModel = app.GetCurrentModel()
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()


