OpenSeesPy (Linux)
OpenSeesPy is a Python wrapper for the OpenSees finite element analysis framework, widely used for simulating structural and geotechnical systems. The `openseespylinux` package provides a pre-compiled, optimized version of OpenSeesPy specifically for Linux environments, enabling high-performance numerical simulations without needing to compile OpenSees from source. It is currently at version 3.8.0.0 and typically updates in alignment with major OpenSees releases.
Common errors
-
ModuleNotFoundError: No module named 'openseespy'
cause The `openseespylinux` package was not installed, or the Python environment where it was installed is not active, or an incompatible Python version is used.fixActivate the correct Python environment (Python 3.12 or newer) and run `pip install openseespylinux`. -
ImportError: DLL load failed while importing opensees
cause Attempting to install or run `openseespylinux` on a non-Linux operating system (e.g., Windows, macOS). This package is Linux-specific.fixUse a Linux environment (native, WSL, Docker, or VM) for `openseespylinux`. For other OS, seek platform-specific distributions or build OpenSeesPy from source. -
OSError: [Errno 8] Exec format error: '/path/to/openseespy/opensees.cpython-312-x86_64-linux-gnu.so'
cause This error occurs when trying to run the Linux-compiled binaries (e.g., an `.so` file) on a non-Linux system or a system with an incompatible architecture.fixEnsure you are running the `openseespylinux` package strictly within a compatible Linux environment matching the architecture (e.g., x86_64). -
AttributeError: module 'openseespy' has no attribute 'model'
cause Incorrect import statement. The `openseespy` module itself does not expose the OpenSees commands directly; they are nested in the `opensees` submodule.fixChange your import from `import openseespy` to `import openseespy.opensees as ops` to correctly access the OpenSees command API.
Warnings
- breaking The `openseespylinux` package is strictly for Linux operating systems. Attempting to install or run it on Windows or macOS will result in `ImportError` or `OSError` due to incompatible binaries.
- breaking `openseespylinux` requires Python 3.12 or newer. Installing with older Python versions will likely lead to `ModuleNotFoundError` or other runtime `ImportError` issues.
- gotcha The standard and correct way to access OpenSees commands is `import openseespy.opensees as ops`. A common mistake is to simply use `import openseespy`, which does not expose the command API directly.
- gotcha It is critical to call `ops.wipe()` at the beginning of any new model definition or before running multiple independent analyses within the same Python script. Failure to do so can lead to unintended interactions and incorrect results from previously defined model components.
Install
-
pip install openseespylinux
Imports
- ops
import openseespy
import openseespy.opensees as ops
Quickstart
import openseespy.opensees as ops
# 1. Start a new model (2D, 3 DoF per node)
ops.wipe()
ops.model('basic', '-ndm', 2, '-ndf', 3)
# 2. Define a uniaxial elastic material (tag 1, E=3000)
ops.uniaxialMaterial('Elastic', 1, 3000.0)
# 3. Define nodes
ops.node(1, 0.0, 0.0)
ops.node(2, 10.0, 0.0)
# 4. Define boundary conditions (fixed at node 1)
ops.fix(1, 1, 1, 1)
# 5. Define an elastic truss element (tag 1, nodes 1-2, Area=1.0, material tag 1)
ops.element('Truss', 1, 1, 2, 1.0, 1)
# 6. Define a time series (constant) and load pattern
ops.timeSeries('Constant', 1)
ops.pattern('Plain', 1, 1)
ops.load(2, 0.0, -100.0, 0.0) # Apply 100 units downward load at node 2
# 7. Define analysis parameters
ops.integrator('LoadControl', 0.1)
ops.numberer('RCM')
ops.constraints('Plain')
ops.system('BandGeneral')
ops.algorithm('Newton')
ops.analysis('Static')
# 8. Perform analysis in 10 steps
ops.analyze(10)
# 9. Get results (Y-displacement of node 2)
disp_y = ops.nodeDisp(2, 2)
print(f"Y-displacement at node 2: {disp_y}")
# 10. End model and clear memory
ops.wipe()