2 Lua Scripts
2 Lua Scripts
and ect..
27.04.2018
Outline
• Lua scripting
• Border conditions
• About torque and force calculation in
Femm
Lua scripts
• in Lua:
• Comments we can put
after '--'
• Line is ended only by the
'enter'
• Variables are defined by
giving them a value
• mi_analyze()
– runs calculations
• mi_loadsolution()
– load ans display results for model
• mo_savebitmap(nazwa)
– save results as a bitmap
• mo_groupselectblock(1)
– select block number 1
commands ...
• fx=mo_blockintegral(18)
– perform integral calculations for the selected
block. The type of calculated value depends on
the parameter. Here, parameter 18 means: „x
(or r) part of steady-state weighted stress
tensor force” For others meanings: page 94 in
„manual.pdf”
• c,V,Fl = mo_getcircuitproperties("circ_1")
– returns values connected to electrical circuit
by the given name:
c – current, V – voltage drop, Fl – flux linkage
Commands ….
• mi_seteditmode("group")
– Sets the edit mode to “group” as it is in
Femm program (it could be also: "nodes",
"segments", "arcsegments", "blocks",
"group")
• mi_selectgroup(1)
– select group number 1
• mi_movetranslate(step,0)
– Move active element or group by the vector
(here the vector is (step,0))
Commands ...
• mi_moverotate(0,0,step_ang,4)
– Turn selected group by the angle (here: 'step_ang') about point
(here: (0,0)). Value 4 here means that command operates on groups
• closefile(outfile)
– Close the file where results was saved
• mo_showdensityplot(legend,gscale,upper_B,lower_B,type)
– Shows the flux density plot with options:
• legend set to 0 to hide the plot legend or 1 to show the plot legend
• gscale set to 0 for a colour density plot or 1 for a grey scale density plot.
• upper_B sets the upper display limit for the density plot.
• lower_B sets the lower display limit for the density plot.
• type - type of density plot to display. Valid entries are "bmag", "breal",
and "bimag" for magnitude, real component, and imaginary component
of flux density (B), respectively; "hmag", "hreal", and "himag" for
magnitude, real component, and imaginary component of field intensity
(H); and "jmag", "jreal", and "jimag" for magnitude, real component,
and imaginary component of current density (J).
Border conditions
• Dirichlet:
In this type of boundary condition, the
value of potential A or V is explicitly
defined on the boundary, e.g. A = 0. The
most common use of Dirichlet-type
boundary conditions in magnetic problems
is to define A = 0 along a boundary to
keep magnetic flux from crossing the
boundary. In electrostatic problems,
Dirichlet conditions are used to fix the
voltage of a surface in the problem
domain.
Border conditions ...
• Neumann:
This boundary condition specifies the
normal derivative of potential along the
boundary. In magnetic problems, the
homogeneous Neumann boundary
condition, ∂A/∂n =0 is defined along a
boundary to force flux to pass the
boundary at exactly a 90o angle to the
boundary. This sort of boundary condition
simulates an interface with a very high
permeable metal.
Border conditions ...
• Robin:
The Robin boundary condition is sort of a mix
between Dirichlet and Neumann prescribing a
relationship between the value of A and its normal
derivative at the boundary. An example of this
boundary condition is:
∂A
+cA=0
∂n
– This boundary condition is most often in FEMM to define
“impedance boundary conditions” that allow a bounded
domain to mimic the behavior of an unbounded region.
In the context of heat flow problems, this boundary
condition can be interpreted as a convection boundary
condition. It means the setting the rate of spatial
change of temperature just near the border which is
depending on the temperature difference between the
surface and the environment.
Border conditions ...
Periodic,
• A periodic boundary conditions joins two
boundaries together. In this type of
boundary condition, the boundary values
on corresponding points of the two
boundaries are set equal to one another.
Border conditions ...
Antiperiodic
• The antiperiodic boundary condition also
joins together two boundaries. However,
the boundary values are made to be of
equal magnitude but opposite sign.
Using the BC
• Lorentz Force/Torque
If we want to compute the force on a collection of
currents in a region containing only materials with a unit
relative permeability, the volume integral of Lorentz
torque is always the method to employ. Lorentz force
results tend to be very accurate. However, again, they
are only applicable for the forces on conductors of with
unit permeability (e.g. coils in a voice coil actuator).
F = B*I*l*sin(α)
Force calculating
• Default value is 0.
• If we put another value ALL field values
will alternate with this frequency
• Therefore mixing problems with permanent
magnet and frequency given do not lead to
the sensible results
Eddy currents