loop for changing earthquake files?

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
0mindlessflip
Posts: 1
Joined: Tue Nov 10, 2020 5:49 am

loop for changing earthquake files?

Post by 0mindlessflip » Tue Nov 10, 2020 6:05 am

Hi dear all,

I'm working on a project in Opensees. As I'm not used to work with the software
I have a maybe easy question concerning a small 2D-Frame under different earthquake
accelerations.

Is there any possibility to built in a "loop" for outputting the different time histories
(acceleraion on y-Axis and time on x-Axis) for several hundred of earthquake files?
I would like to get Opensees loading the earhquake-files itself instead of changing the
name of the files manually.

The files I have are dot acc files which I can open with a normal editor.

Thank you very much,
Cedric

mhscott
Posts: 874
Joined: Tue Jul 06, 2004 3:38 pm
Location: Corvallis, Oregon USA
Contact:

Re: loop for changing earthquake files?

Post by mhscott » Wed Nov 11, 2020 7:34 pm

Code: Select all

set gmFilenames "file1.txt file2.txt ... "
foreach gmFile $gmFilenames {
   # analyze for $gmFile
}

Borislav
Posts: 4
Joined: Tue May 07, 2019 10:34 am

Re: loop for changing earthquake files?

Post by Borislav » Fri Nov 20, 2020 7:22 am

Something else you can try is using tcl's procs. It would look something like:

Code: Select all

proc MyAnalysis{ Groundmotion } {

#put the entirety of your current code inside this procedure

}
Then assuming your ground motion files are sequentially numbered in a way such as groundmotion1.acc, groundmotion2.acc, groundmotion3.acc, etc you would modify your time history code that points to a single file in the following way:

Code: Select all

set GM_file "groundmotion_$Groundmotion.acc"

timeSeries Path 1234 -dt $Dt -filePath myfolder/$GM_file -factor $gmfact
pattern UniformExcitation   $patternTag $dir  -accel 1234
and also then add the following block at the end of your code after the proc close bracket:

Code: Select all

set all_gms [list 1 2 3 4 5]

foreach Groundmotions $all_gms {
puts "Running Groundmotion record $Groundmotions"		
MyAnalysis $Groundmotions 
}
Hope this helps, I choose to define $all_gms as a list so that if you want to come back and say run gm's 1, 3, 15, and 62 you can just modify that list
-Boris

Post Reply