3D Magnetics With Elmer FEM

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7
At a glance
Powered by AI
The key takeaways are that FreeCAD is used to create the geometry, Salome is used for meshing, ElmerGrid converts the mesh for use in Elmer FEM simulations, and Paraview is used for viewing results. Multiple programs are involved in the full modeling workflow.

The geometry being modeled is a simple cylindrical bar magnet that is 20mm in diameter and 50mm long placed inside a larger cube-shaped box of air to approximate an infinite space around the magnet.

The programs used in the modeling process are FreeCAD for geometry creation, Salome for meshing, ElmerGrid for converting the mesh format, Elmer FEM for solving, and Paraview for viewing results. Scripting can help automate tasks between the different programs.

3D Magnetostatics With ElmerFEM

Richard Crozier
July 20, 2016

Contents
1 Introduction 1

2 Cylindrical Magnet in Air 2


2.1 Creating the Geometry in FreeCAD . . . . . . . . . . . . . . . . 2
2.2 Meshing the Geometry in Salome . . . . . . . . . . . . . . . . . . 5
2.3 Converting Mesh for Elmer . . . . . . . . . . . . . . . . . . . . . 6
2.4 Creating the Case File for Elmer and Solving It . . . . . . . . . . 6
2.5 Viewing the Results in Paraview . . . . . . . . . . . . . . . . . . 6

3 A Current Carrying Coil in Air 7

4 Flux Linkage and Mutual Inductance In a Pair of Iron Cored


Coils 7

5 A Permanent Magnet Machine With Symmetry 7

6 Permanent Magnet Machine With Sliding Air Gap Mesh 7

1 Introduction
This tutorial describes the full steps to go from nothing to a 3D magnetic
simulation using Elmer FEM. This is done in the the following steps:

1. Geometry Creation in FreeCAD


2. Meshing in Salome (or Salome Meca)
3. Converting mesh for Elmer
4. Creating the case file for Elmer and solving it

5. Viewing the results in Paraview

As can be seen, unfortunately quite a few different programs are involved,


at least to do the various steps manually. Once you get a grip of each step,
however, many tasks can implemented in python or scripted to automate them,
making the process a bit smoother.

1
2 Cylindrical Magnet in Air
The first problem we are going to solve is that of a simple cylindrical bar magnet
in free space that looks like this:

The magnet will be 20mm in diameter, 50mm long and will be magnetised
along it’s axis. To model this, we will place it in a box of air, to approximate
the infinite space region around the magnet.

2.1 Creating the Geometry in FreeCAD


[url=http://www.freecadweb.org/]FreeCAD[/url] is a powerful free and open
source parametric modelling program based on the industrial grade OpenCAS-
CADE geometry modelling kernel. We could create the geometry diectly in
Salome if we wanted, but for anything other than very simple object FreeCAD
makes life much easier. Our geometry in this case is very simple, a small cylinder
inside a box. Start FreeCAD, and create a new model with File=¿New.
Activate the ’Part’ module by choosing from the drop-down menu.

2
This adds some tools to the toolbar. We can create a cylinder by clicking
on the little yellow cylinder icon. This creates a cylinder with default sizes. We
will change the size by selecting the cylinder and going modifying properties on
it’s ’Data’ tab:

This should leave us with something like the following, a cylider with one
face on the XY plane and it’s centre on the origin.

3
Now we need to make a box of air to put the cylinder into, do this by
selecting the ’Create a cube solid’ tool. This creates a new cuboid with one face
on the XY plane, and one corner on the origin, with default dimensions. Set
the Length, Width, and Height to all be 100mm using the Data tab for the box
in the same way as was done for the cylinder. Then, expand the ’Placement’
property, also in the Data tab, and then expand the ’Postiion’ property. Change
the ’x’ and ’y’ position to both be -50mm, and the ’z’ position to be -25mm.
This makes the box fully overlap our magnet.

Now we can’t see the cylinder any more as it overlaps the box. To make
everything easier to see, make the box transparent by going to it’s ’View’ tab.
Scroll down to the ’Transparency’ property and change to 75. You will now be
able to see the magnet inside the box.

4
This is our geometry complete. With our geometry created, we now have
to mesh it. This will be done in another program, Salome, and to get it into
this we must first export the geometry to a format Salome can import, in this
case STEP. To export the objects to a STEP file, simply select both object in
the model browser and then choose File=¿Export and choose the ’STEP with
colors’ file type. The advantage of STEP is that the model units of FreeCAD,
which are mm by default are saved in the file, and can be correctly imported by
Salome when we load it again.

2.2 Meshing the Geometry in Salome


1) load the objects from file
2) select both solids and execute partition
3) select the Partition, explode to solid
4) go to mesh module, build a mesh on the partition
then apply different rules on the solid-meshes: 5) select the partitions mesh,
create subMesh, Geometry: select an exploded solid of the partition Do this
for all solids special rules are wished for 6) change submesh priority, sort in the
desired sequence (e.g. the finer mesh above the coarser ones, this enforces the
finer rules to be applied on the interface)
create mesh groups and export
7) select the new mesh ¿ create Groups from geometry and select the from
the exploded solids of the partition -¿ in the mesh there now exists a sibling
groups of volumes 8) rename the groups to something sensible we can use later
in Elmer 9) select the mesh, rightclick, export mesh to e.g. UNV file for Elmer
FEM

5
2.3 Converting Mesh for Elmer
Elmer doesn’t natively support the unv mesh format, but we can use ElmerGrid
to convert the unv file to Elmer’s mesh format. Elmer’s mesh format is not a
single file, but rather a directory containing a collection of files. The command
to convert a unv file to Elmer’s format is:
ElmerGrid 8 2 < file name >. unv

The first number is the input file format, the second is the output file format,
and these are followed by the name of the file to be converted. So in our case
we run
ElmerGrid 8 2 e l m e r _ 3 d _ m a g n e t _ m e s h . unv

There should now be a new directory created called elmer_3d_magnet_mesh


containing the files mesh.boundary, mesh.elements mesh.header, mesh.names
and mesh.nodes. The file mesh.names is useful to us, as it contains the names
we assigned earlier to the groups of volumes and faces, the contents of the file
in our case looks like this:
! ----- names for bodies -----
$ magnet = 1
$ air_box = 3
! ----- names for boundaries -----
$ a ir _ bo x_ su r fa ce = 4
$ bnry5 = 5

By setting the appropriate variables in our Elmer case file, we can use these
names instead of having to figure out what numbers have been assigned to the
mesh groups.

2.4 Creating the Case File for Elmer and Solving It


2.5 Viewing the Results in Paraview
1) Open the output (vtu) file
2) Apply Glyph filter choose magnetic flux density turn off vector scaling
color by flux density
Viewing mesh cross-section
Clipping

6
3 A Current Carrying Coil in Air
4 Flux Linkage and Mutual Inductance In a Pair
of Iron Cored Coils
5 A Permanent Magnet Machine With Symme-
try
6 Permanent Magnet Machine With Sliding Air
Gap Mesh

You might also like