forked from wozy13/DIAMOND
-
Notifications
You must be signed in to change notification settings - Fork 0
/
era2mode.m
178 lines (122 loc) · 3.98 KB
/
era2mode.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
function era2mode(A,B,C,fs,emac_era,msv_era,respDOF,refDOF)
%
% Function: era2mode
%
% Usage: era2mode(A,B,C,fs,emac_era,msv_era,respDOF,refDOF)
%
% Converts state-space model A,B,C from ERA
% to complex modes, frequencies (Hz) and damping ratios (%)
%
% (Assumes measurements are from accelerometers)
%
% Author(s): Scott Doebling, [email protected]
% Phillip Cornwell, [email protected]
% Erik Straser, [email protected]
%
% Version SWD980617
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally %
% developed as part of "DIAMOND" at %
% Los Alamos National Laboratory. It may %
% be copied, modified, and distributed in %
% any form, provided: %
% a) This notice accompanies the files and %
% appears near the top of all source %
% code files. %
% b) No payment or commercial services are %
% received in exchange for the code. %
% %
% Original copyright is reserved by the %
% Regents of the University of California, %
% in addition to Scott W. Doebling, Phillip %
% J. Cornwell, Erik G. Straser, and Charles %
% R. Farrar. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global MODES
% Convert to continuous-time
[Ac,Bc] = d2cmatt(A,B,1/fs);
% Determine Damped Modal Realization
[vc,dc] = eig(Ac);
[vd,dd] = eig(A);
ddc = diag(dc);
ddd = diag(dd);
vci = inv(vc);
Ad = vci * Ac * vc;
Bd = vci * Bc;
%Cd = C * vc / dc^2 * 9.81; % ASSUMES ACCELERATION DATA!
Cd = C * vc / dc^2;
%
% Change signs of mode shapes based on sensor orientations
%
%for p = 1:size(respDOF,1),
% Cd(p,:) = Cd(p,:) * sign(respDOF(p,2));
%end
%for p = 1:size(refDOF,1),
% Bd(:,p) = Bd(:,p) * sign(refDOF(p,2));
%end
% Put emac in same order as continuous poles
nx = length(ddc);
if length(emac_era) ~= 0,
emac_sorted = zeros(nx,1);
for i = 1:nx,
[temp,imin] = min(abs(abs(ddc(i)) * ones(nx,1) - abs(log(ddd))*fs));
emac_sorted(i) = emac_era(imin(1));
end
else
emac_sorted = ones(nx,1);
end
% Remove real poles, etc. (to get 'reduced' matrices)
[Adr,Bdr,Cdr,ddcr,vcr,emacr] = chkpoles(Ad,Bd,Cd,ddc,vc,emac_sorted);
% Compute MPC
mpc_resp = mpc_comp(Cdr);
mpc_ref = mpc_comp(Bdr.');
% Extract the frequencies
dvec = [1:2:length(ddcr)];
nm = length(dvec);
freq_unsort = zeros(nm,1);
damp_unsort = zeros(nm,1);
phic_resp_unsort = zeros(size(Cdr,1),nm);
phic_ref_unsort = zeros(size(Bdr',1),nm);
mpc_resp_unsort = mpc_resp(dvec);
mpc_ref_unsort = mpc_ref(dvec);
emac_unsort = emacr(dvec);
for i = 1:nm,
freq_unsort(i) = abs(Adr(dvec(i),dvec(i)))/2/pi;
damp_unsort(i) = real(Adr(dvec(i),dvec(i)))./(-2*pi* freq_unsort(i));
%phic_resp_unsort(:,i) = Cdr(:,(dvec(i)+1)) * (2*sqrt(-1)*imag(Adr(dvec(i),dvec(i))));
phic_ref_unsort(:,i) = Bdr((dvec(i)+1),:).';
res_unsort(:,i) = Cdr(:,(dvec(i)+1)) * Bdr((dvec(i)+1),:).';
end
[freq, isort] = sort(freq_unsort);
damp = damp_unsort(isort);
phic_resp = phic_resp_unsort(:,isort);
phic_ref = phic_ref_unsort(:,isort);
mpc_resp = mpc_resp_unsort(isort);
mpc_ref = mpc_ref_unsort(isort);
emac = emac_unsort(isort);
res = res_unsort(:,isort);
cmi_resp = emac .* mpc_resp;
cmi_ref = emac .* mpc_ref;
% Delete existing modes
if isfield(MODES,'nmodes'),
if MODES.nmodes > 0,
for i = MODES.nmodes:-1:1,
deletemode(i)
end
end
end
% Define entries in MODES
MODES.nmodes = length(freq);
MODES.respDOF = respDOF;
MODES.refDOF = refDOF;
for i = 1:MODES.nmodes,
MODES.Freq{i} = freq(i);
MODES.Damp{i} = damp(i);
MODES.residue{i} = res(:,i).';
MODES.emac{i} = emac(i);
MODES.mpc{i} = mpc_resp(i);
MODES.cmi{i} = cmi_resp(i);
end
residues2modes
return