! ANSYS $RCSfile: MAGLIB.MAC,v $
! Modified on $Date: 2010-11-14 13:40:31 -0500 (Sun, 14 Nov 2010) $ 
! Source ID = $Revision: 435640 $
_filen
!  The purpose of this library is to store commonly used command macros
!  used for magnetics
/eof
_intdiv
!     performs integer divison
!     Used by torqc2d macro
!
!     arg1 = numerator
!     arg2 = denominator
!
   _rres=nint(arg1/arg2)
   _rrem=arg1-_rres*arg2
   *if,_rrem,lt,0,then
    _rres=_rres-1
   *endif
   _rrem=arg1-_rres*arg2
   *if,arg3,eq,1,then
    *if,_rrem,ne,0,then
     _rres=_rres+1
    *endif
   *endif
   _rintdiv=_rres
/eof
_torque
!    used by torqcir macro
!    computes the torque based on the maxwell's stress tensor
   rsys
   csys
   pdef,bx,b,x
   pdef,by,b,y
   pvect,norm,nx,ny,nz
   pdot,pv02,bx,by,by,nx,ny,nz
   pcalc,mult,pv03,xg,by
   pcalc,mult,pv04,yg,bx
   pcalc,add,pv03,pv03,pv04,,-1
   pcalc,mult,pv02,pv02,pv03
   pcalc,intg,torq,pv02,s,1/_mu
   *get,_torq,path,,last,torq
/eof
_torplot
!   Used by the torqc2d macro
   /auto
!  plots nodes
   dsys,0
   /pbc,path,1
   /pnum,node,0
   nplot
   /pbc,path,0
/eof
