Skip to main content

Magnetic Forces Between Two Permanent Magnets

Magnetic Field of 2 Cylindreical Permanent Magnets

Background & Model Setup
Many years back, part of my MS degree required me to do some modeling of some permanent magnets to get magnetic stiffness and magnetic flux. The code is based on the work done then. Other related ANSYS resources I found:
  • CozyWork's 2D single magnet model. 
  • Ansys Help archive. Newer Ansys v18 has much of it undocumented. 
K&J Magnetics has a really cool website calculator that computes the magnetic force of a few simple cases. The ANSYS script below computes the magnetic force between two magnets of N52, 10 mm diameter, 5 mm thick magnets. It is assumed the magnets have relative permeability of 1.05 and Coercive Force of >11.2 kOe (>89,1267 A/m).

The model consists of the two cylindrical shaped magnets at a small distance from each other. Surrounding them is another cylinder that represents the air. Both are polarized in the positive Z direction thus the magnets will be in attraction.

Side View of Two Cylindrical Magnet and Air

Another View of the Magnets and Air Volume

APDL Script
!! Magnetic Force Between Two Magnets Script

! Sze Kwan (Jason) Cheah
! www.AnsysTips.com
! April 13, 2017
! Not verified. Use at own risk! 

/prep7
emunit, mks ! mks units

!! Element Properties
et, 1, solid98, 10 
mp, murx, 1, 1 ! air relative permeability
mp, murx, 2, 1.05 ! magnet relative permeability magnet
mp, mgzz, 2, 892000     ! coercieve force neodynium
mp, murx, 3, 1.05 
mp, mgzz, 3, 892000 

!! Geometry
u = 1e-3 ! mm conversion
myoffset = 2.5*u ! magnet offset
cylind, 5*u, 0, 0, -5*u
cylind, 5*u,0,myoffset, myoffset+5*u
cylind, 9*u, 0, -12*u, 12*u+myoffset

vsbv, 3, 1,, delete,keep
vsbv, 4, 2,, delete,keep
vsel, all
vglue, all

!! Attributes

vsel, s, volu,, 3 ! Air
vatt, 1,, 1 
vsel, s, volu,, 1 ! Lower magnet
vatt, 2,, 1
vsel, s, volu,, 2 ! Upper magnet
vatt, 3,, 1

!! Mesh
alls
esize, 1.5*u ! 1mm 
vmesh, all

!! Boundary Conditions
! calculates magnetic force at lower magnet
vsel, s, volu,, 1
eslv
cm, magnetL, elem
fmagbc, 'magnetL' ! flag lower magnet to calculate force

! outer boundary
alls
nsel, s, ext
d, all, mag, 0

! solves & save
/solu
alls
save
outres, all, all
solve
finish

! Calculates Data

/post1
set, last
alls
etable, FVWZ, NMISC, 6
ssum
*GET, MY_FZSUM, SSUM,, ITEM, FVWZ

Results & Discussion
Simulation results came in at 9.2 N while the K&J website calculator had 9.8 N. Increasing mesh density and tweaking the coercive force values could be done to tweak the results though actual test results would be preferred.

The script could be modified to account for magnets of different shapes that isn't available on a web calculator (e.g. counter sunk, star etc). If misaligned magnets are of interest, take a look at TORQSUM which calculates torque for 2D planar analysis.

Comments