Cookies-law

Cookies help us to bring you our services at overunity.com . If you use this website and our services you declare yourself okay with using cookies .More Infos here:
http://www.overunity.com/5553/privacy-policy/
If you do not agree with storing cookies, please leave this website now. Many thanks for your understanding.
Amazon Warehouse Deals ! Now even more Deep Discounts ! Check out these great prices on slightly used or just opened once only items.I always buy my gadgets via these great Warehouse deals ! Highly recommended ! Many thanks for supporting OverUnity.com this way.

FireMatch

FireMatch

CCKnife

CCKnife

Poplamp

poplamp

CCTool

CCTool

LEDTVforSale

Magpi Magazine

Magpi Magazine Free Rasberry Pi Magazine

Battery Recondition

Battery Recondition

OverUnity Book

overunity principles book

Arduino

Ultracaps

YT Subscribe

Gravity Machines

Tesla-Ebook

Magnet Secrets

Lindemann Video

Navigation

Products

Statistics


  • *Total Posts: 493088
  • *Total Topics: 14500
  • *Online Today: 44
  • *Most Online: 103
(December 19, 2006, 11:27:19 PM)
  • *Users: 1
  • *Guests: 72
  • *Total: 73

Facebook

Author Topic: LUA Script in FEMM 4.2 - please help!:-)  (Read 2343 times)

Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2532
LUA Script in FEMM 4.2 - please help!:-)
« on: September 08, 2016, 10:46:36 PM »
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

Free Energy | searching for free energy and discussing free energy


Offline broli

  • Hero Member
  • *****
  • Posts: 2170
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #1 on: September 08, 2016, 11:05:26 PM »
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


Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2532
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #2 on: September 08, 2016, 11:40:02 PM »
WOW! I can't thank you enough :)  This is awesome!
Thank you broli!


Vidar

Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2532
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #3 on: September 08, 2016, 11:55:41 PM »
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


Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2532
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #4 on: September 09, 2016, 12:05:05 AM »
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

Free Energy | searching for free energy and discussing free energy

Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #4 on: September 09, 2016, 12:05:05 AM »
Sponsored links:




Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2532
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #5 on: September 09, 2016, 12:50:18 AM »
Can I just copy the script twice in the same LUA?


I want both groups to rotate in the same script. I have tried just to add the script once more, under the first one, and changed group number, XY points etc, but got errors...


Vidar

Offline broli

  • Hero Member
  • *****
  • Posts: 2170
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #6 on: September 09, 2016, 08:46:26 AM »
Since it's the same amount of steps just different increments you can keep it in the same for loop and try something like this (I highlighted the changes):

showconsole()
--Defining the variables
dAngle1=0.8    -- Increase of angle for group 1 ( Degrees of rotor rotation by step )
dAngle2=1.0    -- Increase of angle for group 2 ( 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("group")


data = {};
for n=0,((totalDegrees/dAngle1)-1) do
    alfa=dAngle1*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);
    -- rotate group 1
    mi_selectgroup(1)            -- Select Rotor group 1
    mi_move_rotate(X0,Y0,dAngle1)        -- Rotate the rotor
    -- rotate group 2
    mi_selectgroup(2)            -- Select Rotor group 2
    mi_move_rotate(X0,Y0,dAngle2)        -- Rotate the rotor

end

Free Energy | searching for free energy and discussing free energy

Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #6 on: September 09, 2016, 08:46:26 AM »
Sponsored links:




Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2532
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #7 on: September 09, 2016, 01:15:59 PM »
Thanks again broli! This is really helpful :D


Can I put in additional line:
X1 = 0
Y1 = -1


and change:
mi_move_rotate(X0,Y0,dAngle2) to mi_move_rotate(X1,Y1,dAngle2)?


If I want to rotate group 2 90 degrees instead, can I add:
dAngle1=0.8    -- Increase of angle for group 1 ( Degrees of rotor rotation by step )
dAngle2=1.0    -- Increase of angle for group 2 ( Degrees of rotor rotation by step )
totalDegrees= 72 -- amount of total degrees to roate
totalDegrees= 90 -- amount of total degrees to roate???[/size]


Vidar

Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2532
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #8 on: September 09, 2016, 02:08:23 PM »
Ofcourse - when outer rotor turns 72 degrees the inner rotor turns 90 by itself. Didn't think of that.


Now it all works as I want it to. Thank you!!!!!


Vidar

 

Share this topic to your favourite Social and Bookmark site

Please SHARE this topic at: