!   TITLE:  tc.mac
!
!---------------------------------------------------------------------------
!       Rev -   08/16/2000      J. Rinaldi
!       Rev A   08/18/2000      D. Edwards <dee.engineering@usa.net>
!               Added solve section.
!       Rev B   Renamed from thermal_collapse to tc.mac and moved into
!               project directory.
!               Added <arg1> to give the option to build a model representing
!               the surrounding material of the azimuth gimbal or to model
!               just one period of the cut pattern.
!       Rev C   Deleted <arg1> with periodic symmetry.  Added stiffness
!               calculation.
!       Rev D   Added over ride arguments for use with mtc.mac to
!               allow looping over a number of configurations.
!       Rev E   Update model to include an adhevise layer.
!
!---------------------------------------------------------------------------
!
!   This macro tests the concept of angularly intermittent stress relief
!   cuts for thermally dissimilar metals of cylindrical shape and assembled
!   concentrically.
!
!   CS10:           Cartesian Coordinate System
!   CS11:           Cylindrical Coordinate System
!   CS12:           Spherical Coordinate System
!
!   USAGE:  tc
!           tc,tslv,tepoxy      (override parm file)
!
!******************************* TABLE OF CONTENTS **************************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   3.  Material and Element Type
!   4.  Solid Model
!       4.1  Outer perimeter
!       4.2  Surface Cut Patterns
!       4.3  Inner Cylinder
!       4.4  Create Separate Areas with Coincident Entities
!       4.5  Create Section Symmetry
!   5.  FE Model
!       5.1  Mesh Areas
!       5.2  Apply Constraints & Coupling
!           5.2.1  Apply Constraints
!           5.2.2  Apply Coupling
!   6.  Solve
!   7.  Post Processing
!
!***************************** END Table of Contents ************************
!
!************************** Model Assembly Preparation **********************
!
mod_assemb_prep                 ! prepare database for assembly

tstart

/title,Lower Azimuth Bearing w/ Epoxied Sleeve
/units,bin                      ! British/inch units
!
!**************************** End Model Preparation *************************
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>
!
tc.parm

! For plotting purposes, use command line args for key parameters
*if,arg1,ne,0,then
    tslv=arg1               ! Thickness of sleeve
    rslvi=r_mal_o           ! Inner radius of steel sleeve
    rslvo=rslvi+tslv        ! Outer radius
    tepoxy=arg2             ! Bond layer thickness of epoxy
    repoxyi=rslvo           ! Inner radius of bond layer
    repoxyo=repoxyi+tepoxy  ! Outer radius of bond layer

    ! Azimuth Gimbal Bore
    r_fem_i=repoxyo         ! Inner radius of female part
    r_fem_o=1.500           ! Outer radius of female part

    !trace=arg1
    !n=arg2
    !dpth_cut=arg3
    !r_cut=arg4
    !astart=arg5
    !ainc=arg6
    !r_mal_i=2.1657/2-.06   ! inner radius of male part
    !r_mal_o=r_mal_i+trace  ! outer radius of male part (outer bearing race)
    !r_fem_i=r_mal_o        ! (Ro) inner radius of female part
    !r_fem_o=1.500          ! (ro) outer radius of female part
*endif

!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate Systems >>>>>>>>>>>>>>>>>>>>
!
mod_coord_system,0,0,0,0,0,0,0
!
!<<<<<<<<<<<<<<<<<<<< 3.  Material and Element Type >>>>>>>>>>>>>>>>>>>
!
!---------------------- Material Properties --------------------
!
alum=1                  ! Material:  Aluminum A356-T6 azimuth gimbal
cres=2                  ! 440C CRES inner race
epoxy=3                 ! Bacon Ind. LCA-4 Low expansion adhesive

mp,EX,alum,EXalum
mp,dens,alum,DENSalum
mp,nuxy,alum,NUXYalum
mp,alpx,alum,ALPXalum

mp,EX,cres,EXcres
mp,dens,cres,DENScres
mp,nuxy,cres,NUXYcres
mp,alpx,cres,ALPXcres

mp,EX,epoxy,EXepx
mp,dens,epoxy,DENSepx
mp,nuxy,epoxy,NUXYepx
mp,alpx,epoxy,ALPXepx

!
!------------------------- Element Type ------------------------
!
!ET,1,plane82
ET,1,plane42
!
!---------------------------------------------------------------
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>

/VIEW, 1 ,,,1
/ANG, 1

!------------------------- 4.1  Outer Part ------------------------
!
csys,CS11
!
*do,i,0,270,90
    k,,r_fem_o,i,0
*enddo
!
create_area,1

! Add rectangular section
csys,CS10
k,,-width/2,-dfront
k,,-width/2,-dback
k,,width/2,-dback
k,,width/2,-dfront

