# 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 setHalbachArrayMagnetizationPattern(study, partName, properties): """Set a Halbach array for the permanent magnet magnetization pattern""" study.SetMaterialByName(partName, properties["material_name"]) material = study.GetMaterial(partName) material.SetOriginXYZ(0, 0, 0) # Reference axis direction material.SetDirectionXYZ(1, 0, 0) material.SetPattern(properties["pattern"]) material.SetValue(u"Poles", properties["poles"]) material.SetValue(u"StartAngle", properties["start_angle"]) material.SetValue(u"DivisionPerPole", properties["division_per_pole"]) material.SetValue(u"StrongSide", properties["strong_side"]) material.SetOrientation(False) # False = Inward partName = u"Rotor/Magnet" magnetProperty = { "material_name": u"Reversible/NdFeB_Br=1.4(T)", "pattern": u"ParallelCircularHalbachArray", "poles": 8, "start_angle": 22.5, "division_per_pole": 5, "strong_side": u"Internal", } app = designer.GetApplication() study = app.GetCurrentStudy() setHalbachArrayMagnetizationPattern(study, partName, magnetProperty)