[S0070] Check for unassigned thermal model regions

In the thermal model region setting, all required regions must be set.
The required region settings are different between 2D and 3D models.
This script displays unset items in the thermal model region setting according to the model dimension.

Preconditions

  • One or more thermal analysis studies with defined thermal model region setting have been created.
    This script runs on the active thermal analysis study in the project tree.
  • The thermal model is available in JMAG-Designer v25.1 and later.

Script Function

  • Obtain the model dimension and switch the thermal model region items to be checked based on whether it is 2D or 3D.
  • Check for any unset regarding the stator and rotor sides of the gap, the stator outer and the rotor inner.
  • For a 2D model, check for any unset regarding the stator core, rotor core, and coil.
  • For a 3D model, check for any unset regarding the front and rear stator cores, rotor cores and coils.
  • Display unset items. And display a message indicating if all items are assigned.
# Copyright (c) 2026 JSOL CORPORATION
#
# This script is released under the MIT License.
# See the following URL for the full license text.
# https://www.jmag-international.com/jp/scriptlibrary/jmag_script_library_mit/

app = designer.GetApplication()


def getThermalModelRegionCheckItems(dimension):
    """Get thermal model regions to be checked according to the model dimension."""
    checkItems = [
        (u"stator_gap", u"Gap (stator side)"),
        (u"rotor_gap", u"Gap (rotor side)"),
        (u"stator_outer", u"Stator outer boundary"),
        (u"rotor_inner", u"Rotor inner boundary"),
    ]

    if dimension == 2:
        checkItems.extend([
            (u"stator_core", u"Stator core"),
            (u"rotor_core", u"Rotor core"),
            (u"coil", u"Coil (1 slot)"),
        ])
    elif dimension == 3:
        checkItems.extend([
            (u"stator_core", u"Stator core (front face)"),
            (u"rotor_core", u"Rotor core (front face)"),
            (u"coil", u"Coil (front face) (1 slot)"),
            (u"rear_stator_core", u"Stator core (rear face)"),
            (u"rear_rotor_core", u"Rotor core (rear face)"),
            (u"rear_coil", u"Coil (rear face) (1 slot)"),
        ])

    return checkItems


def checkUnassignedThermalModelRegions(thermalModelRegion, checkItems):
    """Check and display unassigned thermal model regions."""
    warningExists = False
    for key, label in checkItems:
        if thermalModelRegion.HasWarning(key):
            print(u"{0} is not assigned.".format(label))
            warningExists = True

    if not warningExists:
        print(u"All thermal model regions are assigned.")


def main():
    """Check unassigned thermal model regions in the current study."""
    model = app.GetCurrentModel()
    study = app.GetCurrentStudy()
    thermalModelRegion = study.GetThermalModelRegion()

    if not thermalModelRegion.IsValid():
        return

    checkItems = getThermalModelRegionCheckItems(model.GetDimension())
    checkUnassignedThermalModelRegions(thermalModelRegion, checkItems)


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