If there is a periodicity in a magnetic field analysis, a partial model is usually used to reduce the model size periodic boundary conditions. In a 2D model, this condition needs to be set to edges. This script does not apply the application individually by ID, but instead selects all edges on the X-axis (>=0), which is common in modeling rotational periodicity.
Preconditions
- One or more magnetic field analysis studies must be created for the 2D model.
This script is run for the first study of the first model in the project tree. - The units of the setting values follow the unit system set for the model.
Script Function
- Create an Edge Set to select all edges on the X-axis (>=0) and use On Half Plane type.
- Set the coordinate system to the Z-X-Y and select secondary axis direction as range of half plane, then the X-axis (x>=0) on the ZX plane has been set.
- Create periodic boundary conditions and apply them to the previously created Edge Set.
- Other parameters for the periodic boundary conditions in this example are: periodicity is set to antiperiodic, the periodic angle is set to 90, and the center of rotation is set to the origin.
# 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 createEdgeSet(targetmodel):
"""Create a set of edges on the XZ plane where x>=0"""
setList = targetmodel.GetSetList()
pbedgeSet = setList.CreateEdgeSet(u"PeriodicBoundary")
pbedgeSet.SetUpdateByRelation(False)
pbedgeSet.SetMatcherType(u"OnHalfPlane") # "OnHalfPlane":On Half Plane
pbedgeSet.SetParameter(u"axis_type", 1)
# The 2nd argumet of SetCoordinateSystem
# 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
pbedgeSet.SetCoordinateSystem(u"coordinate", 3)
#pbedgeSet.SetCoordinateSystem(u"coordinate", u"Local Rectangular (Z-X-Y)")
pbedgeSet.SetParameter(u"tolerance", 1e-06)
pbedgeSet.Rebuild()
return pbedgeSet
def createPeriodicBoundary(targetStudy, targetEdgeEntities):
"""Creates a periodic boundary condition to the edge set passed as the 2nd argument"""
pdcond = targetStudy.CreateCondition(u"RotationPeriodicBoundary", u"pd")
pdcond.ClearParts()
pdcond.AddSet(targetEdgeEntities, 0)
pdcond.SetValue(u"BoundaryType", u"Reverse")
pdcond.SetValue(u"Angle", 90)
pdcond.SetXYZPoint(u"Origin", 0, 0, 0)
app = designer.GetApplication()
model = app.GetModel(0)
edgeEntities = createEdgeSet(model)
study = model.GetStudy(0)
createPeriodicBoundary(study, edgeEntities)


