[S0029] Set a point array property to the analysis condition

 

Some parameters of the analysis conditions need to be defined that change with respect to time, rotation speed, etc.
If the dependency is nonlinear, the data is set as a point array. Such a point array is also needed to be registered as a dataset in the graph manager.
This script sets a point array representing the time dependent voltage to the efficiency map (heat source) condition.

Preconditions

  • One or more thermal transient state analysis studies have been created and efficiency map (heat source) conditions must be set.
    This script runs on the active thermal transient state analysis study in the project tree.
  • One or more efficiency map analysis studies have been created and that has efficiency map definitions.
  • The efficiency map (heat source) conditions must refer to the efficiency map and the [Specifying multiple voltages] must be enabled in that efficiency map definition.
  • The time dependent voltage in the efficiency map (heat source) conditions is available in JMAG-Designer v25.0 and later.

Script Function

  • Specify the type name "ReferenceMapLoss" for the efficiency map (heat source) condition and retrieve all applied efficiency map (heat source) conditions. If multiple conditions are retrieved, apply the settings to the first one.
  • Create a point array (type: efficiency_voltage_time) representing the time dependent voltage and set its values.
  • Set the point array to the time dependent voltage of the efficiency map (heat source) condition.
# 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/

def getConditionsSpecifiedType(targetStudy, typeName):
    """Retrieve conditions of the specified type assigned to the study."""
    matchedConditions = []
    numConds = targetStudy.NumConditions()

    for i in range(numConds):
        condition = targetStudy.GetCondition(i)
        CondType = condition.GetScriptTypeName()
        if CondType == typeName:
            matchedConditions.append(condition)
    return matchedConditions

def createDataSet(dataManager, pointType, pointName, points):
    """Add a point array to graph manager."""
    dataSet = dataManager.CreatePointArray(pointType, pointName)
    dataSet.SetTable(points)
    return dataSet


def setTimeDependentVoltageToEfficiencyMapHeatSource(targetStudy, dataManager):
    """Obtain the efficiency map (heat source) conditions applied to the targetStudy and set the voltage vs time point array property."""
    conditionType = u"ReferenceMapLoss" # Condition type name that means efficiency map (heat source) condition
    efficiencyMapHeatSourceConditions = getConditionsSpecifiedType(study, conditionType)

    if len(efficiencyMapHeatSourceConditions) <= 0:
        print(f"The condition ({conditionType}) is not found.")
    elif len(efficiencyMapHeatSourceConditions) > 1:
        print(f"This study contains two or more conditions ({conditionType}).\nThis sample uses the first condition found.")

    if len(efficiencyMapHeatSourceConditions) >= 1:
        propertyName = u"VoltageTimeTable" # Property type name of voltage vs time point sequence of the efficiency map (heat source) condition
        pointType = u"efficiency_voltage_time" # The type name of point array that means voltage vs time
        pointName = u"TimeDependentVoltageArray1"
        pointArrayTimeVoltage = [[0 for i in range(2)] for j in range(2)]
        pointArrayTimeVoltage[0][0] = 0
        pointArrayTimeVoltage[0][1] = 10
        pointArrayTimeVoltage[1][0] = 100
        pointArrayTimeVoltage[1][1] = 20
        dataSet = createDataSet(dataManager, pointType, pointName, pointArrayTimeVoltage)
        efficiencyMapHeatSourceConditions[0].SetTableProperty(propertyName, dataSet)


app = designer.GetApplication()
study = app.GetCurrentStudy()
dataManager = app.GetDataManager()
setTimeDependentVoltageToEfficiencyMapHeatSource(study, dataManager)

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