Tutorial

OpenSeesPy tutorial: your first 2D frame static analysis in Python

Install OpenSeesPy, model a 2D cantilever and a portal frame with elastic beam-column elements, run a linear static analysis, and check displacements, reactions, and equilibrium.

If you searched for an OpenSeesPy tutorial, you probably want one thing: a small script that runs, a result you can trust, and a clear idea of what each line does.

This tutorial builds exactly that. We model two linear-elastic 2D structures with OpenSeesPy:

  1. a cantilever column with a lateral tip load, which has a closed-form answer we can check;
  2. a single-bay portal frame with a lateral load at the roof, where we check equilibrium of the reactions.

Every command used here was checked against the official OpenSeesPy documentation. The script was run before publishing; the output is shown below together with the environment it ran in.

If you want the background first — why OpenSees is a framework and not an application, and where OpenSeesPy came from — read the history of OpenSees.


1. Install OpenSeesPy

OpenSeesPy is distributed on PyPI. The official installation page for Windows gives these commands:

python -m pip install openseespy

or, for a per-user install:

python -m pip install --user openseespy

To upgrade later:

python -m pip install --upgrade openseespy

The import used throughout the official documentation is:

import openseespy.opensees as ops

At the time of writing (26 November 2026), PyPI lists openseespy 3.8.0.0 (released 18 March 2026), with Requires: Python >=3.10 and classifiers for Windows, Linux, and macOS.


2. The workflow in OpenSees terms

An OpenSees script always follows the same order. It helps to name the steps before writing code:

StepCommand(s) used hereWhat it does
Clearwipe()Removes any previous model from memory
Model buildermodel('basic', '-ndm', 2, '-ndf', 3)2 dimensions, 3 DOF per node (ux, uy, rz)
Geometrynode, fixNodes and supports
ElementsgeomTransf, element('elasticBeamColumn', ...)Members and their local-to-global transformation
LoadstimeSeries('Linear', ...), pattern('Plain', ...), loadA load pattern scaled by a time series
Analysissystem, numberer, constraints, integrator, algorithm, analysis, analyzeHow the equations are assembled and solved
ResultsnodeDisp, reactions, nodeReaction, eleForceRead displacements, reactions, and element forces

Some details from the official command pages that matter for this example:

  • model('basic', '-ndm', ndm, '-ndf', ndf) — ndm is the number of dimensions; ndf is the number of DOFs per node.
  • fix(nodeTag, *constrValues) — a list of 0/1 values, one per DOF (1 = fixed).
  • The 2D form of element('elasticBeamColumn', eleTag, *eleNodes, Area, E_mod, Iz, transfTag) takes the area, Young’s modulus, the second moment of area about the local z-axis, and the tag of a previously defined geometric transformation.
  • geomTransf('Linear', transfTag) — the documentation lists Linear, PDelta, and Corotational transformations. We use Linear: small displacements, no second-order effects.
  • load(nodeTag, *loadValues) adds a nodal load to the enclosing load pattern; the values are reference values scaled by the time series.
  • integrator('LoadControl', incr) applies the load factor increment incr. With incr = 1.0 and one step, the full reference load is applied.
  • analyze(numIncr) returns 0 when the analysis succeeds and a negative value when it does not.
  • reactions() must be called before nodeReaction() is used.

3. The model

Units are kN and m throughout. OpenSees has no unit system: you are responsible for consistency.

  • Columns and beam: E = 200 × 10⁶ kN/m² (200 GPa), A = 0.01 m², I = 1.0 × 10⁻⁴ m⁴ (illustrative section properties, not a real profile).
  • Column height H = 3.0 m, beam span L = 6.0 m.
  • Lateral load P = 10 kN, horizontal, at the top-left node.
Cantilever                 Portal frame

  P → o 2                  P → o 3 ─────────── o 4
      │                        │                 │
      │ H = 3 m                │ H = 3 m         │
      │                        │                 │
     ▓▓▓ 1                    ▓▓▓ 1             ▓▓▓ 2
                                  L = 6 m

