Material settings for magnetic field analysis consist of two steps: setting the material’s properties and assigning it to parts in the analysis model (part properties). The assignment setting parameters vary depending on the material’s properties. This script sets the orientation magnetization pattern to a parallel pattern (circular any direction) in the properties of parts to which a magnetization material is assigned.
Preconditions
- One or more magnetic field analysis studies have been created.
This script is run for the active study in the project tree. - A reference target for specifying the magnetization direction has been set, and its title is known.
- The part to be set is a part group, a magnetization material has been assigned, and the part group title is known.
Script Function
- Set the magnetization pattern of the part group “magnetization” to a parallel pattern (circular any direction).
- Set “Magnet Edge” as the reference target that determines the magnetization direction.
- Other parameters in this example are: pattern division is set to 8 and an angle from reference axis is set to 22.5.
# 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 setParallelPatternToMagnetizationMaterial(study, partGroup, referenceTarget):
"""Change the magnetization pattern of the magnetized material's orientation direction"""
for partId in partGroup.GetPartIDs():
material = study.GetMaterial(partId)
material.SetPatternReferenceTarget(referenceTarget)
material.SetPattern(u"ParallelCircularAnyDirection") # "ParallelCircularAnyDirection":Parallel pattern (circular any direction)
material.SetValue(u"Poles", 8)
material.SetValue(u"StartAngle", 22.5)
app = designer.GetApplication()
model = app.GetCurrentModel()
study = app.GetCurrentStudy()
partGroup = model.GetGroupList().GetGroup("magnetization")
referenceTarget = model.GetReferenceTargetList().GetReferenceTarget("Magnet_Edge")
setParallelPatternToMagnetizationMaterial(study, partGroup, referenceTarget)


