!   TITLE:  tc_top.mac (AAAV)
!
!-----------------------------------------------------------------------
!       Rev -       04/03/2001      J. Rinaldi/D. Edwards
!-----------------------------------------------------------------------
!
!   This macro creates the 2D thermal model of the gimbal upper azimuth
!   bearing assembly for AAAV.
!
!   CSgim0: Cartesian Gimbal Coordinate System
!   CSgim1: Cylindrical Gimbal Coordinate System
!   CSgim2: Spherical Gimbal Coordinate System
!
!
!******************************* TABLE OF CONTENTS *********************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   3.  Solid Model
!       3.1  Center Section
!       3.2  Wing Sections
!       3.3  Screw Holes
!       3.4  Bearing Sleeve
!       3.5  Stress Relief Cuts
!       3.6  Bearing Outer Race
!       3.7  FE Model
!
!
!********************* Model Assembly Preparation **********************
!
!
mod_assemb_prep             ! prepare database for assembly

tstart

/title,Upper Az. %mfg% outer race (dhole=2*%r_cut%)

/units,bin                  ! British/inch units
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>
!
pcnt_act=arg1

tc_top_mpb.parm             ! Read parameter file
!tc_top_nhbb.parm           ! Read parameter file

!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate Systems >>>>>>>>>>>>>>>>>>>>
!
mod_coord_system,0,0,0,0,0,0,0
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<< 3. Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!

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

!
!------------------------- 3.1  Center Section ----------------------
!
csys,CSgim0

cyl4,0,0,dhubo/2
init_entity_num

lplot

!
!------------------------- 3.2  Wing Sections -----------------------
!
csys,CSgim0

k,,-(pcnt_act/100)*(l11-l7),-(l6-(l9+l10)),0
k,,(pcnt_act/100)*(l5-(l11-l7)),-(l6-(l9+l10)),0
k,,(pcnt_act/100)*(l5-(l11-l7)),(l9+l10),0
k,,-(pcnt_act/100)*(l11-l7),(l9+l10),0
!
create_area
asba,am,am-1,,delete,keep
aglue,all
init_entity_num

cyl4,0,0,r_gbor
init_entity_num

*if,pcnt_act,ge,106,then
    asba,am-3,am,,delete,delete
*else
    asba,am-5,am,,delete,delete
*endif
init_entity_num

k,,0,-2*r_gbor,0
k,,0,2*r_gbor,0
!
create_lines,,1
!
ara_part_line,lm
!
asel,s,loc,x,0,-10
!
adele,all,,,1
!
init_entity_num
cm,aset1,area
!
lplot
!
!------------------------- 3.3  Screw Holes -------------------------
!
csys,CSgim1

hole_pattern,CSgim1,rscrwpat,0,,ainc,astart,2*abs(astart),2*rscrwh
!
asel,s,area,,am-8,am,1
cm,aset2,area
!
init_entity_num
!
asba,aset1,aset2,,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
!
!------------------------ 3.4  Bearing Sleeve -----------------------
!
csys,CSgim1

cyl4,0,0,rslvi,,rslvo
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

radial_asel,'u',CSgim1,rslvi,r_gbor,-90,90
cm,aset1,area

init_entity_num

lplot
!
!---------------------- 3.5  Stress Relief Cuts ---------------------
!

*if,r_cut,gt,0,then

csys,CSgim1

!HOLE_PATTERN, csnum, rpat, zpos, numh, anginc, stang, patang, dhole
hole_pattern,CSgim1,r_pat,0,2,,270+phi,ainc-2*phi,2*r_cut
!hole_pattern,CSgim1,r_pat,0,2,,270+22.5+phi,ainc-2*phi,2*r_cut

asel,s,area,,am-1,am

cir_ara_pattern,8,,180-ainc
!cir_ara_pattern,6,,135-ainc

cmsel,u,aset1
radial_asel,'u',CSgim1,rslvi,r_gbor,-90,90
cm,aset2,area

init_entity_num

asba,aset1,aset2,,delete,delete

init_entity_num

aglue,all

init_entity_num

radial_asel,'s',CSgim1,rslvi,r_gbor,-90,90
cm,aset1,area

atran,CSgim1,all,,,,1,0

adele,aset1,,,1

init_entity_num

lplot

*endif

!
!---------------------- 3.6  Bearing Outer Race ---------------------
!
csys,CSgim1

cyl4,0,0,rracei,,rraceo

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

!
!--------------------------- 3.7  FE Model --------------------------
!
!
!            (1)     (2)     (3)   (4)    (5)    (6)    (7)  (8)   (9)
! MSH_AREA, mstyp, mshdens, etpa, elmnl, elmxl, lszmsh, mat, real, ecs
!
csys,CSgim1

! Mesh screw holes
radial_asel,'s',CSgim1,rracei,dhubo/2,-90,90
asel,r,loc,x,rscrwpat
cm,ascrew,area
msh_area,0,0,1,esize,esize,,c416

! Mesh bearing race
radial_asel,'s',CSgim1,rracei,rraceo,-90,90
msh_area,0,0,1,esize,esize,,c440c

! Mesh sleeve
radial_asel,'s',CSgim1,rslvi,rslvo,-90,90
msh_area,0,0,1,esize,esize,,c416
!msh_area,0,0,1,esize,esize,,alum           ! No sleeve also see line 281

! Mesh gimbal bore
radial_asel,'s',CSgim1,r_gbor,dhubo/2,-90,90
asel,u,area,,ascrew
msh_area,0,0,1,esize,esize,,alum

! Mesh gimbal wing section
radial_asel,'u',CSgim1,rracei,dhubo/2,-90,90
msh_area,0,1,1,ewing*esize,ewing*esize,,alum

lplot
!
!----------------- 4.0  Apply Constraints & Coupling ------------------
!

!
!----------------------- 4.1  Apply Coupling ------------------------
!

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

! Couple the Sleeve to the gimbal
csys,CSgim1             ! Rotate all radial coupled nodes
nsel,s,loc,x,r_gbor
nrotat,all
cpintf,ux
!cpintf,all                 ! For case with no sleeve


!---------------------- 4.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,CSgim0
nsel,s,loc,x,0

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

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

! Constrain the bottom corner on the plane of symm.
csys.CSgim0
nsel,s,loc,x,0
nsel,r,loc,y,-dhubo/2,-(1.1*dhubo/2)
d,all,ux

!
!----------------------- 5  Solve -----------------------
!
alls

save,gimb_therm_up_az_bearing,db    ! Save DB file for use in tc_stiff.mac

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,CSgim0
nsel,s,loc,y,0
*get,nmx_,node,0,mnloc,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,CSgim0
nsel,s,loc,y,-dhubo/2,-(1.1*dhubo/2)
ddele,all,ux
d,all,ux,uy0
alls
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,CSgim1     ! Use cylindrical coordinates to get radial displacements
/dscale,1,200    ! 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,CSgim1
csys,CSgim1
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
offset=rracei*ALPX440C*(Ttest-Troom)
uxmax=uxmax-offset
uxmin=uxmin-offset
/out

alls

! Collect data for plotting
/nopr
/out,ux_top_%mfg%,sum,,append
*vwrite,pcnt_act,t_wall,2*r_cut,r_pat,uxmax,uxmin,phi
(F4.0,3F10.4,2E18.5,F8.2)
/out
/gopr

*if,arg1,eq,0,then
    *uilist,ux_top_%mfg%,sum
*endif

csys,CSgim1
nsel,s,loc,x,rracei
cm,nrace,node

!rplot_nodal,CSgim1,'y','u','x'

tstop
:skip