4. The full script

Save this as portal.py:

import openseespy.opensees as ops

# Units: kN, m
E = 200.0e6   # kN/m2 (200 GPa)
A = 0.01      # m2
I = 1.0e-4    # m4
H = 3.0       # column height, m
L = 6.0       # beam span, m
P = 10.0      # lateral load, kN


def run_static_analysis():
    ops.system('BandGeneral')
    ops.numberer('RCM')
    ops.constraints('Plain')
    ops.integrator('LoadControl', 1.0)
    ops.algorithm('Linear')
    ops.analysis('Static')
    return ops.analyze(1)


def cantilever():
    ops.wipe()
    ops.model('basic', '-ndm', 2, '-ndf', 3)
    ops.node(1, 0.0, 0.0)
    ops.node(2, 0.0, H)
    ops.fix(1, 1, 1, 1)
    ops.geomTransf('Linear', 1)
    ops.element('elasticBeamColumn', 1, 1, 2, A, E, I, 1)
    ops.timeSeries('Linear', 1)
    ops.pattern('Plain', 1, 1)
    ops.load(2, P, 0.0, 0.0)
    ok = run_static_analysis()
    ux = ops.nodeDisp(2, 1)
    exact = P * H**3 / (3 * E * I)
    print(f"[cantilever] analyze() = {ok}")
    print(f"[cantilever] tip ux = {ux:.6e} m | P*H^3/(3EI) = {exact:.6e} m")


def portal():
    ops.wipe()
    ops.model('basic', '-ndm', 2, '-ndf', 3)
    ops.node(1, 0.0, 0.0)
    ops.node(2, L, 0.0)
    ops.node(3, 0.0, H)
    ops.node(4, L, H)
    ops.fix(1, 1, 1, 1)
    ops.fix(2, 1, 1, 1)
    ops.geomTransf('Linear', 1)
    ops.element('elasticBeamColumn', 1, 1, 3, A, E, I, 1)  # left column
    ops.element('elasticBeamColumn', 2, 2, 4, A, E, I, 1)  # right column
    ops.element('elasticBeamColumn', 3, 3, 4, A, E, I, 1)  # beam
    ops.timeSeries('Linear', 1)
    ops.pattern('Plain', 1, 1)
    ops.load(3, P, 0.0, 0.0)
    ok = run_static_analysis()
    print(f"[portal] analyze() = {ok}")
    print(f"[portal] roof ux: node 3 = {ops.nodeDisp(3, 1):.6e} m, node 4 = {ops.nodeDisp(4, 1):.6e} m")

    ops.reactions()
    r1 = ops.nodeReaction(1)
    r2 = ops.nodeReaction(2)
    print("[portal] reaction node 1 [Fx, Fy, Mz]:", [round(v, 4) for v in r1])
    print("[portal] reaction node 2 [Fx, Fy, Mz]:", [round(v, 4) for v in r2])

    # Static checks: sum Fx and sum of moments about node 1 must vanish
    sum_fx = r1[0] + r2[0] + P
    sum_m1 = r1[2] + r2[2] + r2[1] * L - P * H
    print(f"[portal] sum Fx = {sum_fx:.3e} kN | sum M about node 1 = {sum_m1:.3e} kN*m")
    print("[portal] left column end forces:", [round(v, 4) for v in ops.eleForce(1)])


cantilever()
portal()

The analysis block (system('BandGeneral'), numberer('RCM'), constraints('Plain'), integrator('LoadControl', 1.0), algorithm('Linear'), analysis('Static')) mirrors the one in the official Elastic Truss Analysis example, with BandGeneral instead of BandSPD. For a linear-elastic model a Linear algorithm and a single load step are enough; nonlinear models need a convergence test and an iterative algorithm, which are outside the scope of this first tutorial.


5. Run it

python portal.py

