How to input response spectrum txt file.

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

Moderators: silvia, selimgunay, Moderators

Post Reply
shiro
Posts: 59
Joined: Tue May 26, 2020 1:19 am

How to input response spectrum txt file.

Post by shiro » Tue May 31, 2022 1:13 am

I have something to ask and I will post.

The following useful code causes an error in "Eqscaling.tcl" when reading a seismic wave.

can't read "designspectra(0)": no such element in array

The seismic wave was used as the response spectrum, and the acceleration was stored in the first column
and the period was stored in the second column, and saved as "Eighteen_Stories.txt".

In what format should the given txt file be given so that the error disappears?

I would appreciate it if you could tell me.


https://scholarsarchive.byu.edu/cgi/vie ... ontext=etd

   Minimizing Base Column Demands in Multi-Story Buckling Restrained Braced Frames Using Genetic Algorithms


$Designfile.txt = Eighteen_Stories.txt

0.01 0.44
0.02 0.48
0.022 0.488
0.025 0.5
0.029 0.516
0.03 0.52
0.032 0.528
0.035 0.54
0.036 0.544
0.04 0.56
0.042 0.568
0.044 0.576
0.045 0.58
0.046 0.584
0.048 0.592
0.05 0.6
0.055 0.62
0.06 0.64
0.065 0.66
0.067 0.668
0.07 0.68
0.075 0.7
0.08 0.72
0.085 0.74
0.09 0.76
0.095 0.78
0.1 0.8




(sec  ACC)





proc EqScaling {} {

global Designfile GMfile GMdir
puts "Scaling EQ"
set file $GMdir/$Designfile.txt
ReadDesignSpectraFile $file; # assembles array of design spectra
set number 1
foreach GM $GMfile {
#puts $GM
set file "$GMdir/$GM"
append file "_050.txt"
puts $file
ReadSpectraFile $file $number; # assembles array of earthquake spectra
incr number
}
puts "EQ Scaled"
}





proc ReadDesignSpectraFile {inFilename} {

# Formal arguments
# inFilename -- file which contains PEER strong motion record
# outArrayname -- file to be written in format .txt can read
global designspectra designspectranum
# Open the input file and catch the error if it can't be read
if {[catch {open $inFilename r} inFileID]} {
puts stderr "Cannot open $inFilename for reading"
} else {
# Flag indicating spectra values are found and that ground motion
# values should be read -- ASSUMES spectra values are at end of file
set flag 0
set i 0
#puts $i
# Look at each line in the file
foreach line [split [read $inFileID] \n] {
if {[llength $line] == 0} {
# Blank line --> do nothing
continue
} else {
split $line
# Find the first line of data values and set the flag
if {[string match [lindex $line 0] "0"] == 1} {set flag 1}
if {$flag == 1} {
incr i
set designspectra($i) [lindex $line 1]; # first value is the acc
lappend designspectra($i) [lindex $line 0]; # second value is period
#puts $designspectra($i)
}
}

#puts "$i $flag"
}
close $inFileID; # Close the input file
set designspectranum $i
#puts $designspectranum
}
}




proc ReadSpectraFile {inFilename j} {

# Formal arguments
# inFilename -- file which contains PEER strong motion record
# j -- earthquake number
#
# Assumptions
# The header in the PEER record is, e.g., formatted as follows:
# PACIFIC ENGINEERING AND ANALYSIS STRONG-MOTION DATA
# IMPERIAL VALLEY 10/15/79 2319, EL CENTRO ARRAY 6, 230
# ACCELERATION TIME HISTORY IN UNITS OF G
# NPTS= 3930, DT= .00500 SEC
global spectra spectranum
# Open the input file and catch the error if it can't be read

if {[catch {open $inFilename r} inFileID]} {
puts stderr "Cannot open $inFilename for reading"
} else {
# Flag indicating spectra values is found and that ground motion
# values should be read -- ASSUMES spectra values after last line
# of header!!!
set flag 0
set i 0
# Look at each line in the file
foreach line [split [read $inFileID] \n] {
if {[llength $line] == 0} {
# Blank line --> do nothing
continue
} else {
split $line
if {$flag == 1} {
incr i
set spectra($j,$i) [lindex $line 6]; # first one is acc
lappend spectra($j,$i) [lindex $line 8];# second one is period
#puts $spectra($j,$i)
}
# Find the first line of data values and set the flag
if {[string match [lindex $line 0] "1"] == 1} {set flag 1}
}
#puts "$i $flag"
}
close $inFileID; # Close the input file
set spectranum($j) $i
}
}

shiro
Posts: 59
Joined: Tue May 26, 2020 1:19 am

Re: How to input response spectrum txt file.

Post by shiro » Tue Jun 07, 2022 1:09 am

I can read "designspectra(0).

And the calculation was done.

However, I get an error and stop at the following points.


*********************************************


Calculating ductility...

Level 1 Deformation: 1.34585
Level 2 Deformation: 1.06504
Level 3 Deformation: 0.672844
Level 4 Deformation: 0.404818
Level 5 Deformation: 0.0950619
Level 6 Deformation: 0.096868
Level 7 Deformation: 0.301676
Level 8 Deformation: 0.08662
Level 9 Deformation: 0.0525909
Level 10 Deformation: 0.0895018
Level 11 Deformation: 0.121067
Level 12 Deformation: 0.04377
Level 13 Deformation: 0.0383664

missing operand at _@_
in expression "abs(-_@_)"


*********************************************


I couldn't solve it because I didn't understand the meaning of this error.

There was a corresponding code in AppAnalysis_area.v6.tcl.

I would be grateful if you could give me some advice.



・「AppAnalysis_area.v6.tcl」


puts " Calculating ductility..."
for {set level 1} {$level <= $NumStories} {incr level} {
set Ductility($ii,$level) -$DBL_MAX
}
# Method from Graham Oxborrow on 4/2/09
for {set level 1} {$level <= $NumStories} {incr level} {

# puts "$ii $level $j"
set Deformation($ii,$level,[expr $j+1]) -$DBL_MAX
#puts $Deformation($ii,$level,[expr $j+1])
if {[catch {open "$dataDir/$FileName/$ii/BraceDeform$level Eq[expr $j+1].out" r 0666} fileID]} {
puts "Cannot open $dataDir/$FileName/$ii/BraceDeform$level Eq[expr $j+1].out"
} else {
foreach line [split [read $fileID] \r\n] {
set bracedeform [split $line]
set x [lindex $bracedeform 1]
if {$x != ""} {
set brdf [expr abs($x)]
if {$brdf > $Deformation($ii,$level,[expr $j+1])} {
set Deformation($ii,$level,[expr $j+1]) $brdf;
#puts $Deformation($ii,$level,[expr $j+1])
# this will turn out to be the max deformation on that level
}
}
}
}
puts "Level $level Deformation: $Deformation($ii,$level,[expr $j+1])"
close $fileID
}

Post Reply