Simulation of the force between two magnets
Simulation of the force between two magnets
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 xaxis. 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:
The mesh file is too large to attach, so here is the .geo file that I meshed with NetGen:
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:
Thank you in advance!
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 xaxis. 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:
The mesh file is too large to attach, so here is the .geo file that I meshed with NetGen:
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:
Thank you in advance!
Re: Simulation of the force between two magnets
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
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

 Posts: 641
 Joined: 25 Jan 2019, 01:28
 Antispam: Yes
Re: Simulation of the force between two magnets
This is my approach in 2D
Impact of mesh size on results
not sure how to sum the nodal force over the left and right bodyRe: Simulation of the force between two magnets
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.
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.
Re: Simulation of the force between two magnets
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:
And here is the resulting magnetic field:
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?
And here is the resulting magnetic field:
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?
Re: Simulation of the force between two magnets
Hi,
First, it seems that the attached grdfile 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 donothing 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
First, it seems that the attached grdfile 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 donothing 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 36 times

 two_bodies.grd
 (1018 Bytes) Downloaded 32 times
Re: Simulation of the force between two magnets
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:
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:
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.
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:
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:
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.

 Site Admin
 Posts: 3702
 Joined: 22 Aug 2009, 11:57
 Antispam: Yes
 Location: Espoo, Finland
 Contact:
Re: Simulation of the force between two magnets
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
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
Re: Simulation of the force between two magnets
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?
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?
Re: Simulation of the force between two magnets
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
 Mika