Notes:
1. No prior experience with Python is required to use the visualization commands. 2. Python 3.7, Matplotlib, Numpy and vfo should be installed on the system. 3. The best way is to use Anaconda (or Miniconda, if you are low on space). 4. FFmpeg codecs are required to save the animation as a movie (.mp4) file. You can download the files used in this tutorials from my GitHub page. |
|
Update: While waiting for the next version of OpenSeesPy, the users can use a development package of the visualization library openseespyvis. Read the description on the openseespyvis page to understand the procedure.
Home page - openseespyvis
Install - pip install openseespyvis
Home page - openseespyvis
Install - pip install openseespyvis
The Python interpreter of OpenSees i.e. OpenSeesPy has several advantages over its Tcl counterpart in terms of plotting and visualization. In January 2020, visualization functions were first added to OpenSeesPy to visualize model and mode-shapes by using only a command. This command worked only for 3D beam-column elements but was later extended to visualize 2D and 3D beam-column elements, shell elements and 3D brick elements. After a long time, a new function to plot deformed shape of the structure was added by another user. At that moment, a long public discussion (here) started on the GitHub page on what other useful function can be added to this library. The best thing about an opensource program is that you get a boost when collaborators join in to help it make better.
Recently, a lot more functions were added to the post-processing using Python after almost one-month long overhauling of the visualization code. Major changes include commands to create an output database for specific load cases, plotting the model and mode-shapes without running the models (i.e. through the saved output database) and animation of deformed shape of the structures.
I had been advising new users to go towards OpenSeesPy to take advantage of Python plotting and ditch Matlab. However, new users find it hard to get guidance in learning OpenSeesPy since a lot of experienced users have used OpenSees Tcl. Also, there are third party pre and post-processors available for the Tcl version which impacts the decision of selecting Tcl over Python. I wanted OpenSees users to be able to take advantage of OpenSeesPy visualization library regardless of their choice of OpenSees interpreting language. Now it is possible.
Using OpenSeesPy to visualize OpenSees Tcl models:
The commands that can be used by OpenSees Tcl users are,
1. plot_model()
2. plot_modeshape()
3. plot_deformedshape()
4. animate_deformedshape()
The description of the commands is given on the OpenSeesPy documentation page. All users are advised to read the documentation carefully before jumping on to using the commands. The key here is to create an output database for your OpenSees Tcl model in a way that can be read by OpenSeesPy visualization library. This is done by using a file Get_Rendering.tcl. The name the same as the Get_Rendering plotting library of OpenSeesPy. This file can be downloaded from here. Get_Rendering.tcl defines a procedure to create an output database and the command of this procedure has been kept the same as the one in python interpreter i.e. createODB. However, all the inputs are needed. If the user does not want to record a specific output, “none” or “0” is required, depending on the variable. Make sure you read the description. Here is the summary of the procedure to follow.
Recently, a lot more functions were added to the post-processing using Python after almost one-month long overhauling of the visualization code. Major changes include commands to create an output database for specific load cases, plotting the model and mode-shapes without running the models (i.e. through the saved output database) and animation of deformed shape of the structures.
I had been advising new users to go towards OpenSeesPy to take advantage of Python plotting and ditch Matlab. However, new users find it hard to get guidance in learning OpenSeesPy since a lot of experienced users have used OpenSees Tcl. Also, there are third party pre and post-processors available for the Tcl version which impacts the decision of selecting Tcl over Python. I wanted OpenSees users to be able to take advantage of OpenSeesPy visualization library regardless of their choice of OpenSees interpreting language. Now it is possible.
Using OpenSeesPy to visualize OpenSees Tcl models:
The commands that can be used by OpenSees Tcl users are,
1. plot_model()
2. plot_modeshape()
3. plot_deformedshape()
4. animate_deformedshape()
The description of the commands is given on the OpenSeesPy documentation page. All users are advised to read the documentation carefully before jumping on to using the commands. The key here is to create an output database for your OpenSees Tcl model in a way that can be read by OpenSeesPy visualization library. This is done by using a file Get_Rendering.tcl. The name the same as the Get_Rendering plotting library of OpenSeesPy. This file can be downloaded from here. Get_Rendering.tcl defines a procedure to create an output database and the command of this procedure has been kept the same as the one in python interpreter i.e. createODB. However, all the inputs are needed. If the user does not want to record a specific output, “none” or “0” is required, depending on the variable. Make sure you read the description. Here is the summary of the procedure to follow.
Let's use this procedure in an example (canti.tcl) of a cantilever beam using ShellNLDKGQ elements. The output database can be saved by using only two additional lines of code in this script (line 73 and 74). First we import Get_Rendering.tcl to read the procedure to create an output database. Next, we call the procedure to create an output database createODB.
You can find the output database folder “CantiBeam_ODB” in the current directory and a “Push” load case sub-folder in it.
Now, create a python file (for example vis_model.py, or any name of your choice) in the current folder and add the following lines to it.
The first line imports the Get_Rendering library that has all the visualization commands. Then, you use the commands to plot the model, modeshapes and deformed shape by passing a reference to the model output database name and load case name that were used in the createODB() command.
The first command plots the OpenSees model with node tags on it. The second command plots the deformed shape at a time-step of 2.0 sec. with a scale factor of 1.0. The third command plots the deformed shape at the last step (default) of the analysis. All the plot windows are interactive and users can rotate, zoom in, and zoom out using the mouse click and scroll.
You can also create an interactive animation of the deformed shape using the fourth command in the above script. There is a default axis limits and view angle to this animation. Users can click on the animation window to pause and restart the animation. You can zoom in to the structure to see the animation of a specific part clearly if the structure is large. The argument Movie="CantiBeam" saves the animation to a file CantiBeam.mp4 in the load case folder using FFmpeg codecs (should be installed by the user on their system).
|