Loading
/custom-emojis/emojis/contour-map.png
Templates
📚
Articles & Resources
📖
Guides & Support
🌵
CalcTree
Get started with OpenSees on CalcTree's banner
/custom-emojis/emojis/building-frame.png

Get started with OpenSees on CalcTree

OpenSees (Open System for Earthquake Engineering Simulation) is an open-source software framework for developing applications to simulate the performance of structural and geotechnical systems subjected to earthquakes. OpenSeesPy is a Python module that provides an interface to OpenSees.
This article is a step-by-step guide to using OpenSeesPy on CalcTree, where CalcTree is used as a graphical user interface (GUI) in a cloud environment.

Step 1: Set up Input Parameters in CalcTree

Determine the input parameters required for your structural analysis with OpenSeesPy. Common parameters include material properties, geometric dimensions and loads.
In CalcTree, navigate to your page and create the input parameters by typing "/" and selecting "Parameter field" or "Parameter inline". We call these "page parameters".
For example:


h
:3.00m


L
:10.00m


m
:1,000kg


E
:20GPa


Ic
:675,000,000mm4


Ib
:675,000,000mm4
👉Note, these input parameters are functioning and referenced in our OpenSeesPy Python code. See end of page for results.

Step 2: Add Python Integration to CalcTree

In CalcTree, add a "Code" source using the Integrations panel on the right-hand side of your page.


Step 3: Write CalcTree-Compliant Python Code

Below takes you through an example of a model construction using OpenSees in Python. The code sets up and visualises a 2D frame structure with given input parameters for mass, height, length, moment of inertia and Young's modulus. The structure consists of vertical columns and horizontal beams with fixed base nodes. The model is then visualized using Matplotlib.
👉Note, you can write your code directly in CalcTree, or any programming interface and copy and paste it back into CalcTree.

Importing Libraries

Import the necessary modules into Python for your analysis.

  1. openseespy.opensees as ops: imports the OpenSeesPy module for structural analysis
  1. opsvis as opsv: imports the opsvis module for visualizing the OpenSees model
  2. matplotlib.pyplot as plt: imports Matplotlib for plotting
  3. numpy as np: imports NumPy for numerical operations

Initialising the Model


  1. ops.wipe(): clears any existing model data
  1. ops.model('basic', '-ndm', 2, '-ndf', 3): initializes a 2D model with 3 degrees of freedom per node (2 translations and 1 rotation)

Defining Input Parameters

Use the "_page_" prefix to match input parameters in Python with CalcTree’s page parameters. Assign these to new variables in your script for clarity.
👉Note, the input parameter definition is tailored to CalcTree's interface. All other parts of the model construction can be written in any programming interface.

  1. m, h, L: input parameters for mass, height and length using parameters defined on your CalcTree page (as per Step 1)
  2. A: cross-sectional area, assumed as 0.09
  3. Ic: moment of inertia for columns, converted from mm^4 to m^4
  4. Ib: moment of inertia for beams, set as 100 times the column inertia
  5. E: Young's modulus, converted from GPa to Pa

Defining Nodes


  1. ops.node: defines the coordinates and mass (if applicable) for each node
  2. Nodes 1 and 2 are the base nodes, with nodes 3 to 8 forming the structure at different heights

Fixing Nodes


  1. ops.fix: fixes the base nodes (nodes 1 and 2) in all degrees of freedom (x, y, and rotation)

Defining Transformation


  1. ops.geomTransf('Linear', geomLinear): defines a linear geometric transformation with the ID geomLinear.

Defining Elements


  1. ops.element('elasticBeamColumn', ...): Defines elastic beam-column elements with given properties and node connectivity.
  2. Elements 1 to 6 are vertical columns with varying moments of inertia
  3. Elements 7 to 9 are horizontal beams with moment of inertia Ib

Visualising the Model


  1. opsv.plot_model(): plots the defined structural model using opsvis
  2. plt.title: adds a title to the plot
  3. plt.show(): displays the plot


Step 4: Add Output Python Parameters to CalcTree Page

Your output parameters will appear in the Integrations panel on the right-hand side of your page, in the page parameter list under Code source. To add these to your page, you can simply click and drag them to the page.
This will display the results of your Python code on the page for the user to see.

Here is the output figure from our Python code defined above.
Can’t display the image because of an internal error. Our team is looking at the issue.



This app is now ready to be shared!



Related Resources

  1. OpenSeesPy vs ETABS: 2D Frame Modal Analysis Comparison