Overunity.com Archives is Temporarily on Read Mode Only!



Free Energy will change the World - Free Energy will stop Climate Change - Free Energy will give us hope
and we will not surrender until free energy will be enabled all over the world, to power planes, cars, ships and trains.
Free energy will help the poor to become independent of needing expensive fuels.
So all in all Free energy will bring far more peace to the world than any other invention has already brought to the world.
Those beautiful words were written by Stefan Hartmann/Owner/Admin at overunity.com
Unfortunately now, Stefan Hartmann is very ill and He needs our help
Stefan wanted that I have all these massive data to get it back online
even being as ill as Stefan is, he transferred all databases and folders
that without his help, this Forum Archives would have never been published here
so, please, as the Webmaster and Creator of these Archives, I am asking that you help him
by making a donation on the Paypal Button above.
You can visit us or register at my main site at:
Overunity Machines Forum



LUA Script in FEMM 4.2 - please help!:-)

Started by Low-Q, September 08, 2016, 04:46:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Low-Q

Hello,


Some years ago I got great help from someone here who was a racer in LUA scripts. But those scripts I saved in my old computer, which is pretty much out of service now.


I need help to make a script that measure torque of a group made in FEMM 4.2. I have read the FEMM 4.2 manual, but I cannot understand what script to use, or where to put them in right order.


I want to keep the original file, so the script must save the results as another file.


For group 1 with center X0 - Y0, I need 0.8 degree steps starting at 0 degrees, ends at 71.2 degrees (At 72 degrees the result will be the same as 0 degrees)
For group 2 with center X0 - Y1, I need 1 degree steps starting at 0 degrees, ends at 89 degrees (At 90 degrees the result will be the same as 0 degrees)[/size]


Can someone please help? Any help is very much appreciated :-)


Vidar

broli

I used a script that I've used myself a while ago and modified it for your needs, please be aware it's not tested but I think it should give you a decent start :) .
Besides generating data it also generates an image of every simulated step which can later be converted to an animated gif file if you want.

showconsole()
--Defining the variables
dAngle=0.8    -- Increase of angle ( Degrees of rotor rotation by step )
totalDegrees= 72 -- amount of total degrees to roate
X0 = 0
Y0 = 0

open("myfile.fem")
mi_saveas("temp.fem")    -- Temp file for save the original
mi_seteditmode("group")

data = {};
for n=0,((totalDegrees/dAngle)-1) do
    alfa=dAngle*n
    print(alfa) -- print to console for debugging and showing the progress
    --analyze the current rotation and take image
    mi_analyse(1)
    mi_loadsolution()
    mo_showdensityplot(0,0,0.5,0,"mag")        -- Obtain Image
    mo_savebitmap(format("acgen_%1$d.bmp",alfa))  -- Save Image
    --Calculate the torque
    mi_analyse(1)
    mi_loadsolution()
    mo_groupselectblock(1)
    torque = mo_blockintegral(22)
   
    --gather all data
    data[n] = {}
    data[n][1] = alfa
    data[n][2] = torque
    mo_close()
   
    -- write results to disk for further analysis, make sure the file already exist to write the results to
    fp=openfile("results.txt","a")
    write(fp,data[n][1],"\t" .. data[n][2],"\n")
    closefile(fp);
   
    mi_selectgroup(1)            -- Select Rotor group
    mi_move_rotate(X0,Y0,dAngle)        -- Rotate the rotor
end

Low-Q

WOW! I can't thank you enough :)  This is awesome!
Thank you broli!


Vidar

Low-Q

I tried it, and I think it need some minor modifications. I got an error message. Please see attached picture :-)



showconsole()
--Defining the variables
dAngle=0.8    -- Increase of angle ( Degrees of rotor rotation by step )
totalDegrees= 72 -- amount of total degrees to roate
X0 = 0
Y0 = 0


open("GE.FEM")
mi_saveas("GEtemp.FEM")    -- Temp file for save the original
mi_seteditmode("1")


data = {};
for n=0,((totalDegrees/dAngle)-1) do
    alfa=dAngle*n
    print(alfa) -- print to console for debugging and showing the progress
    --analyze the current rotation and take image
    mi_analyse(1)
    mi_loadsolution()
    mo_showdensityplot(0,0,0.5,0,"mag")        -- Obtain Image
    mo_savebitmap(format("acgen_%1$d.bmp",alfa))  -- Save Image
    --Calculate the torque
    mi_analyse(1)
    mi_loadsolution()
    mo_groupselectblock(1)
    torque = mo_blockintegral(22)
   
    --gather all data
    data[n] = {}
    data[n][1] = alfa
    data[n][2] = torque
    mo_close()
   
    -- write results to disk for further analysis, make sure the file already exist to write the results to
    fp=openfile("results.txt","a")
    write(fp,data[n][1],"\t" .. data[n][2],"\n")
    closefile(fp);
   
    mi_selectgroup(1)            -- Select Rotor group
    mi_move_rotate(X0,Y0,dAngle)        -- Rotate the rotor
end

Low-Q

I made a mistake in "group"...at the beginning. It works now - just have to add script for group 2 because these two groups are colliding :D