This is the output obtained when running the script for this article (Windows, Python 3.12.10, openseespy 3.8.0.0, 26 November 2026):

[cantilever] analyze() = 0
[cantilever] tip ux = 4.500000e-03 m | P*H^3/(3EI) = 4.500000e-03 m
[portal] analyze() = 0
[portal] roof ux: node 3 = 9.928890e-04 m, node 4 = 9.779686e-04 m
[portal] reaction node 1 [Fx, Fy, Mz]: [-5.0265, -1.8734, 9.4394]
[portal] reaction node 2 [Fx, Fy, Mz]: [-4.9735, 1.8734, 9.32]
[portal] sum Fx = -1.776e-14 kN | sum M about node 1 = 5.684e-14 kN*m
[portal] left column end forces: [-5.0265, -1.8734, 9.4394, 5.0265, 1.8734, 5.6402]

If you change the units, the section, or the OpenSeesPy version, your numbers can differ. What should not change is the logic of the checks below.


6. Read and check the results

Never accept a finite-element number without at least one independent check. This example has three.

Check 1: the cantilever against the closed form

For a cantilever with a tip load and Euler–Bernoulli bending, the tip deflection is P·H³ / (3·E·I):

10 × 3³ / (3 × 200 × 10⁶ × 1.0 × 10⁻⁴) = 270 / 60 000 = 0.0045 m

OpenSeesPy returns 4.5 × 10⁻³ m. The element is a linear-elastic beam-column, so matching the closed form is the expected behavior. If it does not match, look for a units problem, a wrong Iz, or a support that is not fully fixed.

Check 2: equilibrium of the portal frame

nodeReaction() returns [Fx, Fy, Mz] at each support. Two quick hand checks:

  • Horizontal forces: −5.0265 − 4.9735 + 10 = 0. The two base shears balance the applied load (they are almost equal because the beam is very stiff axially and the columns are identical).
  • Moments about node 1: 9.4394 + 9.32 + 1.8734 × 6 − 10 × 3 = 0. The script prints both sums, and both are of the order of 10⁻¹⁴: round-off, not error.

Check 3: the column as a free body

eleForce(1) returns the resisting forces of the left column at end i (base) and end j (top), in global coordinates. The column shear of 5.0265 kN times the 3 m height (15.08 kN·m) equals the sum of the end moments, 9.4394 + 5.6402 = 15.08 kN·m. The element is in equilibrium as a free body.

The two roof displacements are slightly different (node 3: 9.93 × 10⁻⁴ m; node 4: 9.78 × 10⁻⁴ m) because the beam has a finite axial stiffness: it shortens a little while transferring load to the right column.


7. Where to go next

  • Change geomTransf('Linear', 1) to PDelta and compare the roof displacement under the same load. The difference is the second-order effect.
  • Add a gravity load pattern (vertical load values at nodes 3 and 4) and run it before the lateral load.
  • Read the official structural examples, especially Portal Frame 2d Analysis and Reinforced Concrete Frame Gravity Analysis, before moving to nonlinear materials.

And if you plan to have an AI assistant write the next script for you, keep the checks: the assistant can draft the code; the engine and your hand checks provide the evidence. That idea is developed in ChatGPT vs Claude for civil engineering and in your LLM does not calculate.


Sources

  1. OpenSeesPy documentation — Installation (PyPI, Windows).
  2. OpenSeesPy documentation — model command, node, fix.
  3. OpenSeesPy documentation — Elastic Beam Column element, geomTransf.
  4. OpenSeesPy documentation — Linear time series, Plain pattern, load.
  5. OpenSeesPy documentation — system, LoadControl, analysis, analyze.
  6. OpenSeesPy documentation — nodeDisp, reactions, nodeReaction, eleForce.
  7. OpenSeesPy documentation — Elastic Truss Analysis example and Portal Frame 2d Analysis example.
  8. PyPI — openseespy (version, release date, Python requirement).