STAIRLab logo
  • Docs 
  • Examples 
  •  

Linear Truss

4 min read • 833 words
Truss   Python   Tcl  
Truss   Python   Tcl  

A finite element model of a simple truss is created, and static analysis is performed.

On this page
Model   Loads   Analysis  
Python Tcl
  • main.py
  • Example1.tcl

This example is of a linear-elastic three bar truss, as shown in the figure above, subject to static loads. The purpose of this example is to develop the basic concepts used for performing structural analysis with OpenSees. This includes the definition of nodes, materials, elements, loads and constraints.

Model  

We begin the simulation by creating a Model  , which will manage the nodes, elements, loading and state. This is done through either Python or Tcl as follows:

Python Tcl
import opensees.openseespy as ops

model = ops.Model(ndm=2, ndf=2)
model -ndm 2 -ndf 2

where we’ve specified 2 for the spatial dimension ndm, and 2 for the number of degrees of freedom ndf.

Next we define the four nodes of the structural model by specifying a tag which identifies the node, and coordinates in the x−yx-y plane. In general, the node constructor must be passed ndm coordinates.

Python Tcl
#         tag     X     Y
model.node(1, (  0.0,  0.0))
model.node(2, (144.0,  0.0))
model.node(3, (168.0,  0.0))
model.node(4, ( 72.0, 96.0))
#   tag  X    Y
node 1   0.0  0.0;
node 2 144.0  0.0;
node 3 168.0  0.0;
node 4  72.0 96.0;

The restraints are now defined at the nodes with reactions (ie, nodes 1, 2, and 3). The restraints at the nodes with reactions (ie, nodes 1, 2, and 3) are then defined. This is done with the fix  method, whose first argument is an integer node tag and second argument a tuple containing a 1 or 0 for degree of freedom at the node.

Python Tcl
# set the boundary conditions
#    nodeID   x  y
model.fix(1, (1, 1))
model.fix(2, (1, 1))
model.fix(3, (1, 1))
# Set the boundary conditions
#  tag  X  Y
fix 1   1  1;
fix 2   1  1;
fix 3   1  1;

Since the truss elements have the same elastic properties, a single Elastic material is defined. The first argument assigns the tag 1 to the material, and the second specifies a Young’s modulus of 3000.

Python Tcl
# Create Elastic material prototype
model.uniaxialMaterial("Elastic", 1, 3000)
# Create Elastic material prototype
uniaxialMaterial Elastic 1 3000;

Finally, define the elements. The syntax for creating the truss element requires the following arguments:

  1. the element name, in this case always "Truss",
  2. the element tag, in this case 1 through 3,
  3. the nodes that the element is connected to,
  4. the cross-sectional area, in this case 10.0 for element 1 and 5.0 for elements 2 and 3.
  5. the tag of the material assigned to the element, in this case always 1
Python Tcl
#              Type   tag  nodes  Area  material
model.element("Truss", 1, (1, 4), 10.0,    1   )
model.element("Truss", 2, (2, 4),  5.0,    1   )
model.element("Truss", 3, (3, 4),  5.0,    1   )
element Truss 1 1 4 10.0 1;
element Truss 2 2 4  5.0 1;
element Truss 3 3 4  5.0 1;

Loads  

The final step before we can configure and run the analysis is to define some loading. In this case we have two point loads at the apex of the truss (node 4). In OpenSees, loads are assigned to load patterns, which define how loads are scaled with each load step.

In Python, the simplest way to represent a nodal load is by a dictionary with node numbers as keys, and corresponding load vector as values. For the problem at hand, we want to apply a load to node 4 with 100 units in the xx direction, and -50 units in the yy direction; the corresponding definition is:

Python Tcl
loads = {4: [100, -50]}
set loads {4 100 -50}

We then add a "Plain"  load pattern to the model with these loads, and use the "Constant" option to specify that it should be held constant.

Python Tcl
model.pattern("Plain", 1, "Constant", load=loads)
pattern Plain 1 "Constant" "load $loads"

Note that it is common to define the load data structure inside the call to the pattern function. This looks like:

Python Tcl
model.pattern("Plain", 1, "Constant", load={
  4: [100, -50]
})
pattern Plain 1 "Linear" {
  load 4 100 -50
}

Analysis  

Even though the solution is linear, we have to select a procedure for applying the load, which is called an Integrator. For this problem, the LoadControl integrator  is selected, which advances the solution by incrementing the load factor by 1.0 each time the analyze command is called.

Python Tcl
model.integrator("LoadControl", 1.0)
integrator LoadControl 1.0;

Once all the components of an analysis are defined, the Analysis itself is defined. For this problem a Static analysis is used.

Python Tcl
model.analysis("Static")
analysis Static;

Finally, one analysis step is performed by invoking analyze  :

Python Tcl
model.analyze(1)
analyze 1

When the analysis is complete the state of node 4 obtained using nodeDisp  and printed to the screen:

Python Tcl
u4 = model.nodeDisp(4)
print(u4)
print node 4
print ele

The output looks like:

u4 = [0.5300927771322836, -0.1778936384693177]

When using Python, the model variable can be passed directly to the veux library’s render  function as follows:

import veux
# Render the model
artist = veux.render(model, model.nodeDisp, canvas="plotly")

veux.serve(artist)
 Uniaxial Materials
Orienting frames in 3D 
On this page:
Model   Loads   Analysis  
Linear Truss
Linear Truss
A gallery of technical examples currated by the STAIRLab at UC Berkeley.
Code licensed BSD, docs CC BY-NC 4.0
 
Links
Home 
About 
Docs 
Examples
Working with solids 
Nonlinear dynamics 
Basic Statics 
Community
Issues   
Discussions   
Contribute 
STAIRLab
Code copied to clipboard