-------------------------------------------- -- LRK Motor Flux Linkage Analysis Script -- -- edie_currants@yahoo.com -- -- October 19, 2004 -- -------------------------------------------- -- Note: Requires FEMM 4.0 -- load geometry mydir="./" open(mydir .. "lrk.fem") -- and save as a temporary file name so we don't -- ovewrite the original geometry mi_saveas(mydir .. "temp.fem") -- make sure that the currents are zeroed out -- we just want flux linkage due to the magnets mi_modifycircprop("A",1,0); mi_modifycircprop("A",2,0); mi_modifycircprop("B",1,0); mi_modifycircprop("B",2,0); mi_modifycircprop("C",1,0); mi_modifycircprop("C",2,0); -- show the Lua console window so that we can see the -- program report its progress showconsole() -- move the rotor through one pole pitch in small -- increments, recording the flux linkage of each -- phase at each rotor position data = {}; steps = 60; for k = 1,(steps+1) do print((k-1) .. "/" .. steps); mi_analyze(1); mi_loadsolution(); data[k]={}; data[k][1] = (k-1)*360/14/steps; -- collect the flux linkage for each phase v1,v2,v3,v4,data[k][2] = mo_getcircuitproperties("A"); v1,v2,v3,v4,data[k][3] = mo_getcircuitproperties("B"); v1,v2,v3,v4,data[k][4] = mo_getcircuitproperties("C"); -- compute the cogging torque mo_groupselectblock(2); data[k][5] = mo_blockintegral(22); -- increment the rotor's position mi_selectgroup(2); mi_moverotate(0, 0, 360/14/steps, 4); mi_clearselected(); end -- write results to disk for further analysis. fp=openfile(mydir .. "flux-results.txt","w") for k = 1,(steps+1) do write(fp,data[k][1]," ",data[k][2]," ",data[k][3]," ",data[k][4]," ",data[k][5],"\n") end closefile(fp);