clc,clearformat short g% T15=173% T6=198% T7=230% T89=257% T1011=25% v=78/60 %单位cm/s T15=175T6=195T7=235T89=255T1011=25v=70/60 %单位cm/s dt=0.5 %每隔0.5 s焊接区域中心的温度t=0:dt:435.5/v; % ds=30.5% di=5%interval% darea=25 %炉前区域和炉后区域T0=Temp(v,t,T15,T6,T7,T89,T1011)%各个时间点T0(i)表示第i个点在x=0的温度% t=0对应T0下标1,t=i*0.5,对应下标i+1 t/0.5+1len=length(T0);f=[];for i=1:len %下标i对应的是(i-1)*0.5*v这个点f=[f;(i-1)*0.5*v,T0(i)];endplot(f(:,1),f(:,2))xlabel('x/cm','FontSize',10);ylabel('u/度','FontSize',10,'Rotation',0);title('炉内温度变化','FontSize',12); disp('----------------------------')% 0.15mm 0.075x=0.00075;dx=0.00005;m=x/dx;m=15n=length(t)-1 %n是区间段的个数,length是点的个数%已经在Temp函数(T0)中加上t=0mm=m+1;nn=n+1;% % m=5% % r=1;k=1;c=1;rho=1;h=1;arpha=0.0000003;%k/(c*rho);r=dt*arpha/(dx*dx)mmA=zeros(mm,mm);A=(1+2*r)*eye(mm)+diag(-r*ones(1,mm-1),1)+diag(-r*ones(1,mm-1),-1);A(1,1)=-1-dx*n/k;A(mm,mm)=1;A(mm,mm-1)=-1;A(1,2)=1;u=zeros(mm,nn); %每个时间对应一列u(:,1)=u(:,1)+25*ones(mm,1);% t=0时,电路板1~mm都是25°for i=2:5%nnb=[] ;b=u(:,i-1);b(1,1)=-dx*7*T0(i);%h/kb(mm)=0;tmp=A\b;u(:,i)=u(:,i)+tmp;bAtmpend% u% for i=2:length(t)%u(:,n+1)=u(:,n)+a^2*dt/dx^2*A*u(:,n);% a^2*(u关于x的二阶导)%u(1,n+1)=m1(n+1); %边界条件%u(end,n+1)=m2(n+1);%% end% % u
Temp.m
function T=Temp(v,t,T15,T6,T7,T89,T1011)% t1=25/v %炉前% t2=t1+(5*30.5+4*5)/v%1~5% t3=t2+(30.5+5)/v %小温区6% t4=t3+(30.5+5)/v %小温区7% t5=t4+(2*30.5+2*5)/v%小温区8`9 % dis=[25,30.5,5,]x1=25;%炉前区域x2=x1+(30.5+5)*4+30.5;%小温区15及其之间4个间隙x3=x2+5;%小温区5~小温区6之间间隙x4=x3+30.5;%小温区6x5=x4+5;%小温区6~小温区7之间间隙x6=x5+30.5;%小温区7x7=x6+5;%小温区7~小温区8之间间隙x8=x7+30.5*2+5;%小温区89及其之间1个间隙x9=x8+5;%小温区89~小温区1011之间间隙x10=x9+30.5*2+5+25 %435.5 小温区1011、炉后区域之间间隙% t=0:0.5:x10;T_air=25len=length(t);T=zeros(len-1,1);for i=1:len-1tt=i*0.5;d=tt*v;if(d<=x1) k=(T15-T_air)/(25/v);T(i)=T_air+k*(tt-0);elseif(d>x1&&d<=x2) %小温区15及其之间间隙T(i)=T15;elseif(d>x2&&d<=x3)k=(T6-T15)/((x3-x2)/v);T(i)=T15+k*(tt-x2/v);elseif(d>x3&&d<=x4) T(i)=T6;elseif(d>x4&&d<=x5)%67之间的间隙k=(T7-T6)/((x5-x4)/v);T(i)=T6+k*(tt-x4/v);elseif(d>x5&&d<=x6)T(i)=T7;elseif(d>x6&&d<=x7)k=(T89-T7)/((x7-x6)/v);T(i)=T7+k*(tt-x6/v);elseif(d>x7&&d<=x8)T(i)=T89; elseif(d>x8&&d<x9)%小温区89~小温区1011之间间隙k=(T89-T1011)/((x9-x8)/v);T(i)=T89-k*(tt-x8/v); elseif(d>x9&&d<=x10)T(i)=T1011;endendT=[25;T];% T=?% clc,clearend