!   TITLE:  str_tube_slev_375a109.mac (TRW)
!
!----------------------------------------------------------------------
!   Rev -   RELEASED        11/19/2002          J. Rinaldi
!----------------------------------------------------------------------
!
!   This macro creates the stator tube sleeve, 375A109, used in the
!   ISS (International Space Station) end unit CU09616055.
!
!   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_375a109.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)
!
*if,sym_,eq,1/2,then
    csys,CSst00
    !
    asel,s,loc,z,h5+h11+rfil6,h5+h12
    adele,all,,,1
    init_entity_num
*endif
!
lplot
!
!----------------------------- 4.  FE Model ---------------------------
!
*if,enable,eq,'3d',then
    !
    *if,sym_,eq,1/2,then
        adele,am-5,,,1
    *else
        adele,am-7,,,1
    *endif
    !
    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
    !
    nummrg,kp
    init_entity_num
    !
    lplot
    !
    *if,yn_mesh,eq,1,then
        !
        !--------------------- 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,0.020,0.020,1,,,,r5,ptang,
        *else
            !msh_algorithm,1,3,0,0,,,2,3,0.025,0.025,1,,,,r5,ptang,
            msh_algorithm,1,3,0,0,,,2,3,0.030,0.030,1,,,,r5,ptang,
        *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,0.6*z,0.6*z,1,,,,,,
        *else
            !msh_algorithm,1,3,0,0,nint(h6/z),,2,3,0.6*z,0.6*z,1,,,,,,
            msh_algorithm,1,3,0,0,nint(h6/z),,2,3,z,z,1,,,,,,
        *endif
        !
        !-------------------- mesh cylinder wall --------------------
        !
        *if,sym_,ne,1/2,then
            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,0,1,,,2,3,0.065,0.070,1,,,,r5,ptang,
            *else
                msh_algorithm,1,3,0,1,,,2,3,0.065,0.070,1,,,,r5,ptang,0.040
            *endif
        *endif
        !
        !----------------------- mesh end cap -----------------------
        !
        *if,sym_,ne,1/2,then
            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,0.030,0.040,1,,,,r5,ptang,
            *else
                msh_algorithm,1,3,0,0,,,2,3,0.045,0.050,1,,,,r5,ptang,
            *endif
        *endif
        !
        !------------------- mesh top of end cap --------------------
        !
        *if,sym_,ne,1/2,then
            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,0.040,0.040,1,,,,,,
            *else
                msh_algorithm,1,3,0,0,calc_l,,2,3,0.040,0.040,1,,,,,,
            *endif
        *endif
        !
        init_entity_num
        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
    *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
    *endif
    !
    init_entity_num
    nummrg,node
    nummrg,kp
    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
!







!*go,:skip1



*if,enable,eq,'3d',then
    *if,sym_,ne,1/2,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
            create_cs,0,'CSbh01',1,rbp,ptang,0,0,0,0    !
            nsel,selv,loc,z,h5  !
            nsel,r,loc,x,0,rbf  !
            nsel,r,loc,y,315,360    !
            !
            *if,bolt_mis,eq,1,then
               asel,u,loc,y,60,120
               /title,Stator Tube Sleeve 375A109 @ %pload% psi Internal, 1 bolt missing
            *endif
            !
            d,all,uz
            !
            init_entity_num
            !
            csys,CSst01
            asel,selv,loc,z,h5
            asel,a,loc,z,h5+h6
            asel,r,loc,x,rbp
            asel,r,loc,z,h5+h6
            !
            *if,bolt_mis,eq,1,then
               asel,u,loc,y,60,120
               /title,Stator Tube Sleeve 375A109 @ %pload% psi Internal, 1 bolt missing
            *endif
            !
            asum
            *get,b_area,area,,area
            f_pres=(pi*(r1**2))*pload
            b_pres=(f_pres/b_area)/(2*nh)
            b_forc=b_pres*b_area*(2*nh)
            sfa,all,,pres,b_pres
            !
            init_entity_num
            !
            *if,sym_,ne,1,then
                *if,sym_,eq,1/2,then
                    csys,CSst00
                    nsel,selv,loc,x,0
                    d,all,ux
                *elseif,sym_,eq,1/12,then
                    csys,CSst01
                    nsel,s,loc,y,0
                    nsel,a,loc,y,ptang
                    nsel,u,loc,x,0
                    nrotat,all
                    dsym,symm,y,CSst01
                    d,all,uy
                    nsel,s,loc,x,0
                    d,all,ux
                    d,all,uy
                *endif
                !
                init_entity_num
                !
                eplot
           *endif
        *endif
    *else
        csys,CSst01
        !
        asel,s,loc,z,h5+h11+rfil6
        !
        a_top=pi*((r6-tol2/2)**2-(r7+tol3/2)**2)
        f_cpres=(pi*(r7**2))*pload
        c_pres=f_cpres/a_top
        sfa,all,,pres,-c_pres
        !
        lsel,s,loc,y,0
        ar_group,km-275,km-274,km-309
        asel,u,loc,y,0
        sfa,all,,pres,pload
        !
        init_entity_num
        !
        *do,i,270,390,60
            csys,CSst01
            create_cs,0,'CSbh%i%',1,rbp,i,0,0,0,0
            !
            a=50
            nsel,selv,loc,z,h5
            nsel,r,loc,x,0,rbf
            nsel,r,loc,y,360-a,360+a
            !
            d,all,uz
            init_entity_num
        *enddo
        !
        f_pres=(pi*(r1**2))*pload
        b_area=pi*((rbh**2)-((dbh/2)**2))
        b_pres=(f_pres/b_area)/5
        !
        *do,i,270,390,60
            csys,CSbh%i%
            !
            asel,selv,loc,z,h5+h6
            asel,r,loc,x,0,rbh
            nsla,s,1
            !
            sfa,all,,pres,b_pres
            init_entity_num
        *enddo
        !
        csys,CSst00
        nsel,s,loc,x,0
        d,all,ux
        init_entity_num
    *endif
*endif
!
eplot
!
!------------------------ 7.  Solve or Finalize Model -----------------------
!


*go,:skip1



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


:skip1