create_area,1

!aadd,am-2,am
asba,am,am-1,,delete,keep
aglue,all
init_entity_num

! Cut front edge to give mirror support clearance
csys,CS10
k,,-width/2,dcut
k,,width/2,dcut
k,,width/2,1.1*r_fem_o
k,,-width/2,1.1*r_fem_o

create_area,1

asba,am-2,am,,delete,delete

init_entity_num
!
csys,CS11
!*do,i,-90,180,180
    !k,,r_fem_i,i,0
!*enddo
k,,r_fem_i,-90,0
k,,r_fem_i,90,0
k,,r_fem_i,180,0
!*do,i,2*a,270+2*a,90
!   k,,r_fem_i,i,0
!*enddo
!
create_area,1
!
asba,am-1,am,,delete,delete

init_entity_num
a1=am

numcmp,line

lplot
!
!---------------------- 4.2  Surface Cut Patterns ---------------------
!
*if,n,ne,0,then
/title,AAAV Az. Axis Lower Brg Thermal Deflection (n=%n%, ainc=%ainc%)

! HOLE_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang, dhole
!
rpat=r_fem_i-(r_cut-dpth_cut)

HOLE_PATTERN,CS11,rpat,0,,ainc,180-astart,(n-1)*ainc,2*r_cut

init_entity_num

asel,s,area,,am-(n-1),am,1
cm,aset1,area

init_entity_num

asba,a1,aset1,,delete,delete

init_entity_num
numcmp,line

lplot

*endif
!
!-------------------- 4.5  Create Section Symmetry --------------------
!

! Use vertical plane symmetry

!asel,s,area,,am-5,am,5     ! Select all areas
!cm,aset1,area
!
csys,CS11                   ! Create the parting line
k,,3*r_fem_o,90,0
k,,3*r_fem_o,-90,0
!
create_lines
!
!asbl,aset1,lm,,delete,delete   ! Seperate the two halves
asbl,all,lm,,delete,delete  ! Seperate the two halves
!
init_entity_num

csys,CS10
asel,s,loc,x,-width,0
adele,all,,,1

init_entity_num
!
!------------------------- 4.3 Create concentric areas ---------------
!
csys,CS10

cyl4,0,0,r_mal_i,-90,r_mal_o,90     ! Bearing outer race annulus
cyl4,0,0,rslvi,-90,rslvo,90         ! Steel sleeve annulus
cyl4,0,0,repoxyi,-90,repoxyo,90     ! Epoxy annulus

init_entity_num
/pnum,line,1
lplot

*go,:skip

!
!------------------------ 4.4 Divide up concentric areas -------------
!
!k,,0,0
!k,,r_fem_o

!create_lines

!csys,CS10
!lsel,s,loc,x,0
!lsel,r,loc,y,r_mail_i,r_fem_i
!asll,s,0
!lsel,s,line,,lm
!asbl,all,lm,,delete,delete

!init_entity_num

!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<< 5.  FE Model >>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!--------------------------- 5.1  Mesh Areas --------------------------
!

e_epoxy=tepoxy*4
e_min=.05

!                  (1)      (2)     (3)     (4)      (5)       (6)     (7)   (8)
! MSH_ALGORITHM, perflsz, perfmsh, mstyp, mshdens, elmszovr, atargov, etpa, etpv,
!
!                elmnl, elmxl, mtrl, rl, ecs, volsel, sprat, radrot, varcang
!                 (9)    (10)  (11) (12) (13)  (14)   (15)    (16)     (17)
!

!
! Epoxy bond layer
!
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,(repoxyi+repoxyo)/2
asll,s,0
MSH_new,1,1,1,2,,0,1,,e_epoxy,4*e_epoxy,epoxy,,13

!
! Steel sleeve
!
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,(repoxyi+repoxyo)/2
asll,s,0
csys,CS11
lsla
lsel,r,loc,x,repoxyi,repoxyi+tepoxy/3
*get,lnum,line,,num,max
*get,n_div,line,lnum,attr,ndiv
*get,llen,line,lnum,leng
lellen=llen/n_div
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,(rslvi+rslvo)/2
asll,s,0
MSH_new,1,1,1,1,,0,1,,lellen,4*lellen,cres,,13

!
! Bearing outer race
!
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,(rslvi+rslvo)/2
asll,s,0
lsla
csys,CS11
lsel,r,loc,x,rslvi
*get,lnum,line,,num,max
*get,n_div,line,lnum,attr,ndiv
*get,llen,line,lnum,leng
lellen=llen/n_div
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,(r_mal_i+r_mal_o)/2
asll,s,0
MSH_new,1,1,1,1,,0,1,,lellen,4*lellen,cres,,13

!
! Azimuth Gimbal
!

