OpenSees Cloud

OpenSees AMI

A Little Secret About OpenSees Tcl

Original Post - 29 Nov 2020 - Michael H. Scott

Visit Structural Analysis Is Simple on Substack.


Putting load and fiber commands inside {} braces preceded by pattern and section commands, respectively, was a conscious choice in the early days of G3/OpenSees.

section Fiber 1 {
   patch ...
   layer ...
   fiber ...
}
 
pattern Plain 1 Linear {
   load ...
   eleLoad ...
   sp ...
}

The intent was to enforce the same scoping rules that Tcl uses for procedures, loops, and conditional statements; however, the braces and scoping were totally unnecessary.

We scrapped the scoping requirement (but kept backward compatibility for Tcl) when we generalized the interpreters to accommodate Python and whatever is the next scripting language that beckons to OpenSees. As a result, you don’t see load and fiber commands indented in OpenSees Python scripts. These commands simply refer back to the last defined pattern and section commands.

ops.section('Fiber',1)
ops.patch(...)
ops.layer(...)
ops.fiber(...)
 
ops.timeSeries('Linear',1)
ops.pattern('Plain',1,1)
ops.load(...)
ops.eleLoad(...)
ops.sp(...)