!   TITLE:  str_tube_slev_375a085.mac (ISS)
!
!----------------------------------------------------------------------
!   Rev -   RELEASED        11/19/2002          J. Rinaldi
!----------------------------------------------------------------------
!
!   This macro creates the stator tube sleeve, 375A085, used in the
!   ISS (International Space Station) end unit CU09616054.
!
!   CSst00: Cartesian Stator Tube Coordinate System
!   CSst01: Cylindrical Stator Tube Coordinate System
!   CSst02: Spherical Stator Tube Coordinate System
!
!
!************************** TABLE OF CONTENTS *************************
!
!           Model Assembly Preparation
!
!       1.  Parameter List
!       2.  Model Coordinate System
!       3.  Solid Model
!           3.1  Cross-Sectional Area
!               3.1.1  Partition Area
!       4.  FE Model
!       5.  Make Specified Symmetry Model
!       6.  Loading, Constraints
!       7.  Solve or Finalize Model
!
!
!********************* Model Assembly Preparation *********************
!
mod_assemb_prep,arg1,arg2,arg3
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>
!
str_tube_slev_375a085.parm
!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate System >>>>>>>>>>>>>>>>>>>>>
!
mod_coord_system,acs,xc,yc,zc,rotxyc,rotyzc,rotzxc
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 3.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
!---------------------- 3.1  Cross-Sectional Area ---------------------
!
csys,CSst01
!
k,,r1,0,0
k,,r3,0,0
k,,r3,0,h5
k,,r4,0,h5
k,,r4,0,(h5+h6)
!
k,,r5,0,(h5+h6)
k,,r5,0,h5+h7
k,,r8,0,h5+h7
k,,r8,0,(h5+h8)
k,,r9,0,(h5+h8)
!
k,,r9,0,(h5+h11)
k,,r6-tol2/2,0,(h5+h11)
k,,r6-tol2/2,0,(h12-tol1)+h5
k,,0,0,(h12-tol1)+h5
k,,0,0,(h13+tol4)+h5
!
k,,r7+tol3/2,0,(h13+tol4)+h5
k,,r7+tol3/2,0,(h5-h10)
k,,r1,0,(h5-h10)
!
create_lines
!
ln_fillet,km-2,rfil3-tol1
ln_fillet,km-2,rfil7
ln_fillet,km-11,rfil6
ln_fillet,km-12,rfil6
ln_fillet,km-20,rfil1
!
ln_fillet,km-20,rfil2
ln_fillet,km-27,rfil4
!
chamfer_area,1,lm-24,lm-23,chmf1
chamfer_area,1,lm-14,lm-13,chmf2
chamfer_area,1,lm-23,lm-22,chmf3
!
create_area-lines
!
lplot
!
!------------------------ 3.1.1  Partition Area -----------------------
!
csys,CSst00
!
create_cs,0,,0,0,0,0,0,90,0
!
ara_create_part,csn+1,90,r5+rfil1
ara_create_part,csn+1,90,r7-1.5*rfil3
!
ara_create_part,csn+1,0,h5+h11+rfil6,,,,0.6
ara_create_part,csn+1,0,h5+(h13+tol4)-(rfil3-tol1)
!
lplot
!
!----------------------------- 4.  FE Model ---------------------------
!
*if,enable,eq,'3d',then
    !
    adele,am-7,,,1
    isolate_areas
    !
    revolve_aset,CSst01,ptang,1
    !
    flng_ptrn_1,CSst01,rbp,h5,nh,rtangle,rtangle,dbh,rbf,rfout,r5+rfil1,rbh,rff
    !
    csys,CSst00
    !
    isolate_areas
    ara_create_part,CSst00,0,0,,,h5
    !
    isolate_areas
    ara_create_part,CSst00,ptang,0,,,h5
    !
    nummrg,kp
    !
    csys,CSst01
    !
    init_entity_num             ! delete unused flange
    isolate_areas
    asel,r,loc,y,ptang,360
    adele,all,,,1
    !
    init_entity_num
    !
    isolate_areas               ! extrude flange
    asel,r,loc,x,rbp
    cm,aset1,area
    isolate_areas
    asel,u,area,,aset1
    extrude_aset,-h6
    !
    isolate_areas               ! extrude flange bolt perimeter
    extrude_aset,h6
    !
    *if,yn_mesh,eq,1,then
        !
        !-------------------- mesh cylinder wall --------------------
        !
        csys,CSst01
        !
        asel,selv,loc,y,0
        asel,r,loc,z,(h5+h11+rfil6),(h13-rfil3)
        !
        *if,sym_,eq,1/12,then
            msh_algorithm,1,3,1,1,,,2,3,.050,.055,1,,,,r5,ptang,0.030
        *else
            msh_algorithm,1,3,1,1,,,2,3,.0650,.070,1,,,,r5,ptang,0.040
        *endif
        !
        !----------------------- mesh end cap -----------------------
        !
        csys,CSst01
        !
        asel,selv,loc,y,0
        asel,r,loc,z,h5+h13-rfil3,h5+h12
        asel,r,loc,x,r7-1.5*rfil3,r6
        !
        *if,sym_,eq,1/12,then
            msh_algorithm,1,3,0,0,,,2,3,.030,.040,1,,,,r5,ptang,0.030
        *else
            msh_algorithm,1,3,0,0,,,2,3,.045,.050,1,,,,r5,ptang,0.040
        *endif
        !
        !------------------- mesh top of end cap --------------------
        !
        csys,CSst01
        !
        asel,s,loc,z,(h12-tol1)+h5
        asel,r,loc,x,0,r7-1.5*rfil3
        !
        calc_l=nint(((h12-tol1)-(h13+tol4))/ellhndof)
        !
        *if,sym_,eq,1/12,then
            msh_algorithm,1,3,0,0,calc_l,,2,3,.060,.070,1,,,,,,
        *else
            msh_algorithm,1,3,0,0,calc_l,,2,3,.060,.070,1,,,,,,
        *endif
        !
        !--------------------- mesh seal support -------------------
        !
        csys,CSst01
        !
        asel,selv,loc,y,0
        asel,r,loc,z,0,h5+h8
        asel,r,loc,x,r7,r5
        !
        vsla,s
        cm,vset1,volu
        !
        *if,sym_,eq,1/12,then
            msh_algorithm,1,3,0,0,,,2,3,.025,.025,1,,,,r5,ptang,
        *else
            msh_algorithm,1,3,0,0,,,2,3,.035,.035,1,,,,r5,ptang,0.040
        *endif
        !
        !------------------------ mesh flange ----------------------
        !
        z=ellhndof
        !
        vsel,s,volu,,vset1                      ! mesh flange
        aslv,s
        asel,r,loc,z,h5
        cm,aset1,area
        asel,selv,loc,z,h5
        asel,u,area,,aset1
        !
        *if,sym_,eq,1/12,then
            msh_algorithm,1,3,0,0,nint(h6/z),,2,3,z,z+.010,1,,,,,,
        *else
            msh_algorithm,1,3,0,0,nint(h6/z),,2,3,z,z+.010,1,,,,,,
        *endif
        !
        nummrg,node
        init_entity_num
        eplot
    *endif
