Some tips for 2D electrical machine computation

Numerical methods and mathematical models of Elmer
Post Reply
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Some tips for 2D electrical machine computation

Post by raback »

Hi

There are many people using Elmer nowadays for modeling 2D electrical machines. One good starting point here is the great tutorial by Pavel Ponomarev.
https://www.researchgate.net/publicatio ... e_Tutorial

Since those years many things have evolved. The examples should be working since we try to honor backward compatibility but there are some things that can be done also a little differently, usually faster. Here are some random tips:
  • There is a modernized version of assembly routine in MagnetoDynamics2D that works for most features. It saves a little time in assmebly of linear systems. You can try to change it by simple saying in Solver section "Handle Assembly = Logical True".
  • Symmetry conditions are usually done with "Mortar BC = Integer" + "(Anti) Radial Projector = True". This adds constraint for the system matrix increasint its size and making it more difficult to solve. You can also use elimination if, and only if, the matrix is conforming. The instead of mortar bc use "Conforing BC = Integer" and in Solver section add "Apply Conforming BCs = True". You should see less linear system iterations if succesfull. For direct solver the effect is marginal. But this could be the feature that makes the iterative solvers beat the direct ones.
  • The rotation is usually done with RigidMeshMapper. This is perfectly fine and gives best visualization as the mesh is really rotating. However, there is the possibility that you also add to the rotational boundary the same keyword "Mesh Rotate 3" and can comment it out for the RigidMeshMapper. The good thing with this is that the actual mesh is no longer being rotated, just the temporal interface mesh, so you don't have to rotate the permanent magnets as they have constant orientation. Using MATC to rotate the magnets can really kill your performce. This is the easiest way to get rid of those MATC declarations and doesn't even involve coding. Also without the magnets it could be a little faster.
These changes should not affect the results, only computation time and maybe robustness. It would be interesting to here the affect of these small changes. There are many other things in the pipeline. But these are some that should be quite mature.

Would there be interest in forming some kind of special interest group for people studying these machines? This will be one focus area of Elmer also in coming years.

-Peter
MartinHoeijmakers
Posts: 37
Joined: 22 Oct 2017, 21:03
Antispam: Yes

Re: Some tips for 2D electrical machine computation

Post by MartinHoeijmakers »

Hi Peter,

I think Elmer is extremely good software, but it takes some time to learn how to handle it. Personally, I learned a lot from the tutorials by Pavel Ponomarev. However, I have seen that it is sometimes also necessary to look into the source code and to keep an eye on the developments by looking at Discord daily (so, I saw the variable resistor in circuits :-)). Perhaps a special interest group might indeed help users to learn faster, which may also results into more users for Elmer.

I have tried the first tip ("Handle Assembly = Logical True") and it gave an improvement in speed of about 3% in my case.

The second tip didn't work (yet).
I model only a part of the machine and use anti-periodic boundaries. I use a separate mesh for rotor and stator. Typically, I used for the boundaries something like (there are more radial boundaries)

Code: Select all

Solver 3
  Equation = MagnetoDynamics2D
  Procedure = "MagnetoDynamics2D" "MagnetoDynamics2D"
  Mortar BCs additive = True
  Handle Assembly = Logical True
  .....
  
Boundary Condition 12
  Name = bdryStatorYokeCW
  Mortar BC = Integer 13
  Mortar BC Static = Logical True
  Anti Radial Projector = Logical True
  Galerkin Projector = Logical True
End
Boundary Condition 13
  Name = bdryStatorYokeCCW
End

Boundary Condition 10
  Name = slidingBdryStator
  Mortar BC = Integer 15
  Anti Rotational Projector = Logical True
  Galerkin Projector = Logical True
End
Boundary Condition 15
  Name = slidingBdryRotor
End
This seems to give good results, but I don't know if this is optimal.

Trying to follow your second tip, I changed above lines into

Code: Select all

Solver 3
  Equation = MagnetoDynamics2D
  Procedure = "MagnetoDynamics2D" "MagnetoDynamics2D"
  Mortar BCs additive = True
  Apply Conforming BCs = True
  Handle Assembly = Logical True

Boundary Condition 12
  Name = bdryStatorYokeCW
  Conforming BC = Integer 13
  Anti Radial Projector = Logical True
  Galerkin Projector = Logical True
End
Boundary Condition 13
  Name = bdryStatorYokeCCW
End

Boundary Condition 10
  Name = slidingBdryStator
  Mortar BC = Integer 15
  Anti Rotational Projector = Logical True
  Galerkin Projector = Logical True
End
Boundary Condition 15
  Name = slidingBdryRotor
End
The results are not correct anymore. Did I follow your tip in the right way? The boundary between rotor and stator is still a mortar boundary.
Do you get an error message if the boundary mesh is not conforming?

Kind regards,
Martin
FabianH
Posts: 19
Joined: 13 Nov 2020, 01:08
Antispam: Yes

Re: Some tips for 2D electrical machine computation

Post by FabianH »

