-- Creates a new preprocessor document (magnetics problem) newdocument(0) -- Main problem parameters -- 0 frequency -- mm units -- planar problem -- solver precision -- depth, set to 1 m so to have results per m length mi_probdef(0, "millimeters", "planar", 1e-8, 1000) -- A few variables w_coil = 99 h_coil = 22 x_bck = 800 y_bck = 400 workfolder = "C:\\temp\\" filename = "dipole" -- Current and number of turns per coil block -- Current at lowest rigidity -- current = 110 -- Current at higest rigidity current = 450 turns = 18 -- Mesh parameters mshf = 1 msh_yoke = 5*mshf msh_coil = 5*mshf msh_gap = 1*mshf msh_bck = 20*mshf -- Material properties, from the available library mi_getmaterial("Air") mi_getmaterial("Pure Iron") mi_getmaterial("Copper") -- Boundary conditions mi_addboundprop("B parallel", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) mi_addboundprop("B perpendicular", 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0) -- A circuit, multiple ones are possible mi_addcircprop("Coil", current, 1) -- Yoke (array of points, for convenience) x_yoke, y_yoke = { }, { } x_yoke[1], y_yoke[1] = 0, 25 x_yoke[2], y_yoke[2] = 71, 25 x_yoke[3], y_yoke[3] = 71, 24.2 x_yoke[4], y_yoke[4] = 90, 24.2 x_yoke[5], y_yoke[5] = 105, 60 x_yoke[6], y_yoke[6] = 105, 295 x_yoke[7], y_yoke[7] = 55, 345 x_yoke[8], y_yoke[8] = -409, 345 x_yoke[9], y_yoke[9] = -459, 295 x_yoke[10], y_yoke[10] = -459, 0 x_yoke[11], y_yoke[11] = -249, 0 x_yoke[12], y_yoke[12] = -249, 127 x_yoke[13], y_yoke[13] = -105, 127 x_yoke[14], y_yoke[14] = -105, 60 x_yoke[15], y_yoke[15] = -90, 24.2 x_yoke[16], y_yoke[16] = -71, 24.2 x_yoke[17], y_yoke[17] = -71, 25 x_yoke[18], y_yoke[18] = 0, 25 np_yoke = getn(x_yoke) for ip_yoke = 1, np_yoke do mi_addnode(x_yoke[ip_yoke], y_yoke[ip_yoke]) end for ip_yoke = 1, np_yoke-1 do mi_addsegment(x_yoke[ip_yoke], y_yoke[ip_yoke], x_yoke[ip_yoke+1], y_yoke[ip_yoke+1]) end mi_addsegment(x_yoke[np_yoke], y_yoke[np_yoke], x_yoke[1], y_yoke[1]) -- Block label, assign material, properties, mesh size mi_addblocklabel(0, 150) mi_selectlabel(0, 150) mi_setblockprop("Pure Iron", 0, msh_yoke) mi_clearselected() -- Coil inner bottom mi_addnode (-110, 46) mi_addnode (-209, 46) mi_addnode (-209, 68) mi_addnode (-110, 68) mi_addnode (-110, 46) mi_addsegment (-110, 46, -209, 46) mi_addsegment (-209, 46, -209, 68) mi_addsegment (-209, 68, -110, 68) mi_addsegment (-110, 68, -110, 46) mi_addblocklabel (-159.5, 57) mi_selectlabel (-159.5, 57) mi_setblockprop("Copper", 0, msh_coil, "Coil", 0, 0, turns) -- Coil block copies mi_selectrectangle (-209, 46, -110, 68, 4) mi_copytranslate (0, 27, 2, 4) mi_selectrectangle (-209, 46, -110, 122, 4) mi_copytranslate (336, 0, 1, 4) -- change sign of current on one side mi_selectrectangle(127, 100-2*(h_coil+5), 127+w_coil, 100+h_coil, 2) mi_setblockprop("Copper", 0, msh_coil, "Coil", 0, 0, -turns) mi_clearselected() -- Air region (background and gap) mi_addnode(0, 0) mi_addnode(130, 0) mi_addnode(-130, 0) mi_addsegment(130, 0, x_yoke[4], y_yoke[4]) mi_addsegment(-130, 0, x_yoke[15], y_yoke[15]) -- mi_addnode(-500, 0) mi_addnode(x_bck, 0) mi_addnode(x_bck, y_bck) mi_addnode(-500, y_bck) mi_addsegment(-500, 0, x_bck, 0) mi_addsegment(x_bck, 0, x_bck, y_bck) mi_addsegment(x_bck, y_bck, -500, y_bck) mi_addsegment(-x_bck, y_bck, -500, 0) -- mi_addblocklabel(0, 10) mi_selectlabel(0, 10) mi_setblockprop("Air", 0, msh_gap) mi_clearselected() -- mi_addblocklabel(150, 150) mi_selectlabel(150, 150) mi_setblockprop("Air", 0, msh_bck) mi_clearselected() -- mi_addblocklabel(-150, 20) mi_selectlabel(-150, 20) mi_setblockprop("Air", 0, 8*msh_gap) mi_clearselected() -- hide lines in post-processor mi_selectsegment((130+x_yoke[4])/2, y_yoke[4]/2) mi_selectsegment((-130+x_yoke[15])/2, y_yoke[15]/2) mi_setsegmentprop("", 0, 1, 1) mi_clearselected() -- Boundary conditions on segments mi_selectrectangle(-500, 0, x_bck, 0, 1) mi_setsegmentprop("B perpendicular") mi_clearselected() mi_selectsegment(x_bck, y_bck/2) mi_selectsegment((x_bck-500)/2, y_bck) mi_selectsegment(-500, y_bck/2) mi_setsegmentprop("B parallel") mi_clearselected() -- Zoom out mi_zoomnatural() -- Save mi_saveas("C:\Users\jbauche\cernbox\WINDOWS\Desktop\Connaissance\JAI Hilary courses\C-shape_dipole_solution_FEMM.fem") -- Mesh mi_createmesh() -- Solve mi_analyze() -- Post-processing mi_loadsolution()