设计域

设计结果

代码
主代码(备注:程序没有经过优化,所以看起来比较多,请指正)
clc;
clear;
Lx = 0.2; % length x-direction
Ly = 0.2; % length y -direction
cv_x=100;cv_y=100;
ni = cv_x+1; % grid points x-direction
nj = cv_y+1; % grid points y-direction
ei = cv_x+2; ej = cv_y+2; %虚拟单元
Dx = Ly/cv_x; Dy = Ly/cv_y;
dx = Dy; dy = Dy;
xcord = 0:Dx:Lx;
ycord = 0:Dy:Ly;
DV =Dx*Dy;
Ex = 0-dx/2:dx:(ei-1)*dx;
Ey = 0-dx/2:dy:(ej-1)*dy;
bT0=[1 5];bT1 =[200,200];
%%
lameda0 = 900; %900 W/m^2*K
cp = 690; %690 J/kg*K
rho = 2220; %(kg/m^3)
Tinit =293.15;
qB1 = 5E6;
maxtime = 100;
p=1.5;
T(1:ni,1:nj) = Tinit;
theta(1:ei,1:ej) = 0;
theta(2:ei-1,2:ej-1) =0.8;
volfrac=0.50;
r=0.005;
for loop = 1:300
thetaold = theta;
Elameda=lameda0*theta.^p;
T = thermalFVMout(T,Elameda,ni,nj,Dx,Dy,Tinit,qB1,rho,cp,maxtime,bT0,bT1);
c = sum(sum(T))/(ni*nj);
dc = calcdc(ni,nj,ei,ej,Dy,Dx,lameda0,T,theta,p);
dc= SensitivityFilter(Ex,Ey,ei,ej,r,dc,theta);
theta(2:ei-1,2:ej-1) = MMA(ei-2,ej-2,theta(2:ei-1,2:ej-1),volfrac,-dc(2:ei-1,2:ej-1));
change = max(max(abs(theta(2:ei-1,2:ej-1)-thetaold(2:ei-1,2:ej-1))));
disp([' It.: ' sprintf('%4i',loop) ' Obj.: ' sprintf('%10.4f',c) ...
' Vol.: ' sprintf('%6.3f',sum(sum(theta(2:ni-1,2:nj-1)))/((ni-2)*(nj-2))) ...
' ch.: ' sprintf('%6.3f',change)])
cStore(loop) =c;
% PLOT DENSITIES
% thetaAll(:,:,loop)=theta;
% TAll(:,:,loop)=T;
figure(1);
pcolor(T(1:ni,1:nj));xlabel('x');ylabel('y');title('Temperature distribution');colorbar;
filename = ['C:\Users\DELL018\Desktop\Thermal30C01\T\T_',num2str(loop),];
saveas(gc