[D0040] ステータコア・ケースの接触熱抵抗

 

ステータコア・ケースの接触熱抵抗を設定

import math

def main():
	app = designer.GetApplication()
	dialog = app.CreateDialogBox()
	
	title_ja = "ステータコア・ケースの接触熱抵抗"
	title_en = "Contact Resistance between Stator Core and External Case"
	
	select_stator_ja = "接触面(ステータコア側)"
	select_stator_en = "Contact Surface(Stator Core Side)"
	
	tightness_ja = "接触の度合い"
	tightness_en = "Tightness"

	tightness_perfect_ja = "完全"
	tightness_perfect_en = "Perfect"
	
	tightness_good_ja = "きつめ"
	tightness_good_en = "Good"

	tightness_average_ja = "通常"
	tightness_average_en = "Average"

	tightness_poor_ja = "ゆるめ"
	tightness_poor_en = "Poor"

	tightness_optional_ja = "任意"
	tightness_optional_en = "Other"

	gap_length_ja = "ギャップ幅, mm"
	gap_length_en = "Gap Width, mm"
	
	conversion_factor_ja = "換算率"
	conversion_factor_en = "Conversion Factor"

	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 = "処理が中断されました。"

	to_meter = 0.001
	
	currentModel = app.GetCurrentModel()
	currentStudy = app.GetCurrentStudy()
	currentStudyType = currentStudy.GetScriptTypeName()
	if not currentStudyType.startswith("Heat"):
		show_error_exit_message(study_select_error_en, study_select_error_ja)
		return

	tightness_items = [tightness_perfect_en, tightness_good_en, tightness_average_en, tightness_poor_en, tightness_optional_en]

	app.View().SelectFace()
	
	dialog.SetTranslation(title_en, title_ja)
	dialog.SetTranslation(select_stator_en, select_stator_ja)
	dialog.SetTranslation(tightness_en, tightness_ja)
	dialog.SetTranslation(tightness_perfect_en, tightness_perfect_ja)
	dialog.SetTranslation(tightness_good_en, tightness_good_ja)
	dialog.SetTranslation(tightness_average_en, tightness_average_ja)
	dialog.SetTranslation(tightness_poor_en, tightness_poor_ja)
	dialog.SetTranslation(gap_length_en, gap_length_ja)
	dialog.SetTranslation(conversion_factor_en, conversion_factor_ja)
	
	dialog.SetTitle(title_en)
	dialog.SetModal(False)
	dialog.AddSelectFaceList("select_stator", select_stator_en)
	dialog.AddComboBox("tightness", tightness_en, tightness_items)
	dialog.AddReal("gap_length", gap_length_en, 100)
	dialog.AddReal("conversion_factor", conversion_factor_en, model_division(currentStudy))
	ret = dialog.Show()
	if ret==0:
		show_cancel_exit_message(cancel_message_en, cancel_message_ja)
		return
	face_ids = dialog.GetValueAsIntegerList("select_stator")
	mesh_group_ids = dialog.GetMeshGroupIndices("select_stator")
	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_stator")

	tightness = dialog.GetValue("tightness")
	
	k_air = 0.03
	gap_length = [ 0.0, 0.01, 0.05, 0.1 ]
	
	A = 0
	for fid in face_ids:
		A += currentModel.GetFaceArea(fid)
	
	A_unit = currentModel.GetCurrentUnit("Length") + "^2"
	converted_area = currentModel.ConvertValueToSI(A_unit, A)

	print(A)
	l_ig = 0
	if tightness == 4:
		optional_gap_length = dialog.GetValue("gap_length")
		l_ig = optional_gap_length * to_meter
	else:
		l_ig = gap_length[tightness] * to_meter

	cf = dialog.GetValue("conversion_factor")

	r_sig = l_ig / (k_air * converted_area) * cf
	
	condition = currentStudy.CreateCondition("Contact Resistance", "untitled")
	condition.SetValue("SettingType", 1)
	condition.SetValue("ThermalResistance", r_sig)
	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()

def model_division(study):
	division = 1
	for i in range(study.NumConditions()):
		condition = study.GetCondition(i)
		type = condition.GetScriptTypeName()
		if type=="RotationPeriodicBoundary":
			angle = condition.GetValue("Angle")
			division = int(360.0/angle)
			
	return division

main()

Download Python source code

ファイルご利用の注意点

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