The composite result display function allows multiple distribution plots to be shown on a single screen. It can display different result types or different components for each part, helping users understand their correlations. To create a composite display, first define each plot individually, and then create the composite display definition.
This script creates a contour plot, a vector plot, and a flux line, and configures them to display on a single screen as composite result definition.
Preconditions
- One or more study has been created.
This script runs on the active magnetic field analysis study in the project tree.
By specifying the result type appropriate to the study, it can be run on results other than magnetic field analysis study. - The names of the parts to draw contour must be known.
Script Function
- Create a flux line definition for magnetic flux density.
Set the rendering start type to plane and specify the plane with the Z-axis as the normal. This specification is usable in 3D analysis.
Set the line thickness to 5.0 and the color to blue. - Create a contour plot definition for current density results.
Set the display parts to only the "Coil" parts group. - Create a vector plot definition for magnetic field strength results.
Set the arrow type to "Cone" and the scale color gradient to CMR. - Set composite result definition of created plots.
Set the flux line, contour, and vector created up to this point to be displayed items. - Turn on composite result display. This can be executed when analysis results are available.
# 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 settingCompositeResultDefinition(study, fluxLine, contour, vector):
"""Configure simultaneous display of result plots"""
compoResult = study.CreateCompositeResult(u"flux_cont_vec_compo_res")
compoResult.ClearResults()
compoResult.SetFluxLineDefinition(fluxLine)
compoResult.SetContourDefinition(contour)
compoResult.SetVectorDefinition(vector)
def createFluxLine(study, typeName):
"""Create flux line"""
fluxLine = study.CreateFluxLine("mag_flux_dens")
fluxLine.SetResultType(typeName, u"")
fluxLine.SetFluxLineType(u"plane")
fluxLine.SetColor(u"blue")
fluxLine.SetOrigin(28, 28, 15)
fluxLine.SetNormal(0, 0, 1)
fluxLine.SetThickness(u"5")
# display type
# 0:Shaded
# 1:Hidden Line
# 2:Wireframe
fluxLine.SetDisplayType(0)
return fluxLine
def createContour(study, typeName, partIdList):
"""Create contour plot"""
contour = study.CreateContour(u"contour")
contour.SetResultType(typeName, u"")
# The Arguments of SetResultCoordinate
# Name or index
# The name of the preset coordinate system is fixed according to the language setting.
# The index is specified in a 0-based from the coordinate system definition list order under Project - Model - Coordinate Systems
contour.SetResultCoordinate(0)
#contour.SetResultCoordinate(u"Global Rectangular")
contour.SetDisplayAllParts(False)
contour.RemoveAllParts()
for partId in partIdList:
contour.AddPart(partId)
return contour
def createVector(study, typeName):
"""Create vector plot"""
vector = study.CreateVector(u"vector")
vector.SetResultType(typeName, u"")
vector.SetStyle(u"Cone")
vector.SetGradient(u"CMR", u"21", True)
vector.SetNumVectors(u"0")
# display type
# 0:Shaded
# 1:Hidden Line
# 2:Wireframe
vector.SetDisplayType(0)
return vector
study = app.GetCurrentStudy()
typeName = u"MagneticFluxDensity"
fluxLine = createFluxLine(study, typeName)
typeName = u"CurrentDensity"
model = app.GetCurrentModel()
partGroup = model.GetGroupList().GetGroup(u"Coil")
partIdList = partGroup.GetPartIDs()
contour = createContour(study, typeName, partIdList)
typeName = u"MagneticFieldStrength"
vector = createVector(study, typeName)
settingCompositeResultDefinition(study, fluxLine, contour, vector)
app.View().SetCompositeView(True) # An error will occur if no analysis results are available.


