Previous Topic

Next Topic

...Define Tcl Procedure

The procedure is a useful tool available from the Tcl language. A procedure is a generalized funcion/subroutine using arguments. Whenever the Tcl procedure is invoked, the contents of body will be executed by the Tcl interpreter.

An example of a Tcl procedure is found in RCcircSec.tcl. It defines a procedure which generates a circular reinforced concrete section with one layer of steel evenly distributed around the perimeter and a confined core:

# ----RCcircSec.tcl------------------------------------------------------------------------

# by Michael H. Scott

# Define a procedure which generates a circular reinforced concrete section

# with one layer of steel evenly distributed around the perimeter and a confined core.

# Formal arguments

# id - tag for the section that is generated by this procedure

# ri - inner radius of the section

# ro - overall (outer) radius of the section

# cover - cover thickness

# coreID - material tag for the core patch

# coverID - material tag for the cover patches

# steelID - material tag for the reinforcing steel

# numBars - number of reinforcing bars around the section perimeter

# barArea - cross-sectional area of each reinforcing bar

# nfCoreR - number of radial divisions in the core (number of "rings")

# nfCoreT - number of theta divisions in the core (number of "wedges")

# nfCoverR - number of radial divisions in the cover

# nfCoverT - number of theta divisions in the cover

# Notes

# The center of the reinforcing bars are placed at the inner radius

# The core concrete ends at the inner radius (same as reinforcing bars)

# The reinforcing bars are all the same size

# The center of the section is at (0,0) in the local axis system

# Zero degrees is along section y-axis

proc RCcircSection {id ri ro cover coreID coverID steelID numBars barArea nfCoreR nfCoreT nfCoverR nfCoverT} {

section fiberSec $id {

set rc [expr $ro-$cover]; # Core radius

patch circ $coreID $nfCoreT $nfCoreR 0 0 $ri $rc 0 360; # Core patch

patch circ $coverID $nfCoverT $nfCoverR 0 0 $rc $ro 0 360; # Cover patch

if {$numBars <= 0} {

return

}

set theta [expr 360.0/$numBars]; # Angle between bars

layer circ $steelID $numBars $barArea 0 0 $rc $theta 360; # Reinforcing layer

}

}

This procedure is invoked by the following commands, assuming that all arguments have been defined previously in the input generation:

source RCcircSection.tcl;

RCcircSection $IDcolFlex $riCol $roCol $cover $IDcore $IDcover $IDsteel $NbCol $AbCol $nfCoreR $nfCoreT $nfCoverR $nfCoverT

NOTE: the file containing the definition of the procedure (RCcircSec.tcl) needs to be sourced before the procedure is invoked.