!   TITLE:  str_tube_slev_375a080-2.mac (ISS)
!
!---------------------------------------------------------------------------
!   Rev -   RELEASED        11/06/2000          J. Rinaldi
!---------------------------------------------------------------------------
!   Rev A                   01/17/2001          J. Judd, J. Rinaldi
!
!           Added capabilities for maximizing selection of solid model
!           entities by location.  Decreased 3D model symmetry angle
!           from 90 to 30 degrees for pressure analyses.  Created a
!           separate end-cap volume to eliminate sweeping around an
!           axis.  Incorporated full 3D model code for assembly analysis.
!---------------------------------------------------------------------------
!
!       This macro creates the stator tube sleeve, 375A080, used in the
!       ISS (International Space Station) end unit CU09616052.  The analysis
!       is for stresses due to pressure effects. The analysis is performed
!       for the worst case (minimum material condition) tolerances of the
!       part; under the specified loading conditions.  The tolerances are
!       listed in the parameter section. (See table of contents)
!
!       This analysis consists primarily of an axisymmetric model, but a 3d
!       model may be created to verify results.  The 3d section of code may be
!       disabled for an axissymmetric mode only.  This is done by the 'enable'
!       parameter at the end of section 1. (Parameter List)
!
!       stCS00: Cartesian Stator Tube Coordinate System
!       stCS10: Cylindrical Stator Tube Coordinate System
!       stCS20: Spherical Stator Tube Coordinate System
!
!******************************* TABLE OF CONTENTS **************************
!
!           Model Assembly Preparation
!
!       1.  Parameter List
!       2.  Model Coordinate System
!       3.  Material and Element Type
!       4.  Solid Model
!               4.1  Cross-Sectional Area
!                       4.1.1  Partition Area
!       5.  FE Model
!              5.1   Specified Symmetry Model
!       6.  Loading, Constraints
!       7.  Solve or Finalize Model Data
!
!************************** Model Assembly Preparation **********************
!
!
mod_assemb_prep                       ! prepare database for assembly
!
/units,bin                            ! British/inch units
! /DEV,FONT,ENTITY,MENU
/dev,font,2,Courier*New,400,0,-12,0,0,,,
!
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>
!
! The 'enable' parameter determines the type of model to
! create. If enable='3d', then a 3 dimensional solid model
! will be generated, and a 3D analysis performed. For enable=2d,
! an axissymmetric model will be generated and analyzed.
!
!
str_tube_slev_375a080-2.parm
!
*if,assemble,ne,1,then
    *ask,enable,Analyze 2D or 3D model,'2d'
    !
    *IF,enable,EQ,'3d',THEN
        *ask,sym_,(1/12) or (1/2) or (1/1) model symettry,1/12
        !
        *if,sym_,eq,1/2,then
            *ask,bolt_mis,bolt missing=1 or not missing=0,0
        *endif
        !
        *IF,sym_,EQ,1/2,THEN
            ptang=90
        *ELSEIF,sym_,EQ,1/1,THEN
            ptang=90
        *ENDIF
    *ELSEIF,enable,EQ,'2d',THEN
        *ask,ptyp,INTERNAL(i) or EXTERNAL(x) pressure,'i'
    *ENDIF
    !
    *if,sym_,NE,1/1,THEN
        *ask,yn_mesh,Mesh model (False=0, True=1),0
    *endif
    !
    *IF,yn_mesh,EQ,1,THEN
        *IF,enable,EQ,'3d',THEN
            *ask,elordr,high-h or low-l order element,'l'
        *ENDIF
        !
        *ask,pload,Pressure Load,0
        *ask,slv_,SOLVE this model now (True=1),0
    *ENDIF
*endif
!
!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate Systems >>>>>>>>>>>>>>>>>>>>
!
!
*IF,enable,EQ,'2d',THEN
    mod_coord_system,0,0,0,0,0,-90,0
*ELSE
    mod_coord_system,0,0,0,0,0,0,0
*ENDIF
!
!
!<<<<<<<<<<<<<<<<<<<< 3.  Material and Element Type >>>>>>>>>>>>>>>>>>>
!
!
!---------------------- Material Properties --------------------
!
UIMP,1,EX, , ,29.0E6,             ! Material:  304L / 316L CRES
UIMP,1,DENS, , ,0.286/g_bin,
UIMP,1,NUXY, , ,0.27,
!
!------------------------- Element Type ------------------------
!
ET,1,plane82,,,1,
!
*IF,yn_mesh,EQ,1,THEN
    *IF,enable,EQ,'3d',THEN
        *if,sym_,ne,1,then
            *if,elordr,eq,'h',then
                ET,2,shell93
                ET,3,solid95
            *elseif,elordr,eq,'l',then
                ET,2,shell63
                ET,3,solid45
            *endif
        *endif
    *endif
*ENDIF
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.  Solid Model >>>>>>>>>>>>>>>>>>>>>>>>>>
!
*if,pload,ne,0,then
    *IF,enable,EQ,'2d',THEN
        *if,ptyp,eq,'i',then
            /title,Stator Tube Sleeve 375A080 @ %pload% psi Internal
        *elseif,ptyp,eq,'x',then
            /title,Stator Tube Sleeve 375A080 @ %pload% psi External
        *endif
    *else
        /title,Stator Tube Sleeve 375A080 @ %pload% psi Internal
    *endif
