A map for my code

Posted on November 6, 2008

0


Pierre has told me it is difficult to understand my Lua scripts without a better explanation of what each variable means. He expressed a wish for a drawing that maps the variables to the geometry. I agree this is necessary, it just hadn’t been until now because nobody else dared to go into my code! 🙂

Graphically (click to enlarge):

dimensions-map-radial

I will explain the variables present in each file.

  • START_HERE_model_loader.lua: this is the only file you load directly into FEMM. It will load all the others needed do build a model and execute the desired simulations. It is also where the main variables are defined, so you should edit it before using it. This file defines the following important variables (which define the main dimensions of the motor):
    • Ri = minimum inner radius of the motor (absolute limit); In my case, it is just above the radius of the brake drum. Of course, my scripts assume the motor is doughnut-shaped. If you put a zero in here, things will probably break here and there. 😉
    • Ro = maximum outer radius of the motor (absolute limit); In any case, this should be the safe value of the space available inside the wheel rims.
    • Zmax = the maximum depth along the axis of the wheel; typically also a safe maximum value of distance between the interior of the wheel rim and the suspension arm.
    • Hag = Height of air gap between rotor and stator.
    • Occ = Occupation of stator with teeth. I have to find a better name for this one… it means the ratio between the perimeter occupied by stator teeth and the total perimeter of the stator. In other words, (1 – Occ) gives the free space for wire slots.
    • Dpm, Wpm, Hpm = the 3 dimensions of the currently used magnet. My models only use one kind of magnet at a time, and these 3 variables define it’s geometry. D is for Depth (along axis of motor, or perpendicular to the “paper” axis), W is for Width (along the tangent to the motor perimeter), and H is for Height (along the motor radius). These variables are merely initialized in this file, but then changed by a call to “mfl_pick_magnet_material()” which loads the characteristics of a specific magnet from a library (my_femm_lib.lua).
  • model_*_*.lua: these are my motor models. Internally, they combine a stator_*.lua and a rotor_*.lua files to build a complete motor. The model starts out by defining a few variables of its own. These are usually the ones that we play with to define the model.
    • Tst = Thickness of the (non-magnetic) structural plate. The rotors and stator both are composed of two materials: a ferromagnetic core material, and a structural material. The inner rotor has the structural plate on the inside face; the outer rotor has it on the outside; the stator has it right accross the middle of the coils.
    • Nmp_b = Basic number of magnetic poles in rotor (may correspond to 1 or more magnets each). This variable, along with the next one, allow us to express the minimum number of rotor poles and stator teeth and the relationship between them.
    • Nst_b = Basic number of stator teeth.
    • Pmult = Pole multiplier factor. This allows us to scale up the number of poles and teeth in proportion. It is better for efficiency and torque to have as many poles as possible, so you can for example use a factor of 3 to get a 42-pole / 36-teeth motor from a basic model of 14-poles / 12-teeth.
    • Hg = Height (thickness) of glue under magnets. This is a bit of a hack. While it is justifiable as a real project variable, it was born out of my need to compensate for small accumulated errors in magnet placement – which make the corners/faces of the magnets sometimes cross the rotor circles in an almost indetectable infinitesimal amount… 😦 Some models use this, some don’t.
    • Hst = Total height of a stator tooth.
  • At some point I started playing around with “hammerheads”: little extensions of the stator teeth at the air gap to help directing the flux. But I’m not sure it helps at all… anyway, some models may use this.
    • Hsf = Height of the stator tooth inner/outer hammerhead.
    • Whh = Stator pole Hammerhead width, expressed in coefficient relative to pole width.
  • The model file knows how to combine the stator and rotor and create their respective dimensions (and enforce dimension sanity towards the limits defined by the user), and this is all done inside the function “model_refresh_geometric_data()“. This is the most critical function I have in there; if it fails, the model fails to be built. The variables calculated here are dependent upon the other globals already defined by the user, and are supposed to be safely recalculated everytime the user changes those globals.
    • Nmp, Nst = Effective number of magnetic poles and stator teeth (remember the Pmult?);
    • Rs = Stator radius. This is the distance from the centre at which the stator will be placed. It marks the place of the structural plate of the stator, which is where the coil cores are fixed at their middle.
    • Npmpp = Number of permanent magnets per pole. Since we are trying to use several magnet options, it is possible that one magnetic pole is made of more than one magnet.
    • Npm= Total number of used magnets. For financial estimate only. Don’t confuse this variable with Nmp! 😉
    • Wmp = Width (in tangent direction) of a magnetic pole (constructed with one or more magnets).
  • And here comes the really confusing part. As you may have noticed, I’m using magnets with simple block (parallelipiped) shapes, which yield a rectangular cross-section, and attaching them to a curved surface on the rotors. Obviously, this is not a perfect match. On the outside rotor, the magnets only touch the rotor at the corners; on the inside rotor, the magnets only touch the rotor at the middle of their face. To deal with this fact, I created a “bulge” quantity. I normally do the calculations as if the magnets would fit perfectly to the curved surface, and then move them out or in a little (the “bulge” dimension) to get them to touch the rotor face in the right spot. Unfortunately, this math is not perfect yet, and sometimes the model will not simulate (depending on magnet and motor dimensions).
    • Bipm= Inner rotor magnet bulge. The radius at which each magnet centre is placed has to be extended a little bit to account for inner rotor curvature. This is the amount of radius delta that is used to do that.
    • Ripm = Radius at which the magnet centres are placed, for the inner rotor.
    • Rir = Radius at which the inner rotor magnetic core ends (and the magnets start).
    • Ropm = Radius at which the magnet centres are placed, for the outer rotor.
    • Bopm = Outer rotor magnet bulge. Same logic as before, but this time the delta is used to retract the magnets towards the inside, so that the corners touch the rotor face.
    • Ror = Radius at which the outer rotor magnetic core ends (and the magnets start).

There. It isn’t everything, but it is enough for anyone to get started. Now hack it up! 🙂

Advertisements
Posted in: Motorfemmulator