# Copyright (c) 2026 JSOL CORPORATION # # This script is released under the MIT License. # See the full license text at: # https://www.jmag-international.com/scriptlibrary/jmag_script_library_mit/ app = designer.GetApplication() # Set names StatorGapSetName = u"StatorGap_Edge" RotorGapSetName = u"RotorGap_Edge" StatorOuterSetName = u"StatorCoreSide_Edge" RotorInnerSetName = u"Core-Shaft_Edge" StatorCoreSetName = u"Stator/Core_Region" RotorCoreSetName = u"Rotor/Core_Region" CoilSetNames = [u"Coil.1", u"Coil.2"] def createThermalModelRegion(study): """Create a thermal model region for a radial-flux motor.""" app.ClearError() thermalModelRegion = study.CreateThermalModelRegion(u"motor") if app.HasError(): errorMessage = app.GetLastMessage() app.ClearError() print(errorMessage) return None return thermalModelRegion def setThermalModelRegion(thermalModelRegion, setList): """Set the stator, rotor, and coil regions in the thermal model region.""" regionSetData = [ (u"stator_gap", StatorGapSetName), (u"rotor_gap", RotorGapSetName), (u"stator_outer", StatorOuterSetName), (u"rotor_inner", RotorInnerSetName), (u"stator_core", StatorCoreSetName), (u"rotor_core", RotorCoreSetName), ] for regionType, setName in regionSetData: thermalModelRegion.AddSet(regionType, setList.GetSet(setName)) for coilSetName in CoilSetNames: thermalModelRegion.AddSet(u"coil", setList.GetSet(coilSetName)) def main(): """Create a thermal model region in the current study and set each region.""" model = app.GetCurrentModel() study = app.GetCurrentStudy() thermalModelRegion = createThermalModelRegion(study) if thermalModelRegion is None: return setThermalModelRegion(thermalModelRegion, model.GetSetList()) main()