!   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=rraceo            ! 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_gbor=repoxyo          ! Inner radius of female part
    r_hub=1.500         ! Outer radius of female part

    !trace=arg1
    !n=arg2
    !dpth_cut=arg3
    !r_cut=arg4
    !astart=arg5
    !ainc=arg6
    !rracei=2.1657/2-.06    ! inner radius of male part
    !rraceo=rracei+trace    ! outer radius of male part (outer bearing race)
    !r_gbor=rraceo          ! (Ro) inner radius of female part
    !r_hub=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 >>>>>>>>>>>>>>>>>>>
!
!------------------------- Element Type ------------------------
!
!et,1,plane82
et,1,plane42
!
!---------------------------------------------------------------
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>

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

!------------------------- 4.1  Azimuth Gimbal ------------------------
!

! Main Circular section
csys,CS11

k
init_entity_num
circle,kp(0,0,0),r_hub
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           ! Keep areas seperated for better mesh control
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_hub
k,,-width/2,1.1*r_hub

create_area,1

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

init_entity_num

csys,CS11
!*do,i,-90,180,180
!   k,,r_gbor,i,0
!*enddo
k,,r_gbor,-90,0
k,,r_gbor,90,0
k,,r_gbor,180,0

create_area,1
!*do,i,2*a,270+2*a,90
!   k,,r_gbor,i,0
!*enddo

!create_area,1

asba,am-1,am,,delete,delete

init_entity_num
!a1=am

numcmp,line

lplot


!
!-------------------- 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_hub,90,0
k,,3*r_hub,-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,rracei,-90,rraceo,90       ! Bearing outer race annulus
cyl4,0,0,rslvi,-90,rslvo,90         ! Steel sleeve annulus
!cyl4,0,0,repoxyi,-90,repoxyo,90        ! Epoxy annulus

ksel,s,loc,x,0                      ! Add lines at end to enclose the
ksel,r,loc,y,rslvo,r_gbor           ! expoxy area

*get,kmax,kp,0,num,max
*get,kmin,kp,0,num,min

l,kmax,kmin

ksel,s,loc,x,0                      ! Add lines at end to enclose the
ksel,r,loc,y,-rslvo,-r_gbor         ! expoxy area

*get,kmax,kp,0,num,max
*get,kmin,kp,0,num,min

l,kmax,kmin

alls,all,kp

csys,CS11                           ! Create the expoxy area
lsel,s,loc,x,rslvo,r_gbor
al,all
alls,all,line

/pnum,line,1
lplot

!
!---------------------- 4.2  Thermal Relief Hole Pattern ---------------------
!
*if,r_cut,ne,0,then
dd=2*r_cut
/title,AAAV Az. Axis Lower Brg Thermal Deflection (d=%dd%)

! HOLE_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang, dhole
HOLE_PATTERN,CS11,rpat,0,,ainc,-80,(3-1)*ainc,2*r_cut
HOLE_PATTERN,CS11,rpat,0,,ainc,-30,ainc,2*r_cut

csys,CS11
asel,s,loc,x,rpat
cm,aset1,area

!RADIAL_ASEL, stype, acs, rlow, rhigh, alow, ahigh, zlow, zhigh
radial_asel,'s',CS11,r_gbor,r_hub,-90,90
asel,u,area,,aset1

*get,am,area,0,num,max
alls
asba,am,aset1,,delete,delete

init_entity_num

lplot

*endif

!
!------------------------- 4.3  Screw Holes -------------------------
!
csys,CS11

!HOLE_PATTERN,csnum,rpat,zpos,numh,anginc,stang,patang,dhole
hole_pattern,CS11,rpat,0,,45+35,-45,45+35,2*rscrew

asel,s,area,,am-1,am,1
cm,ascrew,area

radial_asel,'s',CS11,r_gbor,r_hub,-90,90
asel,u,area,,ascrew
*get,am,area,0,num,max
alls

asba,am,ascrew,,delete,keep
!
init_entity_num
!
k,,1.5*r_gbor,-90
k,,1.5*r_gbor,90
!
create_lines,,1
!
ara_part_line,lm
!
asel,s,loc,y,90,270
!
adele,all,,,1
!
init_entity_num
!
lplot

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

e_epoxy=4*tepoxy
e_min=.04
escrew=.03
eout=.04

!                  (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_ALGORITHM,1,1,1,2,,0,1,,e_epoxy,2*e_epoxy,epoxy,,13
!MSH_ALGORITHM,1,1,1,2,,0,1,,e_epoxy,2*e_epoxy,ala356,,13       ! No Sleeve

!
! 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_ALGORITHM,1,1,1,0,,0,1,,lellen,4*lellen,c416,,13
!MSH_ALGORITHM,1,1,1,3,,0,1,,lellen,4*lellen,ala356,,13 ! No Sleeve

!
! Screws
!
asel,s,area,,ascrew
msh_area,0,0,1,escrew,escrew,,c416

!
! 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,(rracei+rraceo)/2
asll,s,0
MSH_ALGORITHM,1,1,1,3,,0,1,,lellen,4*lellen,c440C,,13

!
! Azimuth Gimbal
!

! Select circular and rectangular area for course line sizing and size
csys,CS10
lsel,s,loc,x,0
lsel,r,loc,y,r_gbor,r_hub
asll,s,0
lsla,s
lesize,all,.5*eout,,,,1



! 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_gbor,r_hub
asll,s,0
lsla
csys,CS11
lsel,r,loc,x,r_gbor,r_gbor+.001
*get,lnum,line,,num,max
lesize,lnum,,,n_div
lsla
mshkey,0
amesh,all               ! Mesh with no lesize'ing


! Azimuth gimbal outer rectangular section
csys,CS10
lsel,s,loc,y,-dback
asll,s,0
MSH_ALGORITHM,1,1,,0,,0,1,,eout,eout,ala356,,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,rraceo
nrotat,all
cpintf,ux

!---------------------- 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

save,tc,db              ! Save DB file for use in tc_stiff.mac
!*go,:skip
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,rracei
nsort,u,x,1,0                   ! Needed for following *get's
*get,uxmax,sort,0,max
*get,uxmin,sort,0,min

! Property extraction
!arry_search,'prop_lab','ALPX'
!propi=hit(1,1)+1
!arry_search,'mat_name','c440C'
!mtrli=hit(1,2)
!alpx440c=mat_prop(propi,mtrli)
mat_extract,'ALPX','c440C'

offset=rracei*ALPX*(Ttest-Troom)
uxmax=uxmax-offset
uxmin=uxmin-offset
/out

alls


! Collect data for plotting
!*msg,,n,r_cut,dpth_cut,astart,ainc,uxmax,uxmin,trace
!%i %g  %g  %g  %g %g %g %g
/nopr
/out,ux_config,out,,append
*vwrite,2*r_cut,uxmax,uxmin
(F18.4,2E18.6)
/out
/gopr

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

tstop

:skip