磁界過渡応答解析において時間に応じた運動がある際には運動条件を付与します。モーターなどの回転機では回転中心から一定の範囲内にある部品が回転運動の対象となることが一般的です。このスクリプトでは部品名などで1つ1つ設定するのではなく、インナーローターを想定して回転中心軸から指定された半径以内にある部品を判定し、回転運動条件を設定します。
前提条件
- 磁界過渡応答解析スタディが1つ以上作成されていること
このスクリプト例では、プロジェクトツリー上1番目のモデルの1番目のスタディに対して実行している - 回転軸は原点を通るZ軸であり、指定された半径の内側にある部品が回転運動するインナーローター型であること
- 設定値の単位は、作成されているモデルに設定されている単位系に従う
スクリプトにおける設定内容
- モデルの全部品のうち、指定された半径内にある部品を判定し、該当する部品IDでSelectionを作成
- 回転運動条件を作成し、先に作成したSelectionを対象として設定
- 回転運動条件のその他のパラメータは、このスクリプト例では変異タイプを速度一定で600、初期位置は指定するとして15, 回転中心は原点を通るとしている
# Copyright (c) 2026 JSOL CORPORATION
#
# 本スクリプトはMITライセンスのもとで公開しています。
# ライセンス全文は以下を参照してください。
# https://www.jmag-international.com/jp/scriptlibrary/jmag_script_library_mit/
import math
def selectPartsWithinRadius(targetModel, targetRadius):
"""引数半径以内にある部品をすべて選択する"""
sel = targetModel.CreateSelection()
numParts = targetModel.NumParts()
for i in range(numParts):
targetPart = targetModel.GetPartByIndex(i)
# 部品内の1座標位置を取得
pointInPart = targetPart.PointInPart()
# 取得した座標の原点中心でのr座標を計算
rad = math.sqrt((pointInPart.GetX()**2)+(pointInPart.GetY()**2))
if rad <= targetRadius:
sel.SelectPart(targetPart.ID())
return sel
def createMotionConditionOfInnerRotor(targetStudy, selectedTargets):
"""引数で渡された部品を対象に回転運動条件を作成する"""
RotMotionCond = targetStudy.CreateCondition(u"RotationMotion", u"rotMotion")
RotMotionCond.SetValue(u"MotionGroupType", u"ConstantVelocity")
RotMotionCond.SetValue(u"AngularVelocity", 600)
RotMotionCond.SetValue(u"InitialRotationAngleType", u"Manual")
RotMotionCond.SetValue(u"InitialRotationAngle", 15)
RotMotionCond.SetXYZPoint(u"Origin", 0, 0, 0)
RotMotionCond.ClearParts()
RotMotionCond.AddSelected(selectedTargets)
app = designer.GetApplication()
model = app.GetModel(0)
rad = 0.01175
sel = selectPartsWithinRadius(model, rad)
study = model.GetStudy(0)
createMotionConditionOfInnerRotor(study, sel)


