[D0038] 磁石・ロータコア間の接触熱抵抗

 

磁石・ロータコア間の接触熱抵抗を設定する

def main():
	app = designer.GetApplication()
	dialog = app.CreateDialogBox()
	
	title_ja = "磁石・ロータコア間の接触熱抵抗"
	title_en = "Contact Heat Resistance between Magnet and Rotor Core"
	
	select_magnet_face_ja = "接触面(磁石側)"
	select_magnet_face_en = "Contact Surface(Magnet Side)"
	
	adhesive_type_ja = "接着の種類"
	adhesive_type_en = "Adhesive Type"

	adhesive_epoxy_ja = "エポキシ系(熱伝導率0.3)"
	adhesive_epoxy_en = "Epoxy(Conductivity 0.3)"

	adhesive_acrylic_ja = "アクリル系(熱伝導率 0.21)"
	adhesive_acrylic_en = "Acrylic(Conductivity 0.21)"

	adhesive_other_ja = "任意指定"
	adhesive_other_en = "Other"
	
	adhesive_conductivity_ja = "樹脂の熱伝導率, W/(m K)"
	adhesive_conductivity_en = "Adhesive Conductivity, W/(m K)"
	
	adhesive_thickness_ja = "樹脂厚さ, mm"
	adhesive_thickness_en = "Adhesive Thickness, mm"

	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

	adhensive_type_items = [adhesive_epoxy_en, adhesive_acrylic_en, adhesive_other_en]

	app.View().SelectFace()
	
	dialog.SetTranslation(title_en, title_ja)
	dialog.SetTranslation(select_magnet_face_en, select_magnet_face_ja)
	dialog.SetTranslation(adhesive_type_en, adhesive_type_ja)
	dialog.SetTranslation(adhesive_epoxy_en, adhesive_epoxy_ja)
	dialog.SetTranslation(adhesive_acrylic_en, adhesive_acrylic_ja)
	dialog.SetTranslation(adhesive_other_en, adhesive_other_ja)
	dialog.SetTranslation(adhesive_conductivity_en, adhesive_conductivity_ja)
	dialog.SetTranslation(adhesive_thickness_en, adhesive_thickness_ja)
	dialog.SetTranslation(study_select_error_en, study_select_error_ja)
	dialog.SetTranslation(cancel_message_en, cancel_message_ja)
	
	dialog.SetTitle(title_en)
	dialog.SetModal(False)
	dialog.AddSelectFaceList("select_magnet_face", select_magnet_face_en)
	dialog.AddComboBox("adhesive_type", adhesive_type_en, adhensive_type_items)
	dialog.AddReal("adhesive_conductivity", adhesive_conductivity_en, 0.3)
	dialog.AddReal("adhesive_thickness", adhesive_thickness_en, 0.1)
	ret = dialog.Show()
	if ret==0:
		show_cancel_exit_message(cancel_message_en, cancel_message_ja)
		return

	face_ids = dialog.GetValueAsIntegerList("select_magnet_face")
	mesh_group_ids = dialog.GetMeshGroupIndices("select_magnet_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("select_magnet_face")

	conductivity = dialog.GetValue("adhesive_conductivity")
	thickness = dialog.GetValue("adhesive_thickness")
	
	type_index = dialog.GetValue("adhesive_type");
	if type_index==0:
		conductivity = 0.3
	elif type_index==1:
		conductivity = 0.21
	
	condition = currentStudy.CreateCondition("Contact Resistance", "untitled")
	condition.SetValue("ThermalConductivity", conductivity)
	condition.SetValue("Thickness", thickness)
	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()

Download Python source code

ファイルご利用の注意点

JMAGスクリプトライブラリをご利用されるに際し、以下の利用規約をよくお読みいただき、ご同意の上ご利用下さるようお願い申し上げます。