Simulation of the force between two magnets

Numerical methods and mathematical models of Elmer
kevinarden
Posts: 641
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Simulation of the force between two magnets

Post by kevinarden » 28 Jan 2020, 20:57

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

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

Re: Simulation of the force between two magnets

Post by raback » 30 Jan 2020, 15:43

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
Attachments
MagneticForceCylindricalBodies.tar.gz
Reference case in 2D and 3D
(2.99 KiB) Downloaded 44 times

kevinarden
Posts: 641
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Simulation of the force between two magnets

Post by kevinarden » 30 Jan 2020, 21:35

it does help, good addition.

kevinarden
Posts: 641
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Simulation of the force between two magnets

Post by kevinarden » 30 Jan 2020, 21:37

it does help, good addition.

Phlix
Posts: 11
Joined: 31 Aug 2018, 13:51
Antispam: Yes

Re: Simulation of the force between two magnets

Post by Phlix » 31 Mar 2020, 16:08

Hi Peter,

thank you very much for providing MagneticForceCylindricalBodies.tar.gz
I tried to run it with the described steps in the readme-file 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: 2020-03-26)
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

Phlix
Posts: 11
Joined: 31 Aug 2018, 13:51
Antispam: Yes

Re: Simulation of the force between two magnets

Post by Phlix » 07 Apr 2020, 14:35

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 ... dows-test/

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 :D

Best regards!
Attachments
Elmerinstall.PNG
Elmerinstall.PNG (19.15 KiB) Viewed 533 times

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

Re: Simulation of the force between two magnets

Post by JanHoek » 23 Apr 2020, 17:15

raback wrote:
30 Jan 2020, 15:43
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
Hi everyone,

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:
Results_simulations.png
Results_simulations.png (21.82 KiB) Viewed 484 times
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:
3D_20.grd
(874 Bytes) Downloaded 25 times
case.sif
(3.86 KiB) Downloaded 32 times
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.

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

Re: Simulation of the force between two magnets

Post by JanHoek » 23 Apr 2020, 17:20

Below are the files I used for the 2D case:
d20.grd
(923 Bytes) Downloaded 33 times
case.sif
(3.83 KiB) Downloaded 36 times
The analytical solution is valid for x>>R, given by:
Analytical_Solution.png
Analytical_Solution.png (97.13 KiB) Viewed 483 times
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

kevinarden
Posts: 641
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Simulation of the force between two magnets

Post by kevinarden » 23 Apr 2020, 22:10

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.

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

Re: Simulation of the force between two magnets

Post by JanHoek » 27 Apr 2020, 21:31

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:
3D_1.grd
(873 Bytes) Downloaded 22 times
case.sif
(3.72 KiB) Downloaded 22 times
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?

Post Reply