|
楼主 |
发表于 2010-11-8 17:48
|
显示全部楼层
回复 6 # VibrationMaster 的帖子
我把代码贴上来,请指教一下,感谢:
Ndof=37;
[V,D] = eig(K,M);
d = sqrt(diag(D));
[ff,JJ]=sort(d/2/pi);
C = zeros( size( K ) ) ; % 无阻尼
% % 比例阻尼
% w1 = d(1);
% w2 = d(2);
% AA = 0.5*[1/w1 w1; 1/w2 w2];
% BB = [0.05 0.05]'; %% Assume that arbitary modal damping ratio is 5%
%
% CC = inv(AA)*BB;
%
% a1 = CC(1);
% a2 = CC(2);
%
% C = a1*M + a2*K;
%%
% %------ Step 2. 施加地震荷载或白噪声激励
load quake; % help quake (e,n,v)
% wave = 0.098*e; % 地震荷载
wave = wgn(20000,1,0); % Guass white noise,白噪声荷载
%%
% %------ Step 3. Newmark-beta for time history response
% step3.1 初始计算--定义参数
gDeltaT = 0.001 ;
gTimeEnd = 10000*gDeltaT ; % 计算时间为载荷通过所需时间的两倍
timestep = floor(gTimeEnd/gDeltaT) ;
gama = 0.5 ;
beta = 0.25 ;
% step3.2 Displacement,Velocity,Acceleration:定义位移,速度和加速度
gDisp = zeros( Ndof, timestep ) ;
gVelo = zeros( Ndof, timestep ) ;
gAcce = zeros( Ndof, timestep ) ;
% Initialization Conditions:初始条件
gDisp(:,1) = zeros( Ndof, 1 ) ;
gVelo(:,1) = ones( Ndof, 1 ) ;
[N,N] = size( K ) ;
alpha0 = 1/beta/gDeltaT^2 ;
alpha1 = gama/beta/gDeltaT ;
alpha2 = 1/beta/gDeltaT ;
alpha3 = 1/2/beta - 1 ;
alpha4 = gama/beta - 1 ;
alpha5 = gDeltaT/2*(gama/beta-2) ;
alpha6 = gDeltaT*(1-gama) ;
alpha7 = gama*gDeltaT ;
K1 = K + alpha0*M + alpha1*C;
timestep = floor(gTimeEnd/gDeltaT) ;
% step3.3 计算初始加速度
gAcce(:,1) = M\(-K*gDisp(:,1)-C*gVelo(:,1)) ;
p01=-diag(M);
% step3.4 迭代计算:对每一个时间步计算
for i=2:1:timestep
if mod(i,100) == 0
fprintf( '当前时间步:%d\n', i ) ;
end
pi1 = p01*wave(i);
f1 = pi1+M*(alpha0*gDisp(:,i-1)+alpha2*gVelo(:,i-1)+alpha3*gAcce(:,i-1)) ...
+ C*(alpha1*gDisp(:,i-1)+alpha4*gVelo(:,i-1)+alpha5*gAcce(:,i-1)) ;
gDisp(:,i) = inv(K1)*f1;
gAcce(:,i) = alpha0*(gDisp(:,i)-gDisp(:,i-1)) - alpha2*gVelo(:,i-1) - alpha3*gAcce(:,i-1) ;
gVelo(:,i) = gVelo(:,i-1) + alpha6*gAcce(:,i-1) + alpha7*gAcce(:,i) ;
end
|
评分
-
1
查看全部评分
-
|