fid=fopen('kqlienketcung.txt','w');
fid1=fopen('kqanhhuongSSI.txt','w');
fid2=fopen('ketquaqdelta.txt','w');
n=input('Nhap so tang n=');
gama=0.5;
beta=0.25;
dt=0.02;
a0=1/(beta*dt*dt);
a1=gama/(beta*dt);
a2=1/(beta*dt);
a3=1/(2*beta)-1;
a4=gama/beta-1;
a5=dt*(gama/beta-2)/2;
a6=dt*(1-gama);
a7=gama*dt;
[m,k,h]=readdata(n);%doc file lay m, k, h o dang vecto tu file data voi du lieu dau vao la n
[M,K,C]=tinhmkc(m,k,n);%tinh ma tran khoi luong, do cung, can [Q,V,A]=newmark(K,M,C,m,a0,a1,a2,a3,a4,a5,a6,a7,dt);
%chuyen vi q=Q(n,:);
%van toc v=V(n,:);
%gia toc a=A(n,:);
n1=length(q);
t=0.02:dt:30;
tim_max_min_lkngam(Q,V,A,t,n)
fprintf(fid,'---KET QUA TINH TOAN--- --\n');
fprintf(fid,'STT t q v a \n');
fprintf(fid,'1 0.000000 0.000000 0.000000 0.000000 \n');
for i=1:n1
fprintf(fid,'%d %2f %4f
%4f %4f\n',i+1,t(i),q(i),v(i),a(i));
end
mf=input('nhap khoi luong mf=');
[kh,kdelta,mhi,ch,cdelta,vsd]=hamcandat(m,h,mf);
[MI,KI,CI,m1]=tinhSSI(m,h,M,K,C,kh,kdelta,mhi,ch,cdelta,mf);
[QI,VI,AI]=newmark(KI,MI,CI,m1,a0,a1,a2,a3,a4,a5,a6,a7,dt);
%chuyen vi qi=QI(n+2,:);
%van toc vi=VI(n+2,:);
%gia toc ai=AI(n+2,:);
qd=qi+QI(1,:)+h(n)*QI(2,:);
n2=length(qi);
fprintf(fid1,'---KET QUA TINH TOAN SSI--- ---\n');
fprintf(fid1,'STT t q v a \n');
fprintf(fid1,'1 0.000000 0.000000 0.000000 0.000000 \n');
fprintf(fid2,'STT t qdelta \n');
fprintf(fid2,' 1 0 0 \n');
for j=1:n2
fprintf(fid1,'%d %2f %4f
%4f %4f\n',j+1,t(j),qi(j),vi(j),ai(j));
fprintf(fid2,'%d %2f %4f
\n',j+1,t(j),qd(j));
end
code= input('Chon loai do thi muon the hien(0-chuyen vi/1-van toc/2-gia toc):');
if CI(1,1)==0 switch code case 0
plot(t,q,'b-','lineWidth',1.45);hold on plot(t,qi,'k-','lineWidth',1.45);hold on
plot(t,qd,'r-','lineWidth',1.45),legend('Lien kiet ngam','SSI so voi mong','SSI so voi ban dau');
hold off grid;
xlabel('Thoi gian(s)');
ylabel('Chuyen vi(m)');
title('DO THI SO SANH CHUYEN VI TUONG DOI KHONG XET HE SO CAN CUA DAT');
case 1
%---
plot(t,v,'b-','lineWidth',1.4);hold on
plot(t,vi,'r-','lineWidth',1.4),legend('Lien kiet ngam','Anh huong SSI');hold off
grid;
xlabel('Thoi gian(s)');
ylabel('Van toc(m/s)');
title('DO THI SO SANH VAN TOC KHONG XET HE SO CAN CUA DAT');
%--- case 2
plot(t,a,'b-','lineWidth',1.4);hold on
plot(t,ai,'r-','lineWidth',1.4),legend('Lien kiet ngam','Anh huong SSI');hold off
grid;
xlabel('Thoi gian(s)');
ylabel('Gia toc(m/s^2)');
title('DO THI SO SANH GIA TOC KHONG XET HE SO CAN CUA DAT');
end
elseif CI(1,1)==ch switch code case 0
plot(t,q,'b-','lineWidth',1.45);hold on plot(t,qi,'k-','lineWidth',1.45);hold on
plot(t,qd,'r-','lineWidth',1.45),legend('Lien kiet ngam','SSI so voi mong','SSI so voi ban dau');
hold off;
grid on;
xlabel('Thoi gian(s)');
grid;
xlabel('Thoi gian(s)');
ylabel('Van toc(m/s)');
title('DO THI SO SANH VAN TOC CO XET HE SO CAN CUA DAT');
%--- case 2
plot(t,a,'b-','lineWidth',1.4);hold on
plot(t,ai,'r-','lineWidth',1.4),legend('Lien kiet ngam','Anh huong SSI');hold off
grid;
xlabel('Thoi gian(s)');
ylabel('Gia toc(m/s^2)');
title('DO THI SO SANH GIA TOC CO XET HE SO CAN CUA DAT');
end end
timgiatrimaxmin(q,qi,qd,a,ai,v,vi,t,vsd) fclose all;
open('giatrimaxmin.txt');
Các chương trình con Hàm đọc dữ liệu
function [m,k,h]=readdata(n)
fid=fopen('data.txt','r');% doc file du lieu dac trung ket cau j=0;
%m=zeros(n,1);
%k=zeros(n,1);
%h=zeros(n,1);
while j<n j=j+1;
line1=fgets(fid);% bo hang dau tien
STT(:,j)=fscanf(fid,'%d',1); %doc lay cot so thu tu
m(:,j)=fscanf(fid,'%f',1); %doc lay gia tri o cot m de lap ma tran khoi luong
k(:,j)=fscanf(fid,'%f',1); %doc lay gia tri o cot k de lap ma tran do cung
h(:,j)=fscanf(fid,'%f',1); %doc lay gia tri o cot h de tinh xet anh huong SSI
end
Hàm thiết lập ma trận tính chất của kết cấu
function [M,K,C]=tinhmkc(m,k,n) M=diag(m);
K=zeros(n);
for i=1:n-1
K(i,i)=k(i)+k(i+1);
K(n,n)=k(n);
K(i,i+1)=-k(i+1);
K(i+1,i)=-k(i+1);
end
[V,D]=eig(K,M);
lamda=sort(diag(D));
omega=sqrt(lamda);
T=2*pi./omega;
xi=0.05;
a0=(2*xi*omega(1)*omega(2))/(omega(1)+omega(2));
a1=2*xi/(omega(1)+omega(2));
C=a0*M+a1*K;
Giải bài toán bằng phương pháp Newmark
function [Q,V,A]=newmark(K,M,C,m,a0,a1,a2,a3,a4,a5,a6,a7,dt) fid=fopen('ug.txt','r'); %doc file gia toc nen
t1=0.02;
t=0.02:dt:30;
n=length(t);
n1=length(M);
Ktb=K+a0*M+a1*C;
P=zeros(n1,n);
Q=zeros(n1,n);
V=zeros(n1,n);
A=zeros(n1,n);
U=zeros(n,1);
i=1;
while i<n+1
U(i)=fscanf(fid,'%f',1);
i=i+1;
end
P(:,1)=m*U(1);
Q(:,1)=Ktb^-1*P(:,1);
A(:,1)=a0*Q(:,1);
V(:,1)=a7*A(:,1);
for j=1:n-1
P(:,j+1)=-m'*U(j+1)+M*(a0*Q(:,j)+a2*V(:,j)+a3*A(:,j))+C*(a1*Q(:,j)+
a4*V(:,j)+a5*A(:,j));
Q(:,j+1)=Ktb^-1*P(:,j+1);
A(:,j+1)=a0*Q(:,j+1)-a0*Q(:,j)-a2*V(:,j)-a3*A(:,j);
V(:,j+1)=V(:,j)+a6*A(:,j)+a7*A(:,j+1);
end
Tìm giá trị max/min của từng tầng khi liên kết ngàm
function tim_max_min_lkngam(Q,V,A,t,n) fid=fopen('kq_q_max_min_lkngam.txt','w');
fid1=fopen('kq_v_max_min_lkngam.txt','w');
fid2=fopen('kq_a_max_min_lkngam.txt','w');
fprintf(fid,'Tang qn_max thoi diem max qn_min thoi diem min\n');
fprintf(fid1,'Tang vn_max thoi diem max vn_min thoi diem min\n');
fprintf(fid2,'Tang an_max thoi diem max an_min thoi diem min\n');
for i=1:n
[qnmax,b]=max(Q(i,:));
fprintf(fid1,'%d %.4f %.2f %.4f
%.2f\n',i,vnmax,t(e),vnmin,t(f));
fprintf(fid2,'%d %.4f %.2f %.4f
%.2f\n',i,anmax,t(g),anmin,t(h));
Tính độ cứng và cản của đất nền
function [kh,kdelta,mhi,ch,cdelta,vsd]=hamcandat(m,h,mf) disp('NHAP THONG SO DAT NEN')
v=input('Nhap he so Poisson cua dat:');
vsd=input('Nhap van toc cat cua dat:');
pt=input('Nhap trong luong rieng cua dat:');
rm=input('Chon loai mong (tron=0/vuong=1):');
if rm==0
r=nput('nhap ban kinh mong tron:');
rh=r;
rdelta=r;
else if rm==1
a=input('Nhap kich thuoc mong');
rh=sqrt(a^2/pi);
rdelta=(a^4/(3*pi))^(1/4);
end end
e=input('nhap do sau chon mong:');
g=9.81;
%Khoi luong rieng cua dat p=pt/g;
%Module khang cat dong cua dat G=p*vsd^2;
%---
%---HE SO DO CUNG CUA DAT---
%---
%He so do cung khi mong tren mat dat koh=32*(1-v)*G*rh/(7-8*v);
kodelta=8*G*rdelta^3/(3*(1-v));
%He so xet den do sau chon mong nih=1+0.55*(2-v)*e/rh;
nidelta=1+1.2*(1-v)*e/rdelta+0.2*(2-v)*(e/rdelta)^3;
%He so do cung khi mong chon sau kh=nih*koh;
kdelta=nidelta*kodelta;
%---
%---HE SO CAN CUA DAT---
%--- tgm=sum(m)+mf;
tgmh2=sum(m.*(h.^2));
mhi=m.*h;
tgmhi=sum(mhi);
%Can theo phuong ngang
bh=(7-8*v)*tgm*g/(32*(1-v)*p*rh^3);
xih=0.288/sqrt(bh);
canoh=2*xih*sqrt(kh*tgm);
alphah=(1+1.9*(2-v)*(e/rh))/sqrt(nih);
ch=alphah*canoh;
%Can xoay
bdelta=(0.375*(1-v)*g*tgmh2)/(p*rdelta^5);
xidelta=0.15/((1+bdelta)*sqrt(bdelta));
codelta=2*xidelta*sqrt(kdelta*tgmh2);
alphadetal=(1+0.7*(1-v)*(e/rdelta)+0.6*(2-v)*(e/rdelta)^3)/sqrt(nidelta);
cdelta=codelta*alphadetal;
Tính ảnh hưởng của SSI
function [MI,KI,CI,m1]=tinhSSI(m,h,M,K,C,kh,kdelta,mhi,ch,cdelta,mf) n=length(M);
a=mf+sum(m);
b=sum(mhi);
c=sum(m.*(h.^2));
H=m.*h;
Mff=[a b b c];
Mfs=zeros(2,n);
Mfs(1,:)=m;
Mfs(2,:)=H;
MI=[Mff Mfs Mfs' M];
Kff=[kh 0 0 kdelta];
KI=[Kff zeros(2,n) zeros(n,2) K];
code=1;%input('Chon 0-khong can/1-co can:');
switch code case 0
Cff=[0 0 0 0];
case 1 Cff=[ch 0 0 cdelta];
end
CI=[Cff zeros(2,n) zeros(n,2) C];
m1=MI(1,:);
Lưu kết quả ra dạng file text
function [q,v,a]=savekq(Q,V,A)
Tìm và so sánh giá trị lớn nhất và nhỏ nhất của chuyển vị, vận tốc và gia tốc
function timgiatrimaxmin(q,qi,qd,a,ai,v,vi,t,vsd) fid=fopen('giatrimaxmin.txt','w');
[qmax,j]=max(q);
[qimax,b]=max(qi);
[qdmax,c]=max(qd);
[qmin,d]=min(q);
[qimin,e]=min(qi);
[qdmin,f]=min(qd);
[aimin,w]=min(ai);
ssmax1=(qimax-qmax)*100/qmax;
ssmax2=(qdmax-qmax)*100/qmax;
ssmin1=(qimin-qmin)*100/qmin;
ssmin2=(qdmin-qmin)*100/qmin;
fprintf(fid,'Voi van toc cat cua dat la : %.0f ta co ket qua nhu sau:\n',vsd);
fprintf(fid,'Bang so sanh cac gia tri max cua chuyen vi\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'| |thoi diem | q_ngam max | q_SSI (B) max | q_SSI (C) max | sai so |\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'|Lien ket ngam (A) | %.2f | %.4f | %.4f |
%.4f | |\n',t(j),qmax,qi(j),qd(j));
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi mong (B) | %.2f | %.4f | %.4f |
%.4f | %.0f |\n',t(b),q(b),qimax,qd(b),ssmax1);
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi ban dau (C)| %.2f | %.4f | %.4f |
%.4f | %.0f |\n',t(c),q(c),qi(c),qdmax,ssmax2);
fprintf(fid,'--- ---\n');
fprintf(fid,'Bang so sanh cac gia tri min cua chuyen vi\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'| |thoi diem | q_ngam min | q_SSI (B) min | q_SSI (C) min | sai so |\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'|Lien ket ngam | %.2f | %.4f | %.4f |
%.4f | |\n',t(d),qmin,qi(d),qd(d));
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi mong (B) | %.2f | %.4f | %.4f |
%.4f | %.0f |\n',t(e),q(e),qimin,qd(e),ssmin1);
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi ban dau (C)| %.2f | %.4f | %.4f |
%.4f | %.0f |\n',t(f),q(f),qi(f),qdmin,ssmin2);
fprintf(fid,'--- ---\n');
fprintf(fid,'Gia tri max cua van toc \n');
fprintf(fid,'--- ---\n');
fprintf(fid,'| | thoi diem |v_ngam max| v_SSI (B) max | sai so |\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'|Lien ket ngam (A) | %.2f | %.2f | %.2f |
|\n',t(n),vmax,vi(l));
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi mong (B)| %.2f | %.2f | %.2f |
%.0f |\n',t(l),v(l),vimax,(vimax-vmax)*100/vmax);
fprintf(fid,'--- ---\n');
fprintf(fid,'Gia tri min cua van toc \n');
fprintf(fid,'--- ---\n');
fprintf(fid,'| | thoi diem |v_ngam min| v_SSI (B) min | sai so |\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'|Lien ket ngam (A) | %.2f | %.2f | %.2f |
|\n',t(g),vmin,vi(g));
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi mong (B)| %.2f | %.2f | %.2f |
%.0f |\n',t(h),v(h),vimin,(vimin-vmin)*100/vmin);
fprintf(fid,'--- ---\n');
fprintf(fid,'Gia tri max cua gia toc \n');
fprintf(fid,'--- ---\n');
fprintf(fid,'| | thoi diem |a_ngam max| a_SSI (B) max | sai so |\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'|Lien ket ngam (A) | %.2f | %.2f | %.2f |
|\n',t(i),amax,vi(i));
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi mong (B)| %.2f | %.2f | %.2f |
%.0f |\n',t(m),v(m),aimax,(aimax-amax)*100/amax);
fprintf(fid,'--- ---\n');
fprintf(fid,'Gia tri min cua gia toc \n');
fprintf(fid,'--- ---\n');
fprintf(fid,'| | thoi diem |a_ngam min| a_SSI (B) min | sai so |\n');
fprintf(fid,'--- ---\n');
fprintf(fid,'|Lien ket ngam (A) | %.2f | %.2f | %.2f |
|\n',t(o),amin,ai(o));
fprintf(fid,'--- ---\n');
fprintf(fid,'|SSI so voi mong (B)| %.2f | %.2f | %.2f |
%.0f |\n',t(w),v(w),aimin,(aimin-amin)*100/amin);
fprintf(fid,'--- ---\n');
120 1 1.29 2.21 1 1.39 2.36 130 1 1.42 2.27 1 1.50 2.37 140 1 1.27 1.92 1 1.34 2.04 150 1 1.25 1.81 1 1.33 1.92 160 1 1.26 1.74 1 1.29 1.80 170 1 1.24 1.67 1 1.26 1.70 180 1 1.24 1.62 1 1.24 1.62 190 1 1.22 1.56 1 1.21 1.54 200 1 1.21 1.51 1 1.18 1.47 210 1 1.19 1.45 1 1.15 1.41 220 1 1.17 1.41 1 1.13 1.37 230 1 1.16 1.38 1 1.11 1.33 240 1 1.15 1.35 1 1.10 1.29 250 1 1.14 1.32 1 1.08 1.26 260 1 1.13 1.29 1 1.07 1.23 270 1 1.12 1.27 1 1.08 1.22 280 1 1.11 1.25 1 1.08 1.21 290 1 1.10 1.23 1 1.07 1.20 300 1 1.09 1.21 1 1.08 1.20 310 1 1.08 1.19 1 1.07 1.19 320 1 1.08 1.18 1 1.07 1.17 330 1 1.07 1.16 1 1.06 1.16 340 1 1.06 1.15 1 1.05 1.14 350 1 1.05 1.14 1 1.04 1.13 360 1 1.05 1.13 1 1.03 1.12 370 1 1.04 1.12 1 1.03 1.11 380 1 1.04 1.11 1 1.03 1.11 390 1 1.03 1.10 1 1.03 1.10 400 1 1.03 1.09 1 1.03 1.09 410 1 1.03 1.09 1 1.03 1.09 420 1 1.02 1.08 1 1.03 1.08 430 1 1.02 1.08 1 1.02 1.08 440 1 1.02 1.08 1 1.02 1.08 450 1 1.02 1.08 1 1.02 1.07 460 1 1.02 1.07 1 1.02 1.07 470 1 1.02 1.07 1 1.02 1.06 480 1 1.02 1.07 1 1.02 1.06 490 1 1.02 1.07 1 1.01 1.06 500 1 1.02 1.06 1 1.01 1.05 510 1 1.02 1.06 1 1.01 1.05 520 1 1.02 1.06 1 1.01 1.05 530 1 1.02 1.06 1 1.01 1.05 540 1 1.02 1.06 1 1.01 1.04 550 1 1.02 1.05 1 1.01 1.04 560 1 1.02 1.05 1 1.01 1.04 570 1 1.02 1.05 1 1.00 1.04 580 1 1.02 1.05 1 1.00 1.03 590 1 1.02 1.05 1 1.00 1.03 600 1 1.02 1.05 1 1.00 1.03