!   TITLE:  full_f_str.mac (EMAG)
!
!---------------------------------------------------------------------------
!       Rev -   2/16/01
!---------------------------------------------------------------------------
!
!   This macro creates the stator lamination profile, P/N xxxxxxxxx.
!   If tooth extensions are required on the lamination spacers, simply place
!   a 1 in the parameter value for 'toothext', and set the proper parameter
!   values in for 'gap' and 'tooth_d'.  If no tooth extensions are required,
!   place a 0 for 'toothext'.
!
!
!   CSsl0:      Cartesian Stator Lamination Coordinate System
!   CSsl1:  Cylindrical Stator Lamination Coordinate System
!
!
!******************************* TABLE OF CONTENTS **************************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   3.  Material and Element Type
!   4.  Solid Model
!       4.1  Circular Area Layout
!       4.2  Lamination Spacer Layout
!       4.3  Symmetry Layout of Complete Model
!
!
!***************************** END Table of Contents ************************
!
!
!
!************************** Model Assembly Preparation **********************
!

/prep7
!
/dev,font,1,charter,bold,r,24,,,,,
!
/title,Stator Lamination - With Teeth, Full Radius Profile
!
/VIEW, 1 ,,,1
/ANG, 1
!
/units,bin      ! British/inch units
!
!**************************** End Model Preparation *************************
!
!
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>

        toothext=1          ! decision for construction of tooth extensions
                            !       0 = no tooth extentions
                            !       1 = build tooth extensions

        d_out=5.330         ! lamination outer diameter
        d_mid=5.140         ! lamination mid-circle (back of slot) diameter
        d_in=4.846          ! lamination inner diameter
        w_spacer=.106       ! lamination spacer width

        ang_intr=15         ! lamination spacer angle interval
        lam_fil=.06         ! lamination fillet(radius)

!------------------------ Use only if toothext=1:   -----------------------

        gap=0.030           ! linear gap between teeth (if applicable)
        tooth_d=4.9         ! diameter of teeth (if applicable)
        rfil2=0.002         ! fillet radius 2
        rfil3=0.002         ! fillet radius 3


!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!
!<<<<<<<<<<<<<<<<<<<< 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
CSsl0=csn       ! cartesian model c.s. number

csn=csn+1
CSsl1=csn       ! cylindrical model c.s. number

csys,acs
clocal,CSsl0,0,xc,yc,zc,rotxy,rotyz,rotzx

csys,acs
clocal,CSsl1,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  Circular Area Layout ---------------------
!
csys,CSsl1
    !
    k,,0,0,0
    k,,d_out/2,0,0
    k,,d_out/2,ang_intr/2,0
    !
    *get,km,kp,,num,max
    !
    a,km-2,km-1,km
    !
    *get,lm,line,,num,max
    *get,am,area,,num,max
    !
    !
    k,,0,0,0
    k,,d_mid/2,0,0
    k,,d_mid/2,ang_intr,0
    !
    *get,km,kp,,num,max
    !
    a,km-2,km-1,km
    !
    *get,lm,line,,num,max
    *get,am,area,,num,max
    !
    !
    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
!
lplot
!
!-------------------- 4.2  Lamination Spacer Layout -------------------
!
pi=acos(-1)
!
    csys,CSsl1
        !
        theta=ang_intr/2
        phiprime=(asin(gap/d_in))*(180/pi)
        phi1=theta-phiprime
        !
        k,,d_in/2,0,0
        k,,d_in/2,phi1,0
        !
        *get,km,kp,,num,max
        !
        l,km-1,km
        !
        *get,lm,line,,num,max
        !
        !
    csys,CSsl0
        !
        dx1=(d_in/2)*cos(phi1*(pi/180))+(((tooth_d-d_in)/2)/cos(phi1*(pi/180)))
        !
        k,,dx1,(d_in/2)*sin(phi1*(pi/180)),0
    csys,CSsl1
        !
        phi2=asin(w_spacer/tooth_d)*(180/pi)
        !
        !k,,tooth_d/2,phi2,0
        k,,tooth_d/2,0,0
        !
        *get,km,kp,,num,max
        !
        lstr,km-2,km-1
        l,km-1,km
        l,km,km-3
        *get,km,kp,,num,max
        numstr,kp,km
        !
        *get,lm,line,,num,max
        numstr,line,lm
        a,km-3,km-2,km-1,km
        *get,am,area,,num,max
        numstr,area,am

    csys,CSsl0
        !
        k,,(d_mid/2)+0.5*(d_out/2-d_mid/2),w_spacer/2+lam_fil,0
        k,,(d_mid/2)+0.5*(d_out/2-d_mid/2),0,0

        k,,(d_in/2)+0.5*(tooth_d-d_in)/2,0,0
        k,,(d_in/2)+0.5*(tooth_d-d_in)/2,w_spacer/2+lam_fil,0
        !
        *get,km,kp,,num,max

        !
        lstr,km-3,km-2
        lstr,km-2,km-1
        lstr,km-1,km
        lstr,km,km-3
                !
        *get,lm,line,,num,max
        !
        !
        al,lm-3,lm-2,lm-1,lm

    *get,am,area,,num,max
    numstr,area,am
    !
    aadd,am-2,am-1,am

    *get,am,area,,num,max
    numstr,area,am

    lsel,s,loc,y,0
    lsel,r,loc,x,d_in/2,d_out/2

    lcomb,all
    alls

    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm

    lplot

    csys,CSsl1
    rmslot=(tooth_d+d_mid)/4    ! Mean radius of slot
    k,,rmslot,asin((w_spacer/2+lam_fil)/rmslot)*180/pi

    *get,km,kp,,num,max
    numstr,kp,km

    circle,km,lam_fil

    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm

    al,lm-3,lm-2,lm-1,lm

    *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

    csys,CSsl0
    csn=csn+1
    toothcs=csn
    clocal,toothcs,0,0,0,0,ang_intr/2,0,0
    !
    arsym,y,am-1,am,,,0,0
    !
    *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

    !
    aadd,am-1,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
    !
    lplot
    !
    csys,CSsl0
        !
        csn=csn+1
        symcs=csn
        clocal,symcs,0,0,0,0,ang_intr,0,0
        !
        asel,s,area,,am
        lsla,s
        cm,lset1,line
        adele,am

        lfillt,lm-31,lm-19,rfil2
        lfillt,lm-4,lm-3,rfil2
        !
        lfillt,lm-3,lm-2,rfil3
        lfillt,lm-32,lm-31,rfil3
        !
        *get,km,kp,,num,max
        numstr,kp,km
        !
        *get,lm,line,,num,max
        numstr,line,lm
        !
        *get,am,area,,num,max
        numstr,area,am

        !
        lsel,s,line,,lset1
        lsel,a,line,,lm-3,lm,1
        !
        al,all
        !
        *get,am,area,,num,max
        !
        allsel,all
        !
        lplot

