batch execution for automation
Last updated
Last updated
In some use cases, it may be convenient to run parametric analysis of some numerical model with different parameters. A batch execution procedure may be required to automate the process. In this example, we show how to perform similar tasks. The model can be .
It must be noted that by default, all output files generated by recorders are saved under the current working folder. Only the recorder supports customized output folder name, which is again defined relative to current working folder.
Possible useful commands include: , . Depending on the different platform, it is always possible to use PowerShell, bash or other shells to perform automation tasks. Here, we show a Python example.
Suppose we, as structural engineers, are asked to perform a series of time history analyses to find the maximum displacement of some structure under a number of different ground motions.
For simplicity, let the structure be a SDOF mass--spring system, and we want to apply all the records in the database. Please note the provided archive only contains a few records. Please visit the corresponding page for the full database (with 700+ records).
We define a template of the model and use a placeholder named as $groundMotionRecord
to be later replaced by specific record names. The analysis time is labelled as $duration
. It can be changed for different records. The model script will look like the follows.
The above model defines a SDOF structure with a period of half a second. With PGA equals unity (ground motion record is normalised), the displacement is recorded.
The template model file batch-execution.supan
is placed alongside the folder NZStrongMotion
which contains example NZ strong motion records.
To automate the task, we want to
loop over all strong motion records
for each record, replace placeholder $groundMotionRecord
with the proper file name to load the record
replace $duration
with proper analysis duration which can be determined by the duration of record
perform the response history analysis
Note the recorded displacement is stored in *.h5
file, it may be better to store them in different folder with the name of the corresponding ground motion. This can be done in two approaches:
Create the folder first and launch suanPan
inside that folder.
Launch suanPan
first, use terminal
to create that folder, switch to that folder via pwd
and perform the analysis.
Given that we are going to use Python, we can simply choose the first option.
Now loop over each record and perform the analysis.
What if to postprocessing data? Since the output files are stored in HDF5
format, one can use h5py
to operate on those results to do whatever needed.