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
Category: Programming
Hidden Fees
Helper functions are often implemented as private methods in a class. For example, here is a private cross product function in an Element class of OpenSees. Vector CadillacBeamColumn3d::cross(Vector v1, Vector v2){ Vector v3(3); v3(0) = v1(1)*v2(2)-v1(2)*v2(1); v3(1) = v2(0)*v1(2)-v1(0)*v2(2); v3(2) = v1(0)*v2(1)-v1(1)*v2(0); return v3; } Note that the class name has been changed and other … Continue reading Hidden Fees
Minimal Plotting Example
OpenSees is not a GUI. OpenSees is an API. While "no GUI and difficult to use" is a frequent knock, "no GUI" is actually a strength of OpenSees, not a weakness. "No GUI" means the developers remain focused on the core computational framework instead of getting mired in pop-up windows and click bindings. But even … Continue reading Minimal Plotting Example
Cargo Cult OpenSeesing
In recent conversation, a colleague in Eastchester mentioned "cargo cult science", a term with which I was previously unfamiliar. A cargo cult scientist attempts to produce outcomes without understanding the actual processes that lead to those outcomes. Although the associated cultural behaviors have been around for centuries, the popular term "cargo cult" was coined during … Continue reading Cargo Cult OpenSeesing
Runnin’ Down a Leak
Issue #1214 by zAlexliu-8895 on OpenSees GitHub demonstrated a memory leak with creating patches for fiber sections. The script posted with the GitHub issue is reproduced below. import openseespy.opensees as ops Counter = 0 while Counter < 100000000: Counter += 1 ops.wipe() ops.model('basic', '-ndm', 2, '-ndf', 3) ops.uniaxialMaterial("Concrete02", 1, -33, -0.0015, -20, -0.005, 0.1, 2.2, … Continue reading Runnin’ Down a Leak
How to Keep Your OpenSees Code Private on GitHub
I often mention the Concrete23 material model, but you won't find it in the main OpenSees GitHub repository or in any of the repo's public forks. You won't find Concrete23 because it doesn't exist. Or maybe the model does exist but I keep it in a private fork of OpenSees. You'll never know... Let's assume … Continue reading How to Keep Your OpenSees Code Private on GitHub
Run OpenSees in the Cloud
Many OpenSees use cases, from the embarrassingly parallel to large, high fidelity models, require high performance computing (HPC). But even today, HPC remains out of reach for many OpenSees users for a variety of reasons. If you or your organization is able to purchase HPC hardware, the overhead to maintain and operate the hardware remains … Continue reading Run OpenSees in the Cloud
My Favorite Ternary Operation
Most native C++ operations are binary, taking two arguments, e.g., a + b, or unary, taking one argument, e.g., a++. But C++ (and many other languages) has a native "conditional operator", which is ternary, taking three arguments. Known simply as ?:, the conditional operator has the following syntax (condition) ? true_outcome : false_outcome; The conditional … Continue reading My Favorite Ternary Operation
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
Pruning OpenSees
Most OpenSees pull requests add to the code base. Often incremental and sometimes innovative, the new additions keep OpenSees moving forward, offering something for everyone. But it's rare that we remove code. Although it would be great to purge OpenSees of Concrete23 and all its unused variations, to prune code in frequently used OpenSees classes … Continue reading Pruning OpenSees
