!   TITLE:  c552002798_rtr_lam.mac (EMAG)
!
!---------------------------------------------------------------------------
!       Rev -   08/07/2000
!---------------------------------------------------------------------------
!
!   This macro creates the stator lamination profile, P/N C552002798
!
!   CSrl0:      Cartesian Stator Lamination Coordinate System
!   CSrl1:  Cylindrical Stator Lamination Coordinate System
!
!
!******************************* TABLE OF CONTENTS **************************
!
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   3.  Material and Element Type
!   4.  Solid Model
!       4.1  Outer Diameter Area Layout
!       4.2  Flat Surfaces
!       4.3  Mid Diameter Area Layout
!       4.4  Center Hole Layout
!
!
!***************************** END Table of Contents ************************
!
!
!
!************************** Model Assembly Preparation **********************
!
/prep7
!
/dev,font,1,charter,bold,r,24,,,,,
!
/title,Rotor Lamination C552002798
!
/VIEW, 1 ,,,1
/ANG, 1
!
/units,bin      ! British/inch units
!
!**************************** End Model Preparation *************************
!
!
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>

            d_outr=0.375    ! lamination outer diameter
            d_midr=0.203    ! lamination mid-circle diameter
            d_hole=0.1255   ! inner hole diameter
            rsegfil=.035    ! fillet radius of rotor segments

            num_seg=3       ! number of rotor segments
            seg_ang=56      ! rotor lamination segments angle