*else
    /title,Stator Tube Sleeve 375A080
*endif
!
!---------------------- 4.1  Cross-Sectional Area ---------------------
!
csys,stCS10
!
k,,r1,0,h1                !1  seal lip
k,,r3,0,h1
k,,r3,0,h5
k,,r4,0,h5
k,,r4,0,(h5+h6)
!
k,,r5,0,(h5+h6)         !11 = housing sleeve connection area
k,,r5,0,h5+h6+h7
k,,r8,0,h5+h6+h7
k,,r8,0,(h5+h8)
k,,r9,0,(h5+h8)
!
k,,r9,0,(h5+h11)
k,,r6,0,(h5+h11)
k,,r6,0,h12
k,,0,0,h12
k,,0,0,h13
!
k,,r7,0,h13
k,,r7,0,(h5-h10)
k,,r1,0,(h5-h10)
!
create_lines
!
ax1=km-4
ax2=km-3
!
lfillt,lm-3,lm-2,rfil3
lfillt,lm,lm-1,rfil7
lfillt,lm-8,lm-7,rfil6
lfillt,lm-7,lm-6,rfil6
lfillt,lm-13,lm-12,rfil1
!
lfillt,lm-11,lm-10,rfil2
lfillt,lm-16,lm-15,rfil4
!
chamfer_area,1,lm-17,lm-16,chmf1
chamfer_area,1,lm-17,lm-18,chmf3
chamfer_area,1,lm-19,lm-18,chmf2
!
create_area-lines
!
lplot
!
!------------------------ 4.1.1  Partition Area -----------------------
!
csys,stCS10

k,,r10,0,0                      ! flange partition line
k,,r10,0,1.1*h5
create_lines,,1
lsel,s,line,,lm-38
lsel,a,line,,lm
ln_part_ln,lm

k,,r5+rfil1,0,0                      ! flange partition line
k,,r5+rfil1,0,h5+h8
create_lines,,1

k,,r5,0,h13-rfil3                    ! top partition line
k,,0,0,h13-rfil3
create_lines,,1

k,,r9,0,h5+h11+rfil6                 ! bottom partition line
k,,0,0,h5+h11+rfil6
create_lines,,1

k,,r7-rfil3,0,0.5*h12                ! top enclosure
k,,r7-rfil3,0,1.5*h12
create_lines,,1

