# 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)