Hi,

after using many open source and commercial electromagnetic solvers, my opinion is that the best programs have the best documentation or simple GUI. Regardless of the performance. From my point of view, you can see that from the fact that many refer to femm, which is good entry-level software.

Elmer isn't perfectly documented, but Pavel's example serves as a bridge to create a working example without deep knowledge. However, I think it's getting a bit old now. It never ran flawlessly for me, but it also helped me a lot to create the first 2D models.

For many commands, it's more like trial and error. You see a command in the forum or in a test and test if it improves something or doesn't make any sense at all. Unfortunately, it is often not clear to me why some commands help or make the situation worse. There are also commands like "Handle Assembly", which I'm reading for the first time and wondering how I could have found out myself.

I've had the thought of writing a small guide for a long time on how to create a SIF file for 2D calculations. This would clarify many fundamental questions such as boundaries, solver settings, etc. and also increase the acceptance of Elmer. For the advanced topics there is still the forum ;-)

I got an old example for conforming boundaries:

Code: Select all

Boundary Condition 2
  Name = StatorLeft
  Conforming BC = 3
  Radial Projector = True ! Anti for Anti parallel
End
i didn't use "Mortar BCs additive = True" and also not "Galerkin Projector = True". Maybe it helps. My flux lines were correct, but I always had large deviations at the reference norm (compared to mortar boundaries).


Best regards
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Some tips for 2D electrical machine computation

Post by raback »

Hi

The development is always gradual and we have to always prioritization since a handful of people can never have everything polished. The development is usually guided by some projects and the main goal is solve the challenges in the project, not to have perfect documentation. Unfortunately.

The Mortar BCs follow a development pathway. In some terminology we first introduced node-to-surface interpolation which didn't work that well, the surface-to-surface version (Galerkin version) is much more accurate. In fact, just has been proven to be optimal in accuracy. Still it might not converge since linear systems with constraints are more difficult. Hence the Conforming BC version. Note that when you compare these different strategies you can not compare the NRM of the solution. The L2 norm is different as the solution vectors are even of diffent size. You should rather look at the result fields, or at some lumped quantities like the Torque. Note that "Conforming BC", "Mortar BC" and "Periodic BC" are mutually exclusive so only one should be used.

-Peter
MartinHoeijmakers
Posts: 37
Joined: 22 Oct 2017, 21:03
Antispam: Yes

Re: Some tips for 2D electrical machine computation

Post by MartinHoeijmakers »

Hello Peter,

I can understand your problem with the documentation. At this moment, I'm writing my own notes based on studying the source code. However, that is also quite a puzzle because of lack of comments, but I think it still is a good investment, as the software itself is superb.

For me (and I think also for other people calculating electric machines) it is very difficult to find the right combination of keywords in the boundaries and solver. I tried to keep my question above as simple as possible and gave two small sets. Is it possible to check those set?

Kind regards,
Martin
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Some tips for 2D electrical machine computation

Post by raback »

Hi

Yes, your sif sniplets should be optimal for 2D (*). The "Galerkin Projector = Logical True" is not needed for conforming BC but it should do nothing. Of course if your mesh is not conforming i.e. you have exact match between nodes you cannot apply conforming BC. What it does it basically makes a permutation such that the code refers to the same value in the array (if it is "anti" then always multiplied by -1).

(*) The optimality for quadratic meshes is not clear. Probably it would be best to use "Element = p:2" rather than nodal quadratic elements. This is very recent work for the mortars. Going beyond quadratic probably makes no sense. Usually just linear elements are used.

-Peter
MartinHoeijmakers
Posts: 37
Joined: 22 Oct 2017, 21:03
Antispam: Yes

Re: Some tips for 2D electrical machine computation

Post by MartinHoeijmakers »

Hi,

Peter, thanks for checking my set.

I think, I found why the conforming BCs didn't work in my case.
The boundaries are used in pairs. Call one boundary CW (clock wise) and the other boundary CCW (counter-clock wise). If you always use CW as the first boundary (with the keys, such as "Conforming BC = Integer 13") and CCW (with only Name as key) as the second, there is no problem. However, if you use the order CCW as first and CW as second order once, the results are wrong.
I always use the order CW and then CCW, but if I unite the stator mesh and the rotor mesh, and the number of boundaries in the rotor is larger than the number of boundaries in the stator, the order of the rotor boundaries may be changed. In that case one CCW boundary came before its CW counter part.
I will have to make the writing of the boundaries to the sif file more robust.

Kind regards,
Martin
MartinHoeijmakers
Posts: 37
Joined: 22 Oct 2017, 21:03
Antispam: Yes

Re: Some tips for 2D electrical machine computation

Post by MartinHoeijmakers »

Hi,

The second tip (conforming BCs) gave an improvement in speed of about 20% in my case: nice!

The third tip (removing RigidMeshMapper) gave hardly any improvement in speed (perhaps 2%). However, I have to mention that I changed MATC into LUA earlier.

Kind regards,
Martin
Post Reply