拓扑优化经典99行程序解读

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

3188-1-1.html

Sigmund教授所编写的top优化经典99行程序,可以说是我们拓扑优化研究的基础;

每一个新手入门都会要读懂这个程序,才能去扩展,去创新;

99行程序也有好多个版本,用于求解各种问题,如刚度设计、柔顺机构、热耦合问题,但基本思路大同小异;

本文拟对其中的一个版本进行解读,愿能对新手有点小小的帮助。

不详之处,还请论坛内高手多指点

读懂了该程序,只能说是略懂拓扑优化理论了,

我手里就有一些水平集源程序是成千上万行,虽然在99行的基础上成熟了很多,但依然还有很多的发展空间。

源程序如下:

%%%% A 99 LINE TOPOLOGY OPTIMIZATION CODE BY OLE SIGMUND, JANUARY 2000 %%%

%%%% CODE MODIFIED FOR INCREASED SPEED, September 2002, BY OLE SIGMUND %%%

function top(nelx,nely,volfrac,penal,rmin);

nelx=80;

nely=20;

volfrac=0.4;

penal=3;

rmin=2;

% INITIALIZE

x(1:nely,1:nelx) = volfrac;

loop = 0;

change = 1.;

% START ITERATION

while change > 0.01

loop = loop + 1;

xold = x;

% FE-ANAL YSIS

[U]=FE(nelx,nely,x,penal);

% OBJECTIVE FUNCTION AND SENSITIVITY ANAL YSIS

[KE] = lk;

c = 0.;

for ely = 1:nely

for elx = 1:nelx

n1 = (nely+1)*(elx-1)+ely;

n2 = (nely+1)* elx +ely;

Ue = U([2*n1-1;2*n1; 2*n2-1;2*n2; 2*n2+1;2*n2+2; 2*n1+1;2*n1+2],1);

c = c + x(ely,elx)^penal*Ue'*KE*Ue;

dc(ely,elx) = -penal*x(ely,elx)^(penal-1)*Ue'*KE*Ue;

end

end

% FILTERING OF SENSITIVITIES

[dc] = check(nelx,nely,rmin,x,dc);

% DESIGN UPDA TE BY THE OPTIMALITY CRITERIA METHOD

[x] = OC(nelx,nely,x,volfrac,dc);

% PRINT RESULTS

change = max(max(abs(x-xold)));

disp([' It.: ' sprintf('%4i',loop) ' Obj.: ' sprintf('%10.4f',c) ...

' Vol.: ' sprintf('%6.3f',sum(sum(x))/(nelx*nely)) ...

' ch.: ' sprintf('%6.3f',change )])

% PLOT DENSITIES

colormap(gray); imagesc(-x); axis equal; axis tight; axis off;pause(1e-6);

end

%%%%%%%%%% OPTIMALITY CRITERIA UPDATE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [xnew]=OC(nelx,nely,x,volfrac,dc)

l1 = 0; l2 = 100000; move = 0.2;

while (l2-l1 > 1e-4)

lmid = 0.5*(l2+l1);

xnew = max(0.001,max(x-move,min(1.,min(x+move,x.*sqrt(-dc./lmid)))));

if sum(sum(xnew)) - volfrac*nelx*nely > 0;

l1 = lmid;

else

l2 = lmid;

end

end

%%%%%%%%%% MESH-INDEPENDENCY FILTER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [dcn]=check(nelx,nely,rmin,x,dc)

dcn=zeros(nely,nelx);

for i = 1:nelx

for j = 1:nely

sum=0.0;

for k = max(i-floor(rmin),1):min(i+floor(rmin),nelx)

for l = max(j-floor(rmin),1):min(j+floor(rmin),nely)

fac = rmin-sqrt((i-k)^2+(j-l)^2);

sum = sum+max(0,fac);

dcn(j,i) = dcn(j,i) + max(0,fac)*x(l,k)*dc(l,k);

end

end

dcn(j,i) = dcn(j,i)/(x(j,i)*sum);

end

end

%%%%%%%%%%

FE-ANAL YSIS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

相关文档
最新文档