!   thermal_cc.mac
!
*if,arg1,eq,'i',then

    /batch,list
    /show
    /title,thermal stress in concentric cylinders - indirect method
    /prep7
    et,1,plane77,,,1          ! PLANE77 axisymmetric option
    mp,kxx,1,2.2              ! Steel conductivity
    mp,kxx,2,10.8             ! Aluminum conductivity
    rectng,.1875,.4,0,.05     ! Model
    rectng,.4,.6,0,.05
    aglue,all
    numcmp,area
    asel,s,area,,1            Assign attributes to solid model
    aatt,1,1,1
    asel,s,area,,2
    aatt,2,1,1
    asel,all
    esize,.05
    amesh,all                  ! Mesh model
    nsel,s,loc,x,.1875
    d,all,temp,200             ! Apply thermal loads
    nsel,s,loc,x,.6
    d,all,temp,70
    nsel.all
    finish
    /solu
    solve
    finish
    /post1
    path,radial,2              ! Define path name and number of path points
    ppath,1,,.1875             ! Define path by location
    ppath,2,,.6
    pdef,temp,temp             ! Interpret temperature to path
    pasave,radial,filea        ! Save path to an external file
    plpath,temp                ! Plot temperature solution
    finish
    /prep7
    et,1,82,,,1                ! Switch to structural element, SOLID82
    mp,ex,1,30e6               ! Define structural steel properties
    mp,alpx,1,.65e-5
    mp,nuxy,1,.3
    mp,ex,2,10.6e6             ! Define aluminum structural properties
    mp,alpx,2,1.35e-5
    mp,nuxy,2,.33
    nsel,s,loc,y,.05            ! Apply structural boundary conditions
    cp,1,uy,all
    nsel,s,loc,x,.1875
    cp,2,ux,all
    nsel,s,loc,y,0
    d,all,uy,0
    nsel,all
    finish
    /solu
    tref,70
    ldread,temp,,,,,,rth          ! Read in temperatures from thermal run
    solve
    finish
    /post1
    paresu,radial,filea            !Restore path
    pmap,,mat                      ! Set path mapping to handle material discontinuity
    pdef,sx,s,x                    ! Interpret radial stress
    pdef,sz,s,z                    ! Interpret hoop stress
    plpath,sx,sz                   ! Plot stresses
    plpagm,sx,,node                ! Plot radial stress on path geometry
    finish


*elseif,arg1,eq,'p',then


    /batch,list
    /show
    /title,thermal stress in concentric cylinders - physics environment method
    /prep7
    et,1,plane77,,,1          ! PLANE77 axisymmetric options
    mp,kxx,1,2.2              ! Steel conductivity
    mp,kxx,2,10.8             ! Aluminum conductivity
    rectng,.1875,.4,0,.05     ! Model
    rectng,.4,.6,0,.05
    aglue, all
    numcmp,area
    asel,s,area,,11           Assign attributes to solid model
    aatt,1,1,1
    asel,s,area,,2
    aatt,2,1,1
    asel,all
    esize,.05
    amesh,all                 ! Mesh model
    nsel,s,loc,x,.1875
    d,all,temp,200            ! Apply thermal loads
    nsel,s,loc,x,.6
    d,all,temp,70
    nsel,all
    physics,write,thermal     ! Write the thermal physics file
    physics,clear             ! Clear all bc's and options

    et,1,82,,,1               ! Switch to structural element, SOLID82
    mp,ex,1,30e6              ! Define structural steel properties
    mp,alpx,1,.65e-5
    mp,nuxy,1,.3
    mp,ex,2,10.6e6            ! Define aluminum structural properties
    mp,alpx,2,1.35e-5
    mp,nuxy,2,.33
    nsel,s,loc,y,.05          !Apply structural boundary conditions
    cp,1,uy,all
    nsel,s,loc,x,.1875
    cp,2,ux,all
    nsel,s,loc,y,0
    d,all,uy,0
    nsel,all
    tref,70
    physics,write,struct      ! Write structural physics file
    save                      ! Save database
    finish
    /solu
    physics,read,thermal      ! Read thermal physics file

    solve                     ! Solve thermal problem
    finish
    /post1
    path,radial,2             ! Define path name and number of path points
    ppath,1,,.1875            ! Define path by location
    ppath,2,,.6
    pdef,temp,temp            ! Interpret temperature to path
    pasave,radial,filea       ! Save path to an external file
    plpath.temp               ! Plot temperature solution
    finish

    /solu
    physics,read,struct       ! Read structural physics file
    ldread,temp,,,,,,rth      ! Read in temperatures from thermal run
    solve                     ! Solve structural problem
    finish
    /post1
    paresu,raidal,filea       ! Restore path
    pmap,,mat                 ! Set path mapping to handle material discontinuity
    pdef,sx,s,x               ! Interpret radial stress
    pdef,sz,s,z               ! Interpret hoop stress
    plpath,sx,sz              ! Plot stresses
    plpagm,sx,,node           ! Plot radial stress on path geometry
    finish

*endif