*endif
!
!
*if,enable,eq,'2d',then
    *if,yn_mesh,eq,1,then
        view,'f'
        !
        asel,s,area,,am-7,am-5,2
        asel,a,area,,am-1
        !
        msh_area,1,0,1,esz_2dm,esz_2dm
        !
        asel,s,area,,am-2,am,2
        !
        msh_area,0,0,1,esz_2df,esz_2df
    *endif
*endif
!
!--------------------- 5.  Make Specified Symmetry Model --------------------
!
init_entity_num
!
*if,enable,eq,'3d',then
    *if,sym_,eq,1/2,then
        csys,CSst00
        vsymm,y,all,,,0,0,0
        !
        nummrg,kp
        nummrg,node
    *elseif,sym_,eq,1/1,then
        csys,CSst00
        vsymm,y,all,,,0,0,0
        !
        create_cs,0,0,,0,0,0,-ptang,0,0
        vsymm,y,all,,,0,0,0
        !
        nummrg,kp
        nummrg,node
    *endif
    !
    init_entity_num
*endif
!
!--------------------- 6.  Loading, Constraints --------------------
!
*if,enable,eq,'2d',then
    csys,CSst00
    !
    *if,ptyp,eq,'i',then
        lsel,u,line,,lm-10
        lsel,u,line,,lm-5,lm-2,5-2
        ln_group,km-36,km-6,km-50
    *elseif,ptyp,eq,'x',then
        lsel,u,line,,lm-15,lm-10,15-10
        lsel,u,line,,lm-5,lm-2,5-2
        ln_group,km-37,km-7,km-46
    *endif
    !
    *if,pload,ne,0,then
        sfl,all,pres,pload
    *endif
    !
    init_entity_num
    !
    eplot
    !
    !
    *if,yn_mesh,eq,1,then
        csys,CSst00
        !
        nsel,selv,loc,x,0           ! constrain axis nodes
        d,all,ux
        !
        init_entity_num
        !
        nsel,selv,loc,z,(h5+h6)           ! constrain top bolt surface
        nsel,r,loc,x,(rbp-rbh),(rbp+rbh)
        nsel,r,loc,y,0
        !
        d,all,all
        !
        init_entity_num
        !
        nsel,selv,loc,z,h5                  ! constrain bottom bolt surface
        !
        *if,ptyp,eq,'x',then
            nsel,r,loc,x,r3+3*rfil4,r4
        *elseif,ptyp,eq,'i',then
            nsel,r,loc,x,(rbp-rbh),(rbp+rbh)
        *endif
        !
        nsel,r,loc,y,0
        d,all,all
        init_entity_num
        !
        eplot
    *endif
