4 Steps to Parallel Parametric Analysis with OpenSees + Python
You can download the full example here --> DOWNLOAD
Parametric analysis requires running a large number of nonlinear time-history analyses with OpenSees. I have seen at-least two popular cases,
1. Structural Optimization
2. Fragility Analysis
There are parallel commands but to be able to use them you have to compile OpenSeesPy locally and need to install MPI on your machine. Compiling OpenSees locally is not easy, at-least on a Windows machine.
At least for parametric analysis, there is an alternative way with Python itself using this module.
concurrent.futures
"The concurrent.futures module provides a high-level interface for asynchronously executing callable."
In simple words, you can launch multiple tasks using a simple and intuitive Python API call (command). Python is awesome!
There are two ways (subclasses) to perform multi-process using this module,
1 . ThreadPoolExecutor
This subclass uses multi-threading and we get a pool of threads for submitting the tasks. The tasks are assigned to multiple threads.
2 . ProcessPoolExecutor
This subclass uses multi-processing and we get a pool of processors for submitting the tasks. The tasks are assigned to multiple processors.
Here are the four steps to follow
Step 1
We will use "ProcessPoolExecutor" for our parallel analysis. First, import the module into your OpenSeesPy script.
Step 2
Create your OpenSees model as a Python function.
Step 3
Create a function for parallel analysis using the ProcessPoolExecutor. Here parameter values are defined in a list.
The parallel function should iterate over this list to,
- pick a parameter value,
- assign it to the OpenSees model definition
- send the model to any available processor for analysis.
Step 4
Call the parallel function by declaring,
__name__= __main__
Here is the full example.
When you run this example, you will see gravity output plots from each analysis on your screen.