! solenoid.mac
!
! Runs in Ansys 7.1 but not in Ansys 5.4

! Generate the basic model
solenoid.inp

! 1. Air material properties
mp,murx,1,1

! 2. Back Iron material properties
mp,murx,2,1000

! 3. Coil material properties
mp,murx,3,1

! 4. Armature material properties
mp,murx,4,2000

! Select the 2-D Coupled-Field Solid
et,1,plane13
keyopt,1,1,0        ! Use vector potential DOF
keyopt,1,2,0        ! Include extra shapes
keyopt,1,3,1        ! Axisymmetric
keyopt,1,4,0        ! Element coordinate system parallel to global sys
keyopt,1,5,0        ! Basic element printout

! Set properties for air areas
asel,s,area,,13,14
asel,a,area,,17,18
aatt,1,,1,0

! Set properties for back iron areas
asel,s,area,,7,9
asel,a,area,,11,12
aatt,2,,1,0

! Set properties for coil area
asel,s,area,,4
aatt,3,,1,0

! Set properties for armature areas
asel,s,area,,10
asel,a,area,,15,16
aatt,4,,1,0

alls

! Refine the mesh at the air gap
lsel,s,loc,y,h1+.5*gair
lesize,all, , ,2, , , , ,1

alls

! Set mesh size and mesh the model
esize,0.25,0
mshape,0,2d
mshkey,0

amesh,all

eplot

/pnum,area,1
/pnum,mat,1

! Scale the model to meters
arscale,all,,,.01,.01,1,,0,1

esel,s,mat,,4
eplot

! Apply force boundary conditions to armature.
cm,arm,elem
fmagbc,'arm'

alls

! Apply the current density.
bfa,4,js,,,325/.01**2

! Apply a perimeter boundary cond. to obtain a flux parallel field solution. 
lsel,s,line,,2,4,2
lsel,a,line,,9,11,2
lsel,a,line,,25,28,3
lsel,a,line,,35,44,3
lsel,a,line,,47,50
lplo

! Apply flux parallel BC at model boundary
dl,all,,asym

alls

eplo

finish

/sol

! Magnetics solve
magsolv,0,3,0.001, ,25,

finish

/post1

! Flux plot
plf2d,27,0,10,1

! Compute the total force on armature
fmagsum,'arm'

! End of File (exits macro)
/eof

! Vector plot
plvect,b, , , ,vect,elem,on,0

! Flux density color dither plot
/eface,1
plnsol,b,sum,0

! Switch to 3-D extended view
/expand,27,axis,,,10
/view, 1 ,1,1,1
/ang, 1
/rep,fast
/replot,resize

! Magnetic field intensity color dither plot
plnsol,h,sum,0