Vector expressions are a feature that treats 1-dimensional array data as a single variable. A single series is extracted from tabular result data to serve as vector data. A vector expression is defined involving these vector data or a combination of vector data and scalar values.
By creating response values from such vector expressions, these can also be used in optimization.
This script creates vector expression data from a table result and defines a vector expression using those variables.
Preconditions
- One or more studies have been created.
This script runs on the active thermal analysis study in the project tree.
Script Function
- Create vector data by specifying reference data in the study.
Reference data: Circuit thermal resistance
Lines: "Rt1"
Variable: "RtRt1ve"
Range: Use all steps in all cases - Create a vector expression using the vector data.
Variable: "RtCE1R2ve"
Expression: 1/RtRt1ve
# 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()
def createVectorExpression(study, vectorExprInfo):
"""Creating variables and expressions using vector data."""
exprtype = vectorExprInfo[u"type"]
exprParam = vectorExprInfo[u"param"]
vectExpr = study.CreateVectorExpression(vectorExprInfo[u"title"])
# Created from dataset.
if exprtype == u"DataVariable":
vectExpr.SetReferenceDataFromTable(exprParam[u"refDataFromTbl"])
vectExpr.SetUnit(exprParam[u"unit"])
vectExpr.SetLine(exprParam[u"line"])
vectExpr.SetVariable(exprParam[u"variable"])
vectExpr.SetCaseRangeType(exprParam[u"caseRangeType"])
# Creating an expression.
elif exprtype == u"Expression":
vectExpr.SetVariable(exprParam[u"variable"])
vectExpr.SetExpression(exprParam[u"expression"])
study = app.GetCurrentStudy()
dataVarParam = {
u"type" : u"DataVariable",
u"title" : u"rth1",
u"param" : { u"refDataFromTbl" : u"Circuit Thermal Resistance",
u"unit" : u"s",
u"line" : u"Rt1",
u"variable" : u"RtRt1ve",
u"caseRangeType" : u"allsteps"
}
}
createVectorExpression(study, dataVarParam)
exprParam = {
u"type" : u"Expression",
u"title" : u"rth2",
u"param" : { u"variable" : u"RtCE1R2ve",
u"expression" : u"1 / RtRt1ve"
}
}
createVectorExpression(study, exprParam)


