While graphical user interfaces are good for general purpose use, the command line remains the most versatile way to run OpenSees and other computer programs. Passing command line arguments to an OpenSees Tcl or Python script is useful when creating standalone applications for building and analyzing specialized models. Both Tcl and Python have constructs similar … Continue reading OpenSees Command Line Arguments
Category: Programming
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
Life of OpenSees Pi
This is blog post #314, or $latex 100\pi$ to three sig figs. A more recognizable $latex \pi$-times-a-power-of-10 post than post #31 or post #3. And I'll have to maintain the current pace of post writing into my mid 80s in order to reach post #3141. In the G3 days of OpenSees, the inverse sine function … Continue reading Life of OpenSees Pi
It’s OK to Be Negative
A common question is whether or not OpenSees allows negative tags for nodes, elements, materials, time series, patterns, etc. in a model. The obvious answer is "Don't think, just throw". But the polite answer is "Yes, you can define model objects with negative tags". Below is a minimal example where all tags are negative. import … Continue reading It’s OK to Be Negative
Right, then Left
I don't expect every OpenSees contributor to be an expert coder, but I see some dubious coding more frequently than I should. And when I see questionable coding practices, I will call out the offenses so that maybe, just maybe, someone else will consider leaving the cargo cult. For example, the author of CargoConcrete23 wrote … Continue reading Right, then Left
Pleasing the Compiler
Around the transition from G3 to OpenSees, the Visual Studio (VS) compiler was not fully compliant with the then current ISO C++ standard. There were perhaps many items out of compliance, but the non-compliance that drove us nuts was the scoping rule on variables defined in the initialization statement of for loops. The VS compiler … Continue reading Pleasing the Compiler
Something Like a Double Negative
Double negatives are frowned upon in English, but are acceptable in other languages such as Spanish. For example, "No hay nada" is perfectly fine but may sound odd to native English speakers. Along similar lines, I recently came across some OpenSees code that looked something like this: const int N = 20; double Fx[N]; // … Continue reading Something Like a Double Negative
Beware the Em Dash
Out of a rational fear of making a transcription error, no one re-types what they read in a web browser. Instead, they highlight a line or two to initiate the copy-paste-modify sequence. And somewhere in the annals of OpenSees history, an em dash appeared in the recorder commands of a Tcl example or documentation. After … Continue reading Beware the Em Dash
Silence Is Golden
Perhaps the #1 OpenSees complaint of all time is that recorder files have incomplete data--in some cases terminating midline, several time steps before the end of an otherwise successful analysis. For example, the last three lines of a recorder file from a 30 second transient analysis may look something like below. 28.94 1.2433 -0.016987 28.96 … Continue reading Silence Is Golden
