batch execution for automation
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 downloaded.
It must be noted that by default, all output files generated by recorders are saved under the current working folder. Only the Visualization recorder supports customized output folder name, which is again defined relative to current working folder.
Possible useful commands include: pwd , terminal. 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.
Batched Time History Analysis
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 NZ Strong Motion database. Please note the provided archive only contains a few records. Please visit the corresponding page for the full database (with 700+ records).
The Model
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.
# an example of batch processing
node 1 0 0
node 2 1 0
# set modulus ==> 16\pi^2
material Elastic1D 1 157.913670417
element T2D2 1 1 2 1 1
mass 2 2 1 1
fix 1 1 1
fix 2 2 1 2
amplitude NZStrongMotion 1 $groundMotionRecord
# apply reference acceleration ==> 1m/s^2
acceleration 2 1 1.0 1 2
hdf5recorder 1 Node U1 2
step dynamic 1 $duration
set ini_step_size 1E-2
set fixed_step_size true
integrator Newmark 1
converger AbsIncreDisp 1 1E-12 10 1
analyze
exitThe 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.
Folder Structure
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
$groundMotionRecordwith the proper file name to load the recordreplace
$durationwith proper analysis duration which can be determined by the duration of recordperform 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
suanPaninside that folder.Launch
suanPanfirst, useterminalto create that folder, switch to that folder viapwdand perform the analysis.
Given that we are going to use Python, we can simply choose the first option.
Python Script
Load Template First
Load All Record Names
Loop
Now loop over each record and perform the analysis.
Postprocessing
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.
Last updated