[S0069] Create thermal model region settings to a 2D model

The thermal modeling feature can be used to create a complex thermal equivalent circuit based on coolant paths and various parameter settings.
Thermal model region setting defines the correspondence between each region of the FEA model and the components of the thermal model.
This script creates a thermal model region for a radial-flux motor in a 2D model and assigns existing sets to each region.

Preconditions

  • One or more thermal analysis studies have been created for the 2D model.
    This script runs on the active thermal analysis study in the project tree.
    It can also be created for 3D models using a similar script API though the required configuration parameters differ.
  • The thermal model region has not been created.
  • The edge sets and part sets used for the thermal model region have already been created and their titles are known.
  • The thermal model is available in JMAG-Designer v25.1 and later.

Script Function

  • Create a thermal model region for a radial-flux motor with the title "motor".
  • Set "StatorGap_Edge" edge set to the stator side of the gap and "RotorGap_Edge" edge set to the rotor side.
  • Set "StatorCoreSide_Edge" edge set to the stator outer and "Core-Shaft_Edge" edge set to the rotor inner.
  • Set "Stator/Core_Region" part set to the stator core, "Rotor/Core_Region" part set to the rotor core and "Coil.1" and "Coil.2" part sets to the coils.
# 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()

Download Python source code

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.

Search Filter
  • All Categories

An engineer's diary
JMAG-Express Online