!   TITLE:  weld_profile.mac (PART_LIB)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates a model of a weld fillet profile for analyzing
!   stresses through the weld cross-section.
!
!   COMMAND SYNTAX:
!
!
!                       (1)        (2)    (3)  (4)  (5)  (6)    (7)
!       WELD_PROFILE, wld_wdth, wld_dpth, xc,  yc,  zc, rotxy, rotyz,
!
!                     rotzx, bdraf
!                      (8)    (9)
!
!   ARGUMENTS:
!
!       wld_wdth = width of weld
!
!       wld_dpth = weld penetration depth
!
!       xc = x coordinate of the weld C.S. center relative to the active C.S.
!
!       yc = y coordinate of the weld C.S. center relative to the active C.S.
!
!       zc = z coordinate of the weld C.S. center relative to the active C.S.
!
!       rotxy = xy angular rotation of the weld C.S. relative to the active C.S.
!
!       rotyz = yz angular rotation of the weld C.S. relative to the active C.S.
!
!       rotzx = zx angular rotation of the weld C.S. relative to the active C.S.
!
!       bdraf = weld bead radius factor. The weld bead radii are this multiple
!               of the weld width. ( bdraf > or = 0.5 )
!
!
!   DESCRIPTION:
!
!   The weld profile is an area representing a cross-sectional cut of the
!   weld zone joining 2 separate parts or sections. The weld width and depth
!   of penetration must be specified, along with the coordinate position of
!   the weld C.S., as measured from the active C.S. The radius of the weld
!   beads are specified as some multiple of the weld width. The default value
!   of this factor, i.e., BDRAF, is 1, but may be over-ridden with a desired
!   user-specified value.
!
!   A layout of this profile, and the pertinent input arguments, is created
!   by DRAW_WELD_PROFILE.MAC.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

*get,actcs_,active,,csys
!
*get,acttyp_,cdsy,actcs_,attr,kcs
!
*if,acttyp_,ne,0,then
    create_cs,0,'wpcs_',0,0,0,0,0,0,0
*endif
!
wldwdth_=arg1
wlddpth_=arg2
xwcnt_=arg3
ywcnt_=arg4
zwcnt_=arg5
xywcnt_=arg6
yzwcnt_=arg7
zxwcnt_=arg8
bdraf_=arg9
!
!
*if,bdraf_,eq,0,then
    bdraf_=1
*else
    *if,bdraf_,lt,0.5,then
        bdraf_=0.5
    *endif
*endif
!
beadrad_=bdraf_*wldwdth_
!
bdcdpth_=sqrt((beadrad_**2)-((0.5*wldwdth_)**2))
!
create_cs,0,'weldcs',0,xwcnt_,ywcnt_,zwcnt_,xywcnt_,yzwcnt_,zxwcnt_
!
k,,0,0,0
k,,0,-wlddpth_,0
k,,-wldwdth_,-wlddpth_,0
k,,-wldwdth_,0,0
!
init_entity_num
!
lstr,km-3,km-2
lstr,km-1,km
!
init_entity_num
!
create_cs,0,,1,-0.5*wldwdth_,-bdcdpth_,0,0,0,0
!
l,km,km-3
!
init_entity_num
!
csys,weldcs
create_cs,0,,1,-0.5*wldwdth_,-(wlddpth_+bdcdpth_),0,0,0,0
!
l,km-2,km-1
!
init_entity_num
!
lsel,s,line,,lm-3,lm,1
al,all
!
init_entity_num
!
csys,actcs_
!
lplot
!
*set,wldwdth_,
*set,wlddpth_,
*set,xwcnt_,
*set,ywcnt_,
*set,zwcnt_,
*set,xywcnt_,
*set,yzwcnt_,
*set,zxwcnt_,
*set,beadrad_,
*set,bdcdpth_,
*set,actcs_,

*if,prkey_,eq,1,then
    /go
*endif