-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathguyanold.m
executable file
·128 lines (123 loc) · 3.07 KB
/
guyanold.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
function [Mr,Kr,T,master,slave]=guyan(m,k,thresh)
%GUYAN Reduce size of second order system of equations by
% applying Guyan reduction.
% M x'' + K x = 0
% Mr xm'' + Kr xm = 0
% Where x = T*xm, Mr= transpose(T)*M*T, Kr= transpose(T)*K*T
%
%[Mr,Kr,T,master,slave]=GUYAN(M,K,thresh) slaves coordinates i for which
% thresh>(k(i,i)/m(i,i))/max(k(i,i)/m(i,i)). Master coordinates are returned
% in the vector master, slave coordinate indices are returned in the vector
% slave.
%
%[Mr,Kr,T,master,slave]=GUYAN(M,K,master) slaves coordinates which are not
% listed in the vector master. Master coordinates are returned
% in the vector master, slave coordinate indices are returned in the vector
% slave.
%
%[Kr,T,master,slave]=GUYAN(K,master) performs static condensation, slaving
% coordinates that are not listed in the vector master. Master coordinates are
% returned in the vector master, slave coordinate indices are returned in the
% vector slave.
%
%[Mr,Kr,T,master,slave]=GUYAN(M,K) slaves coordinates i for which
% 0.1>(k(i,i)/m(i,i))/max(k(i,i)/m(i,i)). Master coordinates are returned
% in the vector master, slave coordinate indices are returned in the vector
% slave.
%
% Reduced coordinate system forces can be obtained by
% fr=transpose(T)*F
%
% Reduced damping matrix can be obtained using Cr=transpose(T)*C*T.
%
% If mode shapes are obtained for the reduced system, full system mode shapes
% are phi=T*phi_r
%
%
% Copyright Joseph C. Slater, 6/19/2000
if size(k,1)==1 or size(k,2)==1
statcond=1;
thresh=k;
k=m;
m=eye(size(k));
end
sprse=1;
if ~issparse(m)
m=sparse(m);
k=sparse(k);
sprse=0;
end
if nargin==2
thresh=.1;
end
ncoord=length(m);
if length(thresh)==1
if thresh>=1
thresh=.1;
warndlg({'thresh must be less than 1.';'thresh has been set to .1'},'Threshold too hign')
% disp('move on')
end
dm=diag(m);
dk=diag(k);
rat=dm./dk;
%pause
%plot(sort(1./rat))
%pause
mr=rat./max(rat);
%plot(sort(mr))
%pause
mth=min(rat)/max(rat);
master=(mr)>thresh;
numofmasters=sum(master);
[rat,i]=sort(mr);
slave=i(1:ncoord-numofmasters);
master=i(ncoord-numofmasters+1:ncoord)';
lmaster=length(master);
else
master=thresh;
i=1:ncoord;
lmaster=length(master);
i(master)=zeros(lmaster,1);
i=sort(i);
slave=i(lmaster+1:ncoord);
end
if lmaster==ncoord
figure(gcf)
plot((1:ncoord)',rat./max(rat),[1 ncoord],[thresh thresh])
axis([1,ncoord, 0,1])
legend('Normalized Ratios','Cutoff for Slave Coordinates',0)
grid on
xlabel('Coordinate number')
ylabel('Normalized diagonal ratio.')
h=warndlg({['thresh must be greater than ' num2str(mth) ' for']...
;'this problem. Run aborted.'},'Threshold too hign');
t=(1:.1:70)';
noise=sin(10*t)+sin(3*t);
quiet=0*t;
sound([noise;quiet;noise;quiet;noise])
slave=0;master=0;Mr=0;Kr=0;T=0;
break
end
kmm=k(master,master);
ksm=k(slave,master);
kss=k(slave,slave);
kms=ksm';
T=zeros(ncoord,lmaster);
T=sparse(T);
T(master,1:lmaster)=eye(lmaster,lmaster);
T(slave,1:lmaster)=-kss\ksm;
if statcond~=1
Mr=T'*m*T;
end
Kr=T'*k*T;
if sprse==0
Mr=full(Mr);
Kr=full(Kr);
T=full(T);
end
if statcond==1
Mr=Kr;
Kr=T;
T=master;
master=slave;
end