Simulation of the force between two magnets

Numerical methods and mathematical models of Elmer
JanHoek
Posts: 15
Joined: 13 Jan 2020, 14:06
Antispam: Yes

Simulation of the force between two magnets

Post by JanHoek »

Hi everyone,

I am new to Elmer, so it could well be possible that I am using the wrong method to model this. Anyway, I am trying to determine the total attractive magnetic force between two identical cylindrical magnets. Both magnets have an equal but opposite magnetization of 8e7 in the x-axis. The magnets are surrounded by a large rectangle of air. Here is the .sif file, bodies 1 and 2 are magnets, body 3 is the rectangle of air:
case.sif
(3.72 KiB) Downloaded 363 times
The mesh file is too large to attach, so here is the .geo file that I meshed with NetGen:
TwoMagnetsSimple.geo
(526 Bytes) Downloaded 343 times
I am not quite sure how to extract the total magnetic force between the two magnets from this simulation. The nodal forces on the magnets seem to be too high and the magnetic forces seem to be too low (based on the comparison with the results from the analytical solution). Also, when I plot the magnetic field in Paraview, the result is a bit different than expected, which could also indicate that something goes wrong with the model I use for these calculations:
Magneticfield_twomagnets.PNG
Magneticfield_twomagnets.PNG (437.29 KiB) Viewed 6050 times
Thank you in advance!
mika
Posts: 236
Joined: 15 Sep 2009, 07:44

Re: Simulation of the force between two magnets

Post by mika »

Hi,

In the sif file the magnetization vectors seem to have the same sign. Should we change one sign to be consistent with your description of the problem? The magnitude of the magnetization vector is 8e5 in the sif, while 8e7 in the message?

-- Mika
kevinarden
Posts: 2299
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Simulation of the force between two magnets

Post by kevinarden »

This is my approach in 2D
results.png
(275.52 KiB) Not downloaded yet
Impact of mesh size on results
MagField.png
(275.71 KiB) Not downloaded yet
force.sif
(2.92 KiB) Downloaded 375 times
not sure how to sum the nodal force over the left and right body
JanHoek
Posts: 15
Joined: 13 Jan 2020, 14:06
Antispam: Yes

Re: Simulation of the force between two magnets

Post by JanHoek »

Hi,

You are right @Mika, they should be opposite and the magnitude should be equal to 8e5. I will try your 2D approach @kevinarden and see if the answer comes closer to what I would expect, thank you both for your replies.
JanHoek
Posts: 15
Joined: 13 Jan 2020, 14:06
Antispam: Yes

Re: Simulation of the force between two magnets

Post by JanHoek »

I have transformed the 3D model to a 2D axisymmetric model, which does give a realistic magnetic field. However, I am still not sure how to extract the total magnetic force between the two magnets from this model. I tried to sum up the nodal forces over the boundaries of one magnet, but the obtained answer (after transformation from axisymmetric to 3D) is much larger than the analytical solution (which should be close to 1 N). Here are the files I used:
case.sif
(3.54 KiB) Downloaded 306 times
Axisymmetric.grd
(962 Bytes) Downloaded 302 times
And here is the resulting magnetic field:
MagneticFieldAxisymmetric.PNG
(327.16 KiB) Not downloaded yet
I probably do not use the correct method to calculate the force the magnets exert on each other. How would I be able to obtain this force?
mika
Posts: 236
Joined: 15 Sep 2009, 07:44

Re: Simulation of the force between two magnets

Post by mika »

Hi,

First, it seems that the attached grd-file doesn't produce a sensible numbering of boundaries to assign boundary conditions correctly. I'm attaching a modified file which doesn't produce overlapping parts of the boundary. Note also that here the right symmetry BC is the do-nothing condition (the homogeneous Neumann condition, the default BC) rather than the homogeneous Dirichlet BC.

I'm not the best expert on the electromagnetic force computation, but to find the total force I'd try to use the nodal force calculation together with the component definitions. The solver can then compute the total electromagnetic force experienced by each component by summing all nodal forces distributed over the master body. The attached sif file gives a modification into that direction, although it may not yet provide the force of 1 N desired.

-- Mika
Attachments
two_bodies.sif
(4.04 KiB) Downloaded 343 times
two_bodies.grd
(1018 Bytes) Downloaded 277 times
JanHoek
Posts: 15
Joined: 13 Jan 2020, 14:06
Antispam: Yes

Re: Simulation of the force between two magnets

Post by JanHoek »

Thank you Mika for your response.

For the boundary condition, when I use the Neumann condition, the field lines do not look physical (their direction should be perpendicular to the surface of the magnet, not parallel). I think the Dirichlet boundary condition is the correct one here. This gives the following result for the magnetic field lines:
Axisymmetric.PNG
(136.31 KiB) Not downloaded yet
Furthermore, I have tried your approach and I do get an equal and opposite magnetic force from the magnets. I do have some difficulties with interpreting the result, because I think the force should be in N/rad, however then something goes wrong with the scaling. When I have the dimensions in [m] in the .grd file and I don't use scaling, I get a different result than when I have the dimensions in [mm] and use scaling. Here are my .grd and .sif files:
two_bodies.grd
(982 Bytes) Downloaded 306 times
case.sif
(4.02 KiB) Downloaded 302 times
What are the dimensions of the magnetic force in an axisymmetric model? And is my implementation of this model correct?

Edit: I just found out that the force does not depend on the geometry at all (When I make the radius of the magnet 6 times smaller, the result is the same). Could it be possible that the nodal forces are not physical? When I remove the other magnet (for example by making it from air), the nodal forces are still present.
raback
Site Admin
Posts: 4823
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Simulation of the force between two magnets

Post by raback »

Hi

Looked a little, works fine for me. Albeit I must say I modified the case a little to more easily compare to approximation in:
https://en.wikipedia.org/wiki/Force_between_magnets

Your BCs could be somewhat modified (though the effect is quite small):
1) The symmetry BC is natural BC. Just do nothing.
2) The "infinity bc" assume that you're centered at origin. Here this is not the case. You should just take down the whole mesh so that the origin is between discs. Or just use zero Dirichlet BCs.

Then you get forces with component in r and z directions. These should be integrated over the missing 2Pi. This means that the radial components vanishes, and the 2nd direction gets multiplied by 2Pi. Perhaps you were looking at the radial component which does not result to a net force on the object.

After this you should at least have the 1st number correct. Increasing mesh density, refinement or power helps to get better accuracy.

-Peter
JanHoek
Posts: 15
Joined: 13 Jan 2020, 14:06
Antispam: Yes

Re: Simulation of the force between two magnets

Post by JanHoek »

Hi Peter,

Thank you for your response! I made a mistake in loading the files, so forget my edit in the previous post. I think I have got the right answer now thanks to your feedback, however that is only when I use coordinate scaling, of which I am not sure if I should be using it. In the .grd file, I have put all dimensions in meters, however the results are a factor 1000 off if I do not use the scaling. I think all my units are in SI, so could it be possible that Elmer modifies the dimensions from the .grd input file?
mika
Posts: 236
Joined: 15 Sep 2009, 07:44

Re: Simulation of the force between two magnets

Post by mika »

Despite what I wrote earlier, obtaining a finite curl of the potential variable A_phi seems necessarily to imply that A_phi = 0 on the axis r = 0. Thus the homogeneous Dirichlet BC may indeed be the right BC on the axis.

-- Mika
Post Reply