! Select rectangular area for course line sizing and size
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,r_fem_i,r_fem_o
asll,s,0
MSH_new,1,0,,1,,0,1,,.5*e_min,5*e_min   ! Line size only

! Get line sizing of outer radius of epoxy layer
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,(repoxyi+repoxyo)/2
asll,s,0
lsla
csys,CS11
lsel,r,loc,x,repoxyo,repoxyo+tepoxy
*get,lnum,line,,num,max
*get,n_div,line,lnum,attr,ndiv
*get,llen,line,lnum,leng
lellen=llen/n_div

! resize inner radius to match outer radius of epoxy
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,r_fem_i,r_fem_o
asll,s,0
lsla
csys,CS11
lsel,r,loc,x,r_fem_i,r_fem_i+tepoxy
*get,lnum,line,,num,max
lesize,lnum,,,n_div
lsla
!mshkey,0
!amesh,all              ! Mesh with no lesize'ing
MSH_new,0,1,,0,,0,1,,lellen,10*e_min,alum,,13   ! Mesh with no lesize'ing

! Azimuth gimbal outer rectangular section
csys,CS10
lsel,s,loc,y,-dback
asll,s,0
MSH_new,1,1,,0,,0,1,,4*e_min,8*e_min,alum,,13


init_entity_num

lplot
!
!----------------- 5.2  Apply Constraints & Coupling ------------------
!

!
!----------------------- 5.2.1  Apply Coupling ------------------------
!

! Couple the Outer Race to the Sleeve
csys,CS11               ! Rotate all radial coupled nodes
nsel,s,loc,x,r_mal_o
nrotat,all
cpintf,ux

! Couple the epoxy layers
nsel,s,loc,x,rslvo,rslvo+.1*tepoxy
nsel,a,loc,x,repoxyo,repoxyo+.1*tepoxy
nrotat,all
cpintf,ux
cpintf,uy

!---------------------- 5.2.2  Apply Constraints ----------------------
!
! NOTE:  The above nodal cs roatations put the x-axis vertical on the
!        plane of symmetry.  The symmetry constraint must be applied
!        in the uy direction.

! Constrain vertical line of symmetry in the hoiz. direction
csys,CS10
nsel,s,loc,x,0

csys,CS11
nrotat,all              ! Make all nodal CS's on symm plane the same!

csys,CS10
d,all,uy                ! Contrain in horizontal direction

! Constrain bottom edge
nsel,s,loc,y,-dback
nsel,u,loc,x,0          ! Unsel bottom center
cm,nbottom,node
d,all,uy                ! Vertical contraints (except bottom center node)
alls
ncorner=node(0,-dback,0)
d,ncorner,ux                ! Constrain center bottom node vert. (rotated nodal cs)

init_entity_num

!
!----------------------- 6  Solve -----------------------
!
alls
fini

! Perform an initial solve to get dicplacement of race center
/solu
antype,0
tunif,Ttest
tref,Troom
solv
fini

! Store thermal movement of center in y
/post1
/out,yoffset,out
csys,CS10
nsel,s,loc,y,0
*get,nmx_,node,0,mxloc,x
nm_=node(nmx_,0,0)
*get,uy0,node,nm_,u,y
/out
alls
fini


! Delete lower BC's and reapply with displacement uy0
/prep7
csys,CS10
cmsel,s,nbottom
ddele,all,uy
d,all,uy,-uy0
alls
ddele,ncorner,ux
d,ncorner,ux,uy0
fini

! Solve again with compensated initial displacement
/solu
antype,0
tunif,Ttest
tref,Troom
solv
fini

!
!----------------------- 7  Process Thermal Results -------------------
!

! Show a displacement dither plot
/post1
rsys,CS11     ! Use cylindrical coordinates to get radial displacements
/dscale,1,10    ! Set the deflection scale
/eface,1
avprin,0,0
plnsol,U,X,2,1  ! Show radial displacements

! Get statistics on radial displacement of the inner radius
/out,yoffset,out,,append
rsys,CS11
csys,CS11
nsel,s,loc,x,r_mal_i
nsort,u,x,1,0                   ! Needed for following *get's
*get,uxmax,sort,0,max
*get,uxmin,sort,0,min
offset=r_mal_i*ALPXcres*(Ttest-Troom)
uxmax=uxmax-offset
uxmin=uxmin-offset
/out

alls

fini

! Collect data for plotting
!*msg,,n,r_cut,dpth_cut,astart,ainc,uxmax,uxmin,trace
!%i %g  %g  %g  %g %g %g %g
/out,ux_config,out,,append
*msg,,n,tslv,tepoxy,uxmax,uxmin
%i %g %g %g %g
/out

*if,arg1,eq,0,then
    *uilist,ux_config,out
*endif

:skip
tstop