Simulation of the force between two magnets

 Posts: 641
 Joined: 25 Jan 2019, 01:28
 Antispam: Yes
Re: Simulation of the force between two magnets
With the two_bodies geometry and the case.sif provided, modified to center the 0,0 between the bodies the force reported for different mesh sizes is
Element Size Force
0.0009 472
0.00045 870
0.0001 1212
Element Size Force
0.0009 472
0.00045 870
0.0001 1212

 Site Admin
 Posts: 3697
 Joined: 22 Aug 2009, 11:57
 Antispam: Yes
 Location: Espoo, Finland
 Contact:
Re: Simulation of the force between two magnets
Hi All,
Thank you for everybody who has been studying the case!
It seems that the nodal forces had not been used in 2D cylindrically symmetric cases before. So the postprocessing code was missing the weight multiplication by the radius. I have just committed a fix to the devel branch.
Now the fact that there was a missing multiplier meant that the results seemed more accurate when R was in range of 1. And unfortunately in my own test case, this was exactly the value I used.
Attached is the case in somewhat modified form. The same case is now done both in 2D and 3D, and we even obtain same results. I compared to an analytic formula but it is accurate only when x>>R. In this case we have x=2R. Already with x=4R the relative error is reduced to about one third. Maybe you will find better references.
I hope this helps people dealing with permanent magnets.
Peter
Thank you for everybody who has been studying the case!
It seems that the nodal forces had not been used in 2D cylindrically symmetric cases before. So the postprocessing code was missing the weight multiplication by the radius. I have just committed a fix to the devel branch.
Now the fact that there was a missing multiplier meant that the results seemed more accurate when R was in range of 1. And unfortunately in my own test case, this was exactly the value I used.
Attached is the case in somewhat modified form. The same case is now done both in 2D and 3D, and we even obtain same results. I compared to an analytic formula but it is accurate only when x>>R. In this case we have x=2R. Already with x=4R the relative error is reduced to about one third. Maybe you will find better references.
I hope this helps people dealing with permanent magnets.
Peter
 Attachments

 MagneticForceCylindricalBodies.tar.gz
 Reference case in 2D and 3D
 (2.99 KiB) Downloaded 44 times

 Posts: 641
 Joined: 25 Jan 2019, 01:28
 Antispam: Yes
Re: Simulation of the force between two magnets
it does help, good addition.

 Posts: 641
 Joined: 25 Jan 2019, 01:28
 Antispam: Yes
Re: Simulation of the force between two magnets
it does help, good addition.
Re: Simulation of the force between two magnets
Hi Peter,
thank you very much for providing MagneticForceCylindricalBodies.tar.gz
I tried to run it with the described steps in the readmefile but get the following error below.
I run elmer on windows 10.
Does anybody know where I have to start to fix this problem?
Thank you in advance for any hint!
Best regards
Phlix
ELMER SOLVER (v 8.4) STARTED AT: 2020/03/31 15:00:05
ParCommInit: Initialize #PEs: 1
MAIN:
MAIN: =============================================================
MAIN: ElmerSolver finite element software, Welcome!
MAIN: This program is free software licensed under (L)GPL
MAIN: Copyright 1st April 1995  , CSC  IT Center for Science Ltd.
MAIN: Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi
MAIN: Version: 8.4 (Rev: Release, Compiled: 20200326)
MAIN: Running one task without MPI parallelization.
MAIN: Running with just one thread per task.
MAIN: Lua interpreted linked in.
MAIN: =============================================================
MAIN:
MAIN:
MAIN: 
MAIN: Reading Model: case2d.sif
LoadInputFile: Scanning input file: case2d.sif
LoadInputFile: Loading input file: case2d.sif
Model Input: Unlisted keyword: [vtu: discontinuous bodies] in section: [simulation]
Model Input: Unlisted keyword: [expression 1] in section: [solver 3]
LoadInputFile: Number of BCs: 2
LoadInputFile: Number of Body Forces: 0
LoadInputFile: Number of Initial Conditions: 0
LoadInputFile: Number of Materials: 3
LoadInputFile: Number of Equations: 1
LoadInputFile: Number of Solvers: 3
LoadInputFile: Number of Bodies: 3
WARNING:: ListFind:
WARNING:: ListFind: Requested property: [Body Force], not found
WARNING:: ListFind:
WARNING:: ListFind:
WARNING:: ListFind: Requested property: [Body Force], not found
WARNING:: ListFind:
WARNING:: ListFind:
WARNING:: ListFind: Requested property: [Body Force], not found
WARNING:: ListFind:
Loading user function library: [MagnetoDynamics2D]...[MagnetoDynamics2D_Init0]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_Init0]
ERROR:: MagnetoDynamicsCalcFields_Init0: Could not determine target variable type (real or complex)
STOP 1
thank you very much for providing MagneticForceCylindricalBodies.tar.gz
I tried to run it with the described steps in the readmefile but get the following error below.
I run elmer on windows 10.
Does anybody know where I have to start to fix this problem?
Thank you in advance for any hint!
Best regards
Phlix
ELMER SOLVER (v 8.4) STARTED AT: 2020/03/31 15:00:05
ParCommInit: Initialize #PEs: 1
MAIN:
MAIN: =============================================================
MAIN: ElmerSolver finite element software, Welcome!
MAIN: This program is free software licensed under (L)GPL
MAIN: Copyright 1st April 1995  , CSC  IT Center for Science Ltd.
MAIN: Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi
MAIN: Version: 8.4 (Rev: Release, Compiled: 20200326)
MAIN: Running one task without MPI parallelization.
MAIN: Running with just one thread per task.
MAIN: Lua interpreted linked in.
MAIN: =============================================================
MAIN:
MAIN:
MAIN: 
MAIN: Reading Model: case2d.sif
LoadInputFile: Scanning input file: case2d.sif
LoadInputFile: Loading input file: case2d.sif
Model Input: Unlisted keyword: [vtu: discontinuous bodies] in section: [simulation]
Model Input: Unlisted keyword: [expression 1] in section: [solver 3]
LoadInputFile: Number of BCs: 2
LoadInputFile: Number of Body Forces: 0
LoadInputFile: Number of Initial Conditions: 0
LoadInputFile: Number of Materials: 3
LoadInputFile: Number of Equations: 1
LoadInputFile: Number of Solvers: 3
LoadInputFile: Number of Bodies: 3
WARNING:: ListFind:
WARNING:: ListFind: Requested property: [Body Force], not found
WARNING:: ListFind:
WARNING:: ListFind:
WARNING:: ListFind: Requested property: [Body Force], not found
WARNING:: ListFind:
WARNING:: ListFind:
WARNING:: ListFind: Requested property: [Body Force], not found
WARNING:: ListFind:
Loading user function library: [MagnetoDynamics2D]...[MagnetoDynamics2D_Init0]
Loading user function library: [MagnetoDynamics]...[MagnetoDynamicsCalcFields_Init0]
ERROR:: MagnetoDynamicsCalcFields_Init0: Could not determine target variable type (real or complex)
STOP 1
Re: Simulation of the force between two magnets
HI all,
I think found my mistake.
Here the solution if any other newbie runs into the same pitfall:
When i installed the newest version from here:
http://www.nic.funet.fi/pub/sci/physics ... dowstest/
I forgot to add elmer to the system path during the setup (see yellow highlights in screenshot).
I did it as depicted, when I reinstalled elmer. Now, everything seems to work
Best regards!
I think found my mistake.
Here the solution if any other newbie runs into the same pitfall:
When i installed the newest version from here:
http://www.nic.funet.fi/pub/sci/physics ... dowstest/
I forgot to add elmer to the system path during the setup (see yellow highlights in screenshot).
I did it as depicted, when I reinstalled elmer. Now, everything seems to work
Best regards!
 Attachments

 Elmerinstall.PNG (19.15 KiB) Viewed 533 times
