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.

DC2DC converter

Micro JouleThief

FireMatch

FireMatch

CCKnife

CCKnife

CCTool

CCTool

Magpi Magazine

Magpi Magazine Free Rasberry Pi Magazine

Battery Recondition

Battery Recondition

Arduino

Ultracaps

YT Subscribe

Gravity Machines

Tesla-Ebook

Magnet Secrets

Lindemann Video

Navigation

Products

Statistics


  • *Total Posts: 498475
  • *Total Topics: 14679
  • *Online Today: 44
  • *Most Online: 103
(December 19, 2006, 11:27:19 PM)
  • *Users: 9
  • *Guests: 176
  • *Total: 185

Facebook

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

Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2564
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: 2169
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: 2564
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: 2564
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: 2564
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: 2564
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: 2169
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: 2564
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: 2564
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

Offline Apoc4lypse

  • Newbie
  • *
  • Posts: 6
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #9 on: April 20, 2018, 07:11:21 PM »
I know this is an old topic, but I don't know where else to ask really. I searched around google to find this script, I'm using femm 4.2 and am also trying to get femm to rotate a couple groups of objects and output the torque values, or at least output the .ans files so I can just go look at the torque myself. Rotating everything the few degrees I need and analyzing each individually until I get to 360 takes forever.

I tried the script above but keep getting

"error: No current magnetics input in focus"
stack traceback:

1: function 'mi_saveas' [C]
2: main of string "'showconsole()..." at line 10

Yes I also made a boundary around everything and I can analyze it normally with no problems.
Yes I also gave a group value to the group I want to rotate that is the same as the group value specified in the script.

Also, in the file names, where are the files supposed to be placed? Where does FEMM end up looking for them? What folder? The installed folder? what if I installed it in a different location should I specify the entire path?

Free Energy | searching for free energy and discussing free energy

Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #9 on: April 20, 2018, 07:11:21 PM »
Sponsored links:




Offline Low-Q

  • without_ads
  • Hero Member
  • *****
  • Posts: 2564
Re: LUA Script in FEMM 4.2 - please help!:-)
« Reply #10 on: April 20, 2018, 10:12:11 PM »

Hi there.


The lua script might refer to groups. If your model consist of different parts, say the rotor have more than one part, you must mark every line, arch, points, material, press Space and then name them all as group 1.


If the script, which you can edit in notepad, refer to grpup 2 or other than 1, you will get an error.


If the rotors symmetry consists of several equal magnets, for example 6 of them in a circle, you need to simulate only 60 degrees rotation, because the next 60 degrees will give you the same output. No need for 360 degrees samples.


Vidar

I know this is an old topic, but I don't know where else to ask really. I searched around google to find this script, I'm using femm 4.2 and am also trying to get femm to rotate a couple groups of objects and output the torque values, or at least output the .ans files so I can just go look at the torque myself. Rotating everything the few degrees I need and analyzing each individually until I get to 360 takes forever.

I tried the script above but keep getting

"error: No current magnetics input in focus"
stack traceback:

1: function 'mi_saveas' [C]
2: main of string "'showconsole()..." at line 10

Yes I also made a boundary around everything and I can analyze it normally with no problems.
Yes I also gave a group value to the group I want to rotate that is the same as the group value specified in the script.

Also, in the file names, where are the files supposed to be placed? Where does FEMM end up looking for them? What folder? The installed folder? what if I installed it in a different location should I specify the entire path?

 

Share this topic to your favourite Social and Bookmark site

Please SHARE this topic at:


OneLink