OpenSeesPy

3.8.0.0 · active · verified Thu Apr 16

OpenSeesPy is a Python 3 interpreter for the Open System for Earthquake Engineering Simulation (OpenSees), a powerful software framework for finite element analysis. It provides robust capabilities for structural analysis, including linear, nonlinear, static, and dynamic analysis of structures. Currently at version 3.8.0.0, the library is actively developed with frequent updates and releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic 2D truss analysis: defining nodes, boundary conditions, material, elements, applying a static load, running a static analysis, and retrieving nodal displacement. It includes best practices like `ops.wipe()` for model isolation.

import openseespy.opensees as ops

# 1. Start a new model
ops.wipe()
ops.model('basic', '-ndm', 2, '-ndf', 3)

# 2. Define nodes
ops.node(1, 0.0, 0.0)
ops.node(2, 100.0, 0.0)
ops.node(3, 0.0, 100.0)

# 3. Set boundary conditions
ops.fix(1, 1, 1, 1) # Node 1: Fixed in x, y, and rotation
ops.fix(2, 0, 1, 0) # Node 2: Fixed in y

# 4. Define material
# uniaxialMaterial('Elastic', matTag, E)
ops.uniaxialMaterial('Elastic', 1, 200000.0) # Steel, E in appropriate units

# 5. Define elements (e.g., truss element)
# element('truss', eleTag, iNode, jNode, A, matTag)
ops.element('truss', 1, 1, 3, 10.0, 1)
ops.element('truss', 2, 2, 3, 10.0, 1)

# 6. Define loads
# Create a time series (constant load factor)
ops.timeSeries('Constant', 1)
# Create a plain load pattern
ops.pattern('Plain', 1, 1)
# Apply nodal load (Node 3: -10kN in y-direction)
ops.load(3, 0.0, -10.0, 0.0)

# 7. Setup analysis
ops.constraints('Plain')
ops.numberer('RCM')
ops.system('BandSPD')
ops.test('NormDispIncr', 1e-6, 10)
ops.algorithm('Linear')
ops.integrator('LoadControl', 0.1)
ops.analysis('Static')

# 8. Perform analysis
ops.analyze(10)

# 9. Get results (example: node 3 displacement)
disp_y = ops.nodeDisp(3, 2)
print(f"Vertical displacement at node 3: {disp_y:.4f}")

ops.wipe() # Clear the model from memory

view raw JSON →