!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate Systems >>>>>>>>>>>>>>>>>>>>
!
acs=0       ! active coordinate system (c.s.) locating model c.s.
!
!------------- Specify model c.s. center location --------------
!
xc=0.00     ! x (r) coordinate center
yc=0.00     ! y (theta) coordinate center
zc=0.00     ! z (z or phi) coordinate center
!
!------------- Specify model c.s. orientation ------------------
!
rotxy=0     ! 1st rotation angle (+x to +y)
rotyz=0     ! 2nd rotation angle (+y to +z)
rotzx=0     ! 3rd rotation angle (+z to +x)
!
!---------------------------------------------------------------
!
csn=11
!
csn=csn+1
CSrl0=csn       ! cartesian model c.s. number
!
csn=csn+1
CSrl1=csn       ! cylindrical model c.s. number
!
csys,acs
clocal,CSrl0,0,xc,yc,zc,rotxy,rotyz,rotzx
!
csys,acs
clocal,CSrl1,1,xc,yc,zc,rotxy,rotyz,rotzx
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!<<<<<<<<<<<<<<<<<<<< 3.  Material and Element Type >>>>>>>>>>>>>>>>>>>
!
!
!---------------------- Material Properties --------------------
!
UIMP,1,EX, , ,10.3E6,       ! Material:  XXXXX
UIMP,1,DENS, , ,.097/386.4,
UIMP,1,NUXY, , ,0.33,
!UIMP,XX,XXXX
!
!---------------------------------------------------------------
!
!
!------------------------- Element Type ------------------------
!
!ET,XX,XXXXX
!ET,XX,XXXXX
!
!---------------------------------------------------------------
!
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!---------------------- 4.1  Teeth Area Layouts -----------------------
!
csys,CSrl1
    !
    ang_intr=360/num_seg
    ang_gap=(360-num_seg*seg_ang)/num_seg
    pi=acos(-1)
    phi1=asin((0.5*rsegfil)/((d_midr/2)+rsegfil))*(180/pi)
    !
    k,,0,0,0
    *get,kpcent,kp,,num,max
    !
    alpha1=90+(num_seg-1)*(ang_intr)
    !
    *do,j,90,alpha1,ang_intr
        k,,d_outr/2,j-(seg_ang/2),0
        k,,d_outr/2,j+(seg_ang/2),0
        !
        *get,km,kp,,num,max
        !
        l,km-1,km
        lstr,km-1,kpcent
        lstr,km,kpcent
        !
        *get,lm,line,,num,max
        !
        al,lm-2,lm-1,lm
        !
        *get,km,kp,,num,max
        numstr,kp,km
        !
        *get,lm,line,,num,max
        numstr,line,lm
        !
        *get,am,area,,num,max
        numstr,area,am
        !
    *enddo
    !
    !------------------ 4.2  Center Hub Area Layout -------------------
    !
    km_prev=km              ! store previous entity maximums
    lm_prev=lm
    am_prev=am
    !
    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm
    !
    *get,am,area,,num,max
    numstr,area,am
    !
    *do,j,90,alpha1,ang_intr
        k,,d_midr/2,j,0
    *enddo
    !
    *get,km,kp,,num,max
    numstr,kp,km
    !
    newkps=km-km_prev
    !
    *do,iii,1,newkps,1
        *if,iii,ne,newkps,then
            l,km-(newkps-iii),km-(newkps-iii-1)
        *else
            l,km,km-(newkps-1)
        *endif
    *enddo
    !
    *get,lm,line,,num,max
    numstr,line,lm
    !
    lsel,s,line,,lm-(num_seg-1),lm
    !
    al,all
    !
    allsel,all
    !
    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm
    !
    *get,am,area,,num,max
    numstr,area,am
    !
    asel,s,area,,am-num_seg,am
    aadd,all
    allsel,all
    !
    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm
    !
    *get,am,area,,num,max
    numstr,area,am
    !
    lplot
    !
    !----------------- 4.3  Center Hub / Tooth Fillets ----------------
    !
    asel,s,area,,am
    lsla,s
    cm,lset1,line
    allsel,all
    !
    adele,am
    !
    *do,j,90,alpha1,ang_intr
        !
        *if,j,eq,90,then
            lsel,s,loc,x,d_midr/2,d_outr/2
            lsel,r,loc,z,0
            lsel,r,loc,y,j-(seg_ang/2)-0.95*ang_gap,j-(seg_ang/2)
        *else
            lsel,s,loc,x,d_midr/2,d_outr/2
            lsel,r,loc,z,0
            lsel,r,loc,y,j-(seg_ang/2)-0.95*ang_gap+phi1,j-(seg_ang/2)
        *endif
        !
        *get,llow,line,,num,min
        *get,lhigh,line,,num,max
        !
        lfillt,llow,lhigh,rsegfil
        !
        !
        *if,j,eq,90,then
            lsel,s,loc,x,d_midr/2,d_outr/2
            lsel,r,loc,z,0
            lsel,r,loc,y,j+(seg_ang/2)+0.95*ang_gap,j+(seg_ang/2)
        *else
            lsel,s,loc,x,d_midr/2,d_outr/2
            lsel,r,loc,z,0
            lsel,r,loc,y,j+(seg_ang/2)+0.95*ang_gap-phi1,j+(seg_ang/2)
        *endif
        !
        *get,llow,line,,num,min
        *get,lhigh,line,,num,max
        !
        lfillt,llow,lhigh,rsegfil
        !
        allsel,all
        !
        *get,km,kp,,num,max
        numstr,kp,km
        !
        *get,lm,line,,num,max
        numstr,line,lm
        !
        *get,am,area,,num,max
        numstr,area,am
        !
        lplot
    *enddo
    !
    lsel,s,line,,lset1
    lsel,a,line,,lm-(2*num_seg-1),lm
    !
    al,all
    !
    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm
    !
    *get,am,area,,num,max
    numstr,area,am
    !
    lplot
    !
    !------------------------ 4.4  Center Hole ------------------------
    !
    *do,i,0,270,90
        k,,d_hole/2,i,0
    *enddo
    !
    *get,km,kp,,num,max
    !
    a,km-3,km-2,km-1,km
    !
    *get,am,area,,num,max
    numstr,area,am
    !
    asba,am-1,am,,delete,delete
    !
    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm
    !
    *get,am,area,,num,max
    numstr,area,am
    !
    allsel,all
    lplot