*endif
!
*if,enable,eq,'3d',then
    !
    csys,CSst00
    !
    lsel,s,loc,y,0
    lsel,u,loc,x,r7-1.5*rfil3
    lsel,u,loc,z,h5+(h13+tol4)-(rfil3-tol1)
    lsel,u,loc,z,h5+h11+rfil6
    !
    ks=kp(0,0,h13+tol4)
    kd=kp(r7-1.5*rfil3,0,h13+tol4)
    ke=kp(r1,0,0)
    !
    ar_group,ks,kd,ke
    asel,u,loc,y,0
    !
    *if,pload,ne,0,then
      sfa,all,,pres,pload
    *endif
    !
    init_entity_num
    !
    eplot
    !
    *if,yn_mesh,eq,1,then
        csys,CSst01
        asel,selv,loc,z,h5
        asel,a,loc,z,h5+h6
        asel,r,loc,x,rbp
        *if,bolt_mis,eq,1,then
           asel,u,loc,y,60,120
           /title,Stator Tube Sleeve 375A085 @ %pload% psi Internal, 1 bolt missing
        *endif
        nsla,s,1
        d,all,all
        !
        init_entity_num
        !
        *if,sym_,ne,1,then
           *if,sym_,eq,1/2,then
              csys,CSst00
              nsel,selv,loc,x,0
           *elseif,sym_,eq,1/12,then
              csys,CSst01
              nsel,s,loc,y,0
              nsel,a,loc,y,ptang
           *endif
           !
           csys,CSst01
           dsym,symm,y,CSst01
           init_entity_num
           eplot
       *endif
    *endif
*endif
!
!------------------------ 7.  Solve or Finalize Model -----------------------
!
*if,sym_,eq,1/1,then
   finalize_model
*else
    *if,slv_,eq,1,then
        finish
        /config,fsplit,250
        /solu
        eqslv,iter,5,3
        solve
        !
        finish
        !
        /post1
        /eface,1
        avprin,0,0,
        !
        plnsol,s,eqv,0,1
        /eface,1
        avprin,0,0,
        !
        *if,enable,eq,'2d',then
            csys,CSst01
            nsel,s,loc,x,0,1.1*(r6-tol2/2)
            esln,s
            plnsol,s,eqv,0,1
            *get,Smax,plnsol,,max
            !
            round_num,Sy/Smax,3
            SFy=num_                ! calculated safety factor @ yield
            round_num,Su/Smax,3
            SFu=num_                ! calculated safety factor @ ultimate
            !
            round_num,(Sy/(FSyR*Smax))-1,3
            MSy=num_                ! calculated margin of safety @ yield
            round_num,(Su/(FSuR*Smax))-1,3
            MSu=num_                ! calculated margin of safety @ ultimate
            !
            round_num,Smax,0
            Smax=num_
            !
            init_entity_num
        *endif
        !
        s=Smax
        p=pload
        y=SFy
        u=SFu
        !
        *if,enable,eq,'2d',then
            *if,ptyp,eq,'i',then
                /title,%p% psi Internal,  Smax=%s%,  SFy=%y%,  MSy=%MSy%,  SFu=%u%,  MSu=%MSu%
            *elseif,ptyp,eq,'x',then
                /title,%p% psi External,  Smax=%s%,  SFy=%y%,  MSy=%MSy%,  SFu=%u%,  MSu=%MSu%
            *endif
        *else
            /title,%p% psi Internal,  Smax=%s%,  SFy=%y%,  MSy=%MSy%,  SFu=%u%,  MSu=%MSu%
        *endif
        !
        view,'f'
    *endif
*endif