# 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)