isolate_lines
cm,lset1,line
!
init_entity_num
ara_part_line,'lset1'
lplot
!
!----------------------------- 5.  FE Model ---------------------------
!
*if,enable,eq,'3d',then
        !
        adele,am-4,,,1     !changed 3 to 4 due to extra area
        isolate_areas
        revolve_aset,ax1,ax2,ptang,1    !ptang redefined from parm file in this macro

        init_entity_num

        flng_ptrn_1,stCS10,rbp,h5,nh,rtangle,rtangle,dbh,rbf,rfout,r5+rfil1,rbh,rff

        csys,stCS10
        max_enty_dim,'l'

        k,,3*max_leng,0,h5             !Create line for splitting flange
        k,,3*max_leng,180,h5
        create_lines,,1

        k,,3*max_leng,-ptang,h5        !Create line for splitting flange
        k,,3*max_leng,180-ptang,h5
        create_lines,,1

        isolate_lines                  !Make split lines into component
        cm,lset1,line
        !
        init_entity_num                !split flange areas
        isolate_areas
        ara_part_line,'lset1'
        !
        nummrg,kp
        !
        init_entity_num             !delete of flange to match tube section
        isolate_areas
        asel,r,loc,y,0,360-ptang
        adele,all,,,1

        init_entity_num

        isolate_areas               !extrude flange minus bolt perimeters
        asel,r,loc,x,rbp
        cm,aset1,area
        isolate_areas
        asel,u,area,,aset1
        extrude_aset,-h6
        !
        isolate_areas               ! extrude flange bolt perimeters
        extrude_aset,h6

        *IF,yn_mesh,EQ,1,THEN
                asel,selv,loc,y,0                        ! mesh cylinder wall
                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

                asel,selv,loc,y,0                        ! mesh end cap
                asel,r,loc,z,(h13-rfil3),h12
                asel,r,loc,x,(r7-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

                asel,selv,loc,z,h12                      ! mesh top of end cap
                asel,r,loc,x,0,(r7-rfil3)
                *IF,sym_,EQ,1/12,THEN
                    msh_algorithm,1,3,0,0,,,2,3,.060,.070,1,,,,,,
                *ELSE
                    msh_algorithm,1,3,0,0,,,2,3,.060,.070,1,,,,,,
                *ENDIF
                !
                asel,selv,loc,y,0                        ! mesh seal support
                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

                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
                aclear,all
                nummrg,all
                init_entity_num
                eplot
         *ENDIF
        !
*endif
!
!
*if,enable,eq,'2d',then
    *IF,yn_mesh,EQ,1,THEN
        /VIEW, 1 ,,,1
        /ANG, 1
        lplot
        !
        asel,s,area,,am-2
        !
        msh_algorithm,1,1,1,3,,,1,,0.006,0.009,1,,,,,,
        !
        asel,s,area,,am-4,am-3,1
        asel,a,area,,am-1,am,1
        !
        msh_algorithm,1,1,0,,,,1,,0.008,0.013,1,,,,,,
    *ENDIF
*endif
!
!--------------------- 5.1  Make Specified Symmetry Model --------------------
!
init_entity_num
!
*IF,enable,EQ,'3d',THEN
    *IF,sym_,EQ,1/2,THEN
       csys,stCS00   $wpcsys
       VSYMM,Y,all,,,0,0,0
    *ELSEIF,sym_,EQ,1/1,THEN
       csys,stCS00   $wpcsys
       VSYMM,Y,all,,,0,0,0

       csys,stCS00   $wpcsys
       create_cs,0,0,,0,0,0,-ptang,0,0
       VSYMM,Y,all,,,0,0,0
    *ENDIF
    nummrg,all
    init_entity_num
*ENDIF
!
!--------------------- 6.  Loading, Constraints --------------------
!
*if,enable,eq,'2d',then
    !
    *if,ptyp,eq,'i',then
        !
        csys,stCS10
        !
        lsel,s,loc,y,0
        lsel,r,loc,z,0,h13
        lsel,u,loc,x,1.001*r7,3*r7
        cm,lset1,line
        !
        lsel,s,loc,z,0,h5
        lsel,r,loc,x,0,r10
        cm,lset2,line
        !
        cmsel,s,lset1
        cmsel,a,lset2
        !
        *IF,pload,NE,0,THEN
            sfl,all,pres,pload
        *ENDIF
        !
        init_entity_num
        !
        *IF,yn_mesh,EQ,1,THEN
            nsel,selv,loc,x,0
                !
            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
            nsel,r,loc,x,(rbp-rbh),(rbp+rbh)
            nsel,r,loc,y,0
                !
            d,all,all
                !
            init_entity_num
                !
            eplot
        *ENDIF
        !
    *elseif,ptyp,eq,'x',then
        !
        csys,stCS10
        !
        lsel,s,loc,y,0
        lsel,r,loc,z,0,h13
        lsel,u,loc,x,1.001*r7,3*r7
        cm,lset1,line
        !
        lsel,s,loc,z,0,h5
        cm,lset2,line
        !
        init_entity_num
        !
        cmsel,u,lset1
        cmsel,u,lset2
        !
        lsel,u,loc,x,0
        lsel,u,loc,x,r5+rfil1
        lsel,u,loc,x,r7-rfil3
        lsel,u,loc,z,h13-rfil3
        !
        *IF,pload,NE,0,THEN
            sfl,all,pres,pload
        *ENDIF
        !
        init_entity_num
        !
        *IF,yn_mesh,EQ,1,THEN
            nsel,selv,loc,x,0                   !constrain
            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
            nsel,r,loc,x,r3+3*rfil4,r4
            nsel,r,loc,y,0
            d,all,all

            init_entity_num
            eplot
       *ENDIF
    *endif
*endif

*if,enable,eq,'3d',then
        !
        csys,stCS10                           ! select load areas
        !
        lsel,s,loc,y,0
        lsel,r,loc,z,0,h13
        lsel,u,loc,x,1.001*r7,3*r7
        cm,lset1,line
        !
        lsel,s,loc,y,0
        lsel,r,loc,z,0,h5
        lsel,r,loc,x,0,r10
        cm,lset2,line
        !
        cmsel,s,lset1
        cmsel,a,lset2
        !
        asll,s
        asel,u,loc,y,0
        !
        *IF,pload,NE,0,THEN
           sfa,all,,pres,pload         ! apply pressure load to areas
        *ENDIF
        !
   *IF,yn_mesh,EQ,1,THEN
        init_entity_num
        !
        csys,stCS10
        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 375A080 @ %pload% psi Internal, 1 bolt missing
        *ENDIF
        nsla,s,1
        d,all,all                      !constrain flange mounting bolt circle
        !
        init_entity_num

        *IF,sym_,NE,1,THEN           !if full symettry do not need symettry constraints
           *IF,sym_,EQ,1/2,THEN      ! select symettry edges
              csys,stCS00
              nsel,selv,loc,x,0
           *ELSEIF,sym_,EQ,1/12,THEN
              csys,stCS10
              nsel,s,loc,y,0
              nsel,a,loc,y,-ptang
           *ENDIF
           csys,stCS10
           dsym,symm,y,stCS10        !apply symettry constraints
           init_entity_num
           eplot
       *ENDIF
    *ENDIF
*endif

!--------------------- 7.  Solve or Finalize Model Data  --------------------
!
*IF,sym_,EQ,1/1,THEN
   finalize_model_data
*ELSE
    *IF,slv_,EQ,1,THEN
        FINISH
        /config,fsplit,250
        /solu
        eqslv,iter,5,3
        solve
    *ENDIF
*ENDIF