How to Use pytest with OpenSees

Despite plentiful constitutive models and analysis options, testing and verifying OpenSees has been quite limited. At this point, going back and testing all the contributions from the last 25 years is a nearly insurmountable task. But, as the saying goes: The best time to start testing OpenSees was 25 years ago.The second best time is … Continue reading How to Use pytest with OpenSees

One Fiber at a Time

A few years after G3 became OpenSees, UCFyber became XTRACT. In those intervening years, to accommodate section data exported from UCFyber, we added the fiber command to OpenSees, allowing you to add a single fiber to a section based on the fiber's (y,z) coordinates, area, and material tag. Several section analysis software packages have sprung … Continue reading One Fiber at a Time

How to Profile an OpenSeesPy Analysis

Python has a couple of profiling libraries--pyinstrument and cProfile--for finding out where all the time goes when you run a script. But, as far as I can tell, these libraries only tell you that the ops.analyze() command is called, not what happens therein. What you really want is to drill down into the state determinations … Continue reading How to Profile an OpenSeesPy Analysis

Is It Close Enough?

The locations and weights for Gauss-Lobatto beam integration, the de facto beam integration for force-based elements, are hard-coded in the OpenSees source code. For most cases in the LobattoBeamIntegration class, the locations and weights are written to only ten significant figures instead of 16 or more. Although I am certain that leaving six sig-figs on … Continue reading Is It Close Enough?

Is OpenSees Pythonic?

OpenSeesPy is sometimes criticized for not being "Pythonic". But what does "Pythonic" even mean? And does achieving "Pythonic" status matter? From what I gathered in this blog post, Pythonic code uses the idioms, i.e., the specific syntax and constructs, of Python. That definition is circular--an example from the post better demonstrates the meaning. If you … Continue reading Is OpenSees Pythonic?

How to Use with with OpenSeesPy

The with command offers a clean approach to manage Python resources, particularly file streams. Without going into detail, the with command is a shortcut for exception handling. The nice thing about reading and writing files using the with command is you don't have to worry about closing the file stream. Immediately after the with block … Continue reading How to Use with with OpenSeesPy

A Better Way to Find Memory Leaks in OpenSees

In a previous post, I explained how to find a memory leak in OpenSees. The basic idea was to put the analysis inside a loop, run the loop a million times, and monitor your operating system for increasing memory usage. A perfectly fine leak hunting approach--as long as you are willing to monitor your operating … Continue reading A Better Way to Find Memory Leaks in OpenSees

Gotta Catch ‘Em All

Python has built-in Exception types for dealing with various run-time errors. You've probably seen a few Exceptions like ModuleNotFoundError if you had issues installing OpenSeesPy or KeyboardInterrupt when you have used Ctrl+C to get your script out of an infinite loop. A common Exception encountered within a script is divide by zero, in which case … Continue reading Gotta Catch ‘Em All

Not Everything Should Be a Direct Translation

Like learning another language, not everything in OpenSees, and programming in general, is a direct translation from textbooks. Your mother tongue could be $latex {\bf x} = {\bf A}^{-1}{\bf b}$, but you should never invert the matrix then multiply. Instead, call an equation solver. For small matrices in OpenSees, use A.Solve(b, x) from the Matrix … Continue reading Not Everything Should Be a Direct Translation