Re: Simulation of the force between two magnets
Hi everyone,raback wrote: ↑30 Jan 2020, 15:43Hi All,
Thank you for everybody who has been studying the case!
It seems that the nodal forces had not been used in 2D cylindrically symmetric cases before. So the postprocessing code was missing the weight multiplication by the radius. I have just committed a fix to the devel branch.
Now the fact that there was a missing multiplier meant that the results seemed more accurate when R was in range of 1. And unfortunately in my own test case, this was exactly the value I used.
Attached is the case in somewhat modified form. The same case is now done both in 2D and 3D, and we even obtain same results. I compared to an analytic formula but it is accurate only when x>>R. In this case we have x=2R. Already with x=4R the relative error is reduced to about one third. Maybe you will find better references.
I hope this helps people dealing with permanent magnets.
Peter
I am currently trying to expand on this study by simulating multiple cases for two permanent magnets. Here, I am comparing the results from the 2D and 3D cases to the analytical solution. The results are shown below:
The results from Elmer 2D and the analytical solution seem to match, however I have some problems with getting the correct results for Elmer 3D. I noticed that the results from Elmer 3D were about a factor 2 too low. Multiplication by 2 gives the Elmer 3D correction line, which seems to be the correct answer. However, I cannot explain this factor and I cannot find any reason why this difference would be there. Here are the files from the 3D case I used:
The files from the 2D case are in the next post.
Last edited by JanHoek on 23 Apr 2020, 17:22, edited 1 time in total.
Re: Simulation of the force between two magnets
Below are the files I used for the 2D case:
The analytical solution is valid for x>>R, given by: Does anyone have any idea why the solutions from the 2D and 3D case are different? Any help would be greatly appreciated.
Kind regards,
Jan
The analytical solution is valid for x>>R, given by: Does anyone have any idea why the solutions from the 2D and 3D case are different? Any help would be greatly appreciated.
Kind regards,
Jan

 Posts: 641
 Joined: 25 Jan 2019, 01:28
 Antispam: Yes
Re: Simulation of the force between two magnets
Yes, the 2D case has a finer mesh by a factor of a 1000. Mesh density affects the answer. increase the mesh density of the 3D problem and it will start converging to the 2D problem.
Re: Simulation of the force between two magnets
I tried to refine the mesh a couple of times for the case where the distance between the magnets is 1mm. I also tried multiple local mesh refinements, however the solution seems to converge to half the value of the analytical solution and 2D axisymmetric case result every time. Here are the files I use:
Based on the similar results from all simulations, I am quite certain that a mesh refinement won't give the correct solution. Does anyone know what else could cause the problem in these simulations? Could it be possible that it is an implementation error?
Based on the similar results from all simulations, I am quite certain that a mesh refinement won't give the correct solution. Does anyone know what else could cause the problem in these simulations? Could it be possible that it is an implementation error?