When the calculation of eddy current distribution in the steel plate, results are output for each depth within the lamination.
These depth-specific lamination calculation results can be viewed by using a probe.
Additionally, there is a processing function available to calculate the average value at each depth.
This script creates a magnetic flux density (lamination) probe and calculates the average value for each depth over a specified time range.
Preconditions
- One or more magnetic field analysis studies have been created.
This script runs on the magnetic field transient analysis study in the project tree. - The output of calculation results requires that the study has already been calculated.
- Results for the lamination are output.
Select "Calculate Distribution in Steel Plate" as eddy currents for the material's electric properties.
Script Function
- Create a magnetic flux density (lamination) probe.
Specify the probe point at coordinates (-58, 9, 0).
Since the calculation process runs with every API call when creating a probe via script, suppress this behavior during execution.
"SetAutoRecalculate(False)" to suppress the calculation process.
Use "Build()" to apply the settings and perform the calculation. - Calculate the per depth average based on the results from the previously created probe.
The time range for averaging is 0 – 0.02 seconds. - Export the table of averages in depth in CSV format to the same directory as the currently opened project file.
# 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/
import os
app = designer.GetApplication()
def createLamiMagFluxDensityProbe(study, title):
"""Create a magnetic flux density (stacked) probe."""
probe = study.CreateProbe(title)
probe.SetAutoRecalculate(False)
probe.SetResultType(u"LaminationMagneticFluxDensity")
# The 1st argument 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
probe.SetResultCoordinate(0)
# probe.SetResultCoordinate(u"Global Rectangular")
probe.SetComponent(u"All")
probe.SetLocationCoordinate(0)
# probe.SetLocationCoordinate(u"Global Rectangular")
probe.SetProbeType(u"Coordinate")
probe.SetLocation(0, u"-58", u"9", u"0")
probe.RenamePoint(0, u"Measurement position")
probe.SetUseElementValue(True)
probe.SetMoveWithPart(True)
probe.Build()
return probe
def createAvgVsDepth(dataManager, probe, param):
"""Create the necessary parameters for averaging by depth."""
parameter = app.CreateGraphIntegralParameter(param[u"title"])
dataSet = probe.GetDataSet()
parameter.AddDataSet(dataSet)
parameter.SetMin(param[u"min"])
parameter.SetMax(param[u"max"])
parameter.SetRangeUnit(param[u"rangeUnit"])
dataSetAVGVsDepth = dataManager.CreateAverageVersusDepth(parameter)
graphModelAVGVsDepth = dataManager.CreateGraphModel(dataSetAVGVsDepth)
return graphModelAVGVsDepth
def getFolderpathOfOpenedProjectFile():
"""Get the folder path of the currently open jproj file."""
openedJprojFilePath = app.GetProjectPath()
folderPath = os.path.dirname(openedJprojFilePath)
return folderPath
def exportAvgVsDepth(graphModelAVGVsDepth, exportPath):
"""Export the average for each depth."""
graphModelAVGVsDepth.WriteTable(os.path.join(exportPath, u"avgVsDepth.csv"))
study = app.GetCurrentStudy()
probeTitle = u"B-lamination"
probe = createLamiMagFluxDensityProbe(study, probeTitle)
dataManager = app.GetDataManager()
dataSetTitle = u"B-lamination AVG"
param = {
u"title" : dataSetTitle,
u"min" : u"0",
u"max" : u"0.02",
u"rangeUnit" : u"s"
}
graphModelAVGVsDepth = createAvgVsDepth(dataManager, probe, param)
exportPath = getFolderpathOfOpenedProjectFile()
exportAvgVsDepth(graphModelAVGVsDepth, exportPath)


