OpenSees Cloud

OpenSees AMI

It's OK to Be Negative

Original Post - 13 Nov 2023 - Michael H. Scott

Visit Structural Analysis Is Simple on Substack.


A common question is whether or not OpenSees allows negative tags for nodes, elements, materials, time series, patterns, etc. in a model. The obvious answer is “Don’t think, just throw”.

But the polite answer is “Yes, you can define model objects with negative tags”. Below is a minimal example where all tags are negative.

import openseespy.opensees as ops

ops.wipe()
ops.model('basic','-ndm',1,'-ndf',1)

ops.node(-1,0); ops.fix(-1,1)
ops.node(-2,0)

ops.uniaxialMaterial('Elastic',-1,50)

ops.element('zeroLength',-1,-1,-2,'-mat',-1,'-dir',1)

ops.timeSeries('Constant',-1)
ops.pattern('Plain',-1,-1)
ops.load(-2,10)

ops.analysis('Static')
ops.analyze(1)

print(ops.nodeDisp(-2))

Internally, OpenSees uses instances of the MapOfTaggedObjects class as a container for model building objects. The MapOfTaggedObjectsIter class is used for iterating over tagged objects, e.g., when forming a load vector or assembling a stiffness matrix.

Why would one want to use negative tags? A few reasons come to mind. Better bookkeeping. Automation. Defining a shadow model. I’m sure there are other valid use cases.

And not only do tags not have to be positive, tags also do not have to be sequential.