/out,machtorq,out
/com,machtorq.mac
/com, computes the machine torque by
/com, virtural work, Maxwell's stress by element and line integral
/com
fini
/post1
_mg1=1
torqsum,'r_iron'
/out,machtorq,out,,append
cmsel,,rotor
csys,1
*get,_rmax,node,,mxloc,x
rtor=_rmax-.5*.5*gap*ggeom
cmsel,,rotor
mtorqc2d,rtor
/out,machtorq,out,,append
*stat,torqvw
*if,ggeom,le,0,then
  ggeom=1
*endif
_mg1=
csys,1
esel,,mat,,5
nsle
*get,_thmn,node,,mnloc,y
*get,_thmx,node,,mxloc,y
_dift=_thmx-_thmn
perfac=nint(360/_dift)
*if,perfac,lt,1,then
  perfac=1
*endif
csys
torqvw=torqvw*ggeom*stkthk*perfac
torqmx=torqmx*ggeom*stkthk*perfac
torqmx2=torque*ggeom*stkthk*perfac

esel,all
nsel,all

/out,machtorq,sum
*msg,info
________________TORQUE CALCULATION_____________________
*msg,info

*msg,info,stkthk
Stack length:_______ %g
*msg,info,torqvw
Torque-virtual work (n-m):__________________________ %g
*msg,info,torqmx
Torque-Maxwell Stress (n-m):________________________ %g
*msg,info,torqmx2
Torque-Maxwell Stress Line integration (n-m):_______ %g
/out
*uili,machtorq,sum