!-------------- 4.3  Symmetry Layout of Complete Model ----------------
!
n_intr=90/ang_intr
!
*do,i,1,n_intr-1,1
    !
    csys,symcs
    !
    arsym,y,am,,,,0,0
    !
    *get,km,kp,,num,max
    numstr,kp,km
    !
    *get,lm,line,,num,max
    numstr,line,lm
    !
    *get,am,area,,num,max
    numstr,area,am
    !
    clocal,symcs,0,0,0,0,ang_intr,0,0
*enddo
!
csys,CSsl0
!
*do,j,1,n_intr,1
    *if,j,eq,1,then
        asel,s,area,,am-(n_intr-j)
    *else
        asel,a,area,,am-(n_intr-j)
    *endif
*enddo
!
arsym,x,all,,,,0,0
!
*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,1,2*n_intr,1
    *if,j,eq,1,then
        asel,s,area,,am-(2*n_intr-j)
    *else
        asel,a,area,,am-(2*n_intr-j)
    *endif
*enddo
!
arsym,y,all,,,,0,0
!
*get,km,kp,,num,max
numstr,kp,km
!
*get,lm,line,,num,max
numstr,line,lm
!
*get,am,area,,num,max
numstr,area,am
!
csys,CSsl1
asel,s,loc,x,d_in/2,d_out/2
!
!aadd,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
!
allsel,all
lplot

! MSH_AREA, mstyp, mshdens, etpa, elmnl, elmxl, ecs, mat, real, perflsz

msh_area,0,1,1,0.1,.15

lamthk=14  !  laminate thickness of 7 mil
r_vltg=0   !   1 = the rotor coils are to have an applied voltage
s_vltg=1   !   0 = the stator coils will not have applied voltage
f_mesh=3   !   makes the elements at the top and bottom of the slot more
           !   coarse. Increasing values makes the mesh more coarse.
           !   f_mesh=1, is the default and has no effect.  f_mesh=2
           !   doubles the size of the elements, f_mesh=3, triples...
stat_id='slotsta'
rotor_id='slotrot'
m_ref=2
v_peak=1.35*sqrt(2)
pi=3.141593
hfreq=47000     !  AC frequency for the coils (HZ)


! *** Laminate geometry data ***
inamp=1          ! Peak amperage (A)
nturn=0          ! Number of turns
mname='ken' ! Name of plot file (extention is .plt)
npole=2          ! Number of poles

! *** Rotor dimensions ***
rtkthk=.154      ! Rotor laminate stack thickness
nconr=2
nrp=2           ! Number of slots in rotor lamination
nrpgen=2        ! Number of rotor poles to be generated for the model
         !  used for arguement in polegen.mac

!  Stator dimensions
stref=2         !  refinement for stator mesh 1=least elements, 2 more, 3 more,,,
stkthk=.210           ! Stator stack length (in)
nmcond=2         !   number of phases in a single slot
ncons=2
!   MATERIAL PROPERTIES DEFINITIONS
!
fini
/prep7
!   material numbers
mpdel,all,all
tbdel,bh,all
mp,murx,1,1         !  air

!    laminate end of stator/rotor
mp,murx,5,9000        !  stator iron
mp,murx,2,9000        !  rotor iron
mp,murx,6,1          !  stator coil
mp,rsvx,20,1/5.8e7
mp,murx,20,1         ! coil region o the whole static
mp,murx,21,700       ! coil region o the whole static

!   coil end material numbers
!   murx = permeability []
!   rsvx = resisitivity [ohm-m]
mp,murx,13,1                    !  stator coil
mp,rsvx,13,1/5.8e7
copper,13           !  7/8/98

!!  coil real constants

!   stator data
ggeom=.0254      !   conversion factor from English to Metric for length
w_stator='ken1'     !   file name for the stator winding is st140.wnd
nsp=8           !   number of stator slots in the complete machine