-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetResponseSpectrum.m
187 lines (166 loc) · 5.35 KB
/
getResponseSpectrum.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% CIVL5750 Homework 2
%%% Matlab code to compute acceleration response spectrum
%%% Gang Wang, HKUST Mar. 08, 2011
%%% add comments on Mar. 25, 2013
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function PSA=getResponseSpectrum(acc, dt, Period, damp)
%%%% input
%%%% AccFileName: File name (character) for data in PEER format
%%%% dt is obtained automatically from the PEER format
%%%% can not work for other format
%%%% example:
%%%% PlotResponseSpectrum('YBI090.AT2')
%%%% output:
%%%% PSA: psudo-spectral acceleration
%%%%%%%%%%%%%%%%% no need to change below %%%%%%%%%%%%%%%%%
%%% integrate time histories
time=[1:length(acc)]*dt;
% acc=acc'; % acc is now a row vector
acc2=[0, acc(1:(length(acc)-1))];
accAvg= (acc+acc2)/2;
vel= cumsum(accAvg).*dt .*981; % in unit of cm/s
velAvg= vel + (acc./3+acc2./6).*dt.*981 ;
displ = cumsum(velAvg).* dt;
PGA=max(abs(acc)); % in unit of g
PGV=max(abs(vel)); % in unit of cm/s
PGD=max(abs(displ)); % in unit of cm
Ia_time=pi/2*cumsum(abs(acc).^2)*dt; % unit g-sec %%% corrected Apr. 25, 2017
%%%%%%%%%%%%% Calculate spectra STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:length(Period)
T=Period(i);
Omega=2*pi/T;
%%%%%%%% use algorithm from SPECTAE (Geomatrix) %%%%%%
kug=length(time)-1;
if T < 10*dt % stiff system, reduce time step
[z]=ucmpmx(kug,acc,time,T,Omega,damp);
else
[z]=cmpmax(kug,acc,T,Omega,damp,dt);
end
rd(i)=z(1); % max relative disp. for period T, disp response spectrum
rv(i)=z(2); % max relative vel. for period T, vel response spectrum
aa(i)=z(3); % max absolute acc. for period T, Acc response spectrum
PsedoSV(i)=2*pi/T*rd(i); % psedo-velocity response spectrum
PsedoSA(i)=(2*pi/T)^2*rd(i); % psedo-acceleration response spectrum
end
%%%%%%%% use algorithm from SPECTAE (Geomatrix) END %%%%%%
%%%%% the final results %%%%%%%%%%%%%%
Sa=aa; % max absolution acc, unit: g
Sv=rv *981; % max relative vel., unit: cm/s
Sd=rd *981; % max relative disp., unit: cm
PSV=PsedoSV *981; % Psedo-velocity, unit: cm/s
PSA=PsedoSA; % Psedo-acceleration, unit: g
% compute response of single-DOF system under arbituary time step
function [z]=ucmpmx(kug,ug,time,pr,w,d)
% inputs:
% kug -- number of time increment
% ug -- input ground acceleration
% time -- time sequence
% pr -- period at which spectra are calculated
% w -- frequency
% d -- damping ratio,
% outputs:
% z - z(1); maximum relative displacement
% z(2); maximum relative velocity
% z(3); maximum absolute acceleration
% x is time history, not outputed yet
wd=sqrt(1.-d*d)*w;
w2=w*w;
w3=w2*w;
for i=1:3
x(1,i)=0.0;
z(i)=0.0;
end
f2=1./w2;
f3=d*w;
f4=1./wd;
f5=f3*f4;
f6=2.*f3;
for k=1:kug
dt=time(k+1)-time(k);
ns=round(10.*dt/pr-0.01);
dt=dt/real(ns); % reduce time step for STIFF system
f1=2.*d/w3/dt;
e=exp(-f3*dt);
g1=e*sin(wd*dt);
g2=e*cos(wd*dt);
h1=wd*g2-f3*g1;
h2=wd*g1+f3*g2;
dug=(ug(k+1)-ug(k))/real(ns);
g=ug(k);
z1=f2*dug;
z3=f1*dug;
z4=z1/dt;
for is=1:ns % march over reduced substeps
z2=f2*g;
b=x(1,1)+z2-z3;
a=f4*x(1,2)+f5*b+f4*z4;
x(2,1)=a*g1+b*g2+z3-z2-z1;
x(2,2)=a*h1-b*h2-z4;
x(2,3)=-f6*x(2,2)-w2*x(2,1);
for l=1:3
c(l)=abs(x(2,l));
if(c(l)>=z(l))
z(l)=c(l);
t(l)=time(k)+is*dt;
else
end
x(1,l)=x(2,l);
end
g=g+dug;
end
end
% compute response of single-DOF system under fixed time step
function [z]=cmpmax(kug,ug,pr,w,d,dt)
% inputs:
% kug -- number of time increment
% ug -- input ground acceleration
% pr -- period at which spectra are calculated
% w- frequency
% d -- damping ratio,
% dt -- time step,
% outputs:
% z - z(1); maximum relative displacement
% z(2); maximum relative velocity
% z(3); maximum absolute acceleration
% x is time history, not outputed yet
wd=sqrt(1.-d*d)*w;
w2=w*w;
w3=w2*w;
for i=1:3
x(1,i)=0.0;
z(i)=0.0;
end
f1=2.*d/(w3*dt);
f2=1./w2;
f3=d*w;
f4=1./wd;
f5=f3*f4;
f6=2.*f3;
e=exp(-f3*dt);
g1=e*sin(wd*dt);
g2=e*cos(wd*dt);
h1=wd*g2-f3*g1;
h2=wd*g1+f3*g2;
for k=1:kug
dug=ug(k+1)-ug(k);
z1=f2*dug;
z2=f2*ug(k);
z3=f1*dug;
z4=z1/dt;
b=x(1,1)+z2-z3;
a=f4*x(1,2)+f5*b+f4*z4;
x(2,1)=a*g1+b*g2+z3-z2-z1; % relative disp.
x(2,2)=a*h1-b*h2-z4; % relative vel.
x(2,3)=-f6*x(2,2)-w2*x(2,1); % absolute acc.
% find the maximum of each
for l=1:3
c(l)=abs(x(2,l));
if(c(l)>=z(l))
z(l)=c(l);
t(l)=dt*real(k);
else
end
x(1,l)=x(2,l);
end
end