top3d.zip

• 一只皮蛋
了解作者
• matlab
开发工具
• 3KB
文件大小
• zip
文件格式
• 0
收藏次数
• 1 积分
下载积分
• 0
下载次数
• 2020-05-27 12:18
上传日期
169行三维程序，是三维的基础，可以在这上面更改
top3d.zip
• top3d.m
8.2KB

% AN 169 LINE 3D TOPOLOGY OPITMIZATION CODE BY LIU AND TOVAR (JUL 2013) function top3d(nelx,nely,nelz,volfrac,penal,rmin) % USER-DEFINED LOOP PARAMETERS maxloop = 200; % Maximum number of iterations tolx = 0.01; % Terminarion criterion displayflag = 0; % Display structure flag % USER-DEFINED MATERIAL PROPERTIES E0 = 1; % Young's modulus of solid material Emin = 1e-9; % Young's modulus of void-like material nu = 0.3; % Poisson's ratio % USER-DEFINED LOAD DOFs il = nelx; jl = 0; kl = 0:nelz; % Coordinates loadnid = kl*(nelx+1)*(nely+1)+il*(nely+1)+(nely+1-jl); % Node IDs loaddof = 3*loadnid(:) - 1; % DOFs % USER-DEFINED SUPPORT FIXED DOFs [jf,kf] = meshgrid(1:nely+1,1:nelz+1); % Coordinates fixednid = (kf-1)*(nely+1)*(nelx+1)+jf; % Node IDs fixeddof = [3*fixednid(:); 3*fixednid(:)-1; 3*fixednid(:)-2]; % DOFs % PREPARE FINITE ELEMENT ANALYSIS nele = nelx*nely*nelz; ndof = 3*(nelx+1)*(nely+1)*(nelz+1); F = sparse(loaddof,1,-1,ndof,1); U = zeros(ndof,1); freedofs = setdiff(1:ndof,fixeddof); KE = lk_H8(nu); nodegrd = reshape(1:(nely+1)*(nelx+1),nely+1,nelx+1); nodeids = reshape(nodegrd(1:end-1,1:end-1),nely*nelx,1); nodeidz = 0:(nely+1)*(nelx+1):(nelz-1)*(nely+1)*(nelx+1); nodeids = repmat(nodeids,size(nodeidz))+repmat(nodeidz,size(nodeids)); edofVec = 3*nodeids(:)+1; edofMat = repmat(edofVec,1,24)+ ... repmat([0 1 2 3*nely + [3 4 5 0 1 2] -3 -2 -1 ... 3*(nely+1)*(nelx+1)+[0 1 2 3*nely + [3 4 5 0 1 2] -3 -2 -1]],nele,1); iK = reshape(kron(edofMat,ones(24,1))',24*24*nele,1); jK = reshape(kron(edofMat,ones(1,24))',24*24*nele,1); % PREPARE FILTER iH = ones(nele*(2*(ceil(rmin)-1)+1)^2,1); jH = ones(size(iH)); sH = zeros(size(iH)); k = 0; for k1 = 1:nelz for i1 = 1:nelx for j1 = 1:nely e1 = (k1-1)*nelx*nely + (i1-1)*nely+j1; for k2 = max(k1-(ceil(rmin)-1),1):min(k1+(ceil(rmin)-1),nelz) for i2 = max(i1-(ceil(rmin)-1),1):min(i1+(ceil(rmin)-1),nelx) for j2 = max(j1-(ceil(rmin)-1),1):min(j1+(ceil(rmin)-1),nely) e2 = (k2-1)*nelx*nely + (i2-1)*nely+j2; k = k+1; iH(k) = e1; jH(k) = e2; sH(k) = max(0,rmin-sqrt((i1-i2)^2+(j1-j2)^2+(k1-k2)^2)); end end end end end end H = sparse(iH,jH,sH); Hs = sum(H,2); % INITIALIZE ITERATION x = repmat(volfrac,[nely,nelx,nelz]); xPhys = x; loop = 0; change = 1; % START ITERATION while change > tolx && loop < maxloop loop = loop+1; % FE-ANALYSIS sK = reshape(KE(:)*(Emin+xPhys(:)'.^penal*(E0-Emin)),24*24*nele,1); K = sparse(iK,jK,sK); K = (K+K')/2; U(freedofs,:) = K(freedofs,freedofs)\F(freedofs,:); % OBJECTIVE FUNCTION AND SENSITIVITY ANALYSIS ce = reshape(sum((U(edofMat)*KE).*U(edofMat),2),[nely,nelx,nelz]); c = sum(sum(sum((Emin+xPhys.^penal*(E0-Emin)).*ce))); dc = -penal*(E0-Emin)*xPhys.^(penal-1).*ce; dv = ones(nely,nelx,nelz); % FILTERING AND MODIFICATION OF SENSITIVITIES dc(:) = H*(dc(:)./Hs); dv(:) = H*(dv(:)./Hs); % OPTIMALITY CRITERIA UPDATE l1 = 0; l2 = 1e9; move = 0.2; while (l2-l1)/(l1+l2) > 1e-3 lmid = 0.5*(l2+l1); xnew = max(0,max(x-move,min(1,min(x+move,x.*sqrt(-dc./dv/lmid))))); xPhys(:) = (H*xnew(:))./Hs; if sum(xPhys(:)) > volfrac*nele, l1 = lmid; else l2 = lmid; end end change = max(abs(xnew(:)-x(:))); x = xnew; % PRINT RESULTS fprintf(' It.:%5i Obj.:%11.4f Vol.:%7.3f ch.:%7.3f\n',loop,c,mean(xPhys(:)),change); % PLOT DENSITIES if displayflag, clf; display_3D(xPhys); end %#ok<UNRCH> end clf; display_3D(xPhys); end % === GENERATE ELEMENT STIFFNESS MATRIX === function [KE] = lk_H8(nu) A = [32 6 -8 6 -6 4 3 -6 -10 3 -3 -3 -4 -8; -48 0 0 -24 24 0 0 0 12 -12 0 12 12 12]; k = 1/144*A'*[1; nu]; K1 = [k(1) k(2) k(2) k(3) k(5) k(5); k(2) k(1) k(2) k(4) k(6) k(7); k(2) k(2) k(1) k(4) k(7) k(6); k(3) k(4) k(4) k(1) k(8) k(8); k(5) k(6) k(7) k(8) k(1) k(2); k(5) k(7) k(6) k(8) k(2) k(1)]; K2 = [k(9) k(8) k(12) k(6) k(4) k(7); k(8) k(9) k(12) k(5) k(3) k(5); k(10) k(10) k(13) k(7) k(4) k(6); k(6) k(5) k(11) k(9) k(2) k(10); k(4) k(3) k(5) k(2) k(9) k(12) k(11) k(4) k(6) k(12) k(10) k(13)]; K3 = [k(6) k(7) k(4) k(9) k(12) k(8); k(7) k(6) k(4) k(10) k(13) k(10); k(5) k(5) k(3) k(8) k(12) k(9); k(9) k(10) k(2) k(6) k(11) k(5); k(12) k(13) k(10) k(11) k(6) k(4); k(2) k(12) k(9) k(4) k(5) k(3)]; K4 = [k(14) k(11) k(11) k(13) k(10) k(10); k(11) k(14) k(11) k(12) k(9) k(8); k(11) k(11) k(14) k(12) k(8) k(9); k(13) k(12) k(12) k(14) k(7) k(7); k(10) k(9) k(8) k(7) k(14) k(11); k(10) k(8) k(9) k(7) k(11) k(14)]; K5 = [k(1) k(2) k(8) k(3) k(5) k(4); k(2) k(1) k(8) k(4) k(6) k(11); k(8) k(8) k(1) k(5) k(11) k(6); k(3) k(4) k(5) k(1) k(8) k(2); k(5) k(6) k(11) k(8) k(1) k(8); k(4) k(11) k(6) k(2) k(8) k(1)]; K6 = [k(14) k(11) k(7) k(13) k(10) k(12); k(11) k(14) k(7) k(12) k(9) k(2); k(7) k(7) k(14) k(10) k(2) k(9); k(13) k(12) k(10) k(14) k(7) k(11); k(10) k(9) k(2) k(7) k(14) k(7); k(12) k(2) k(9) k(11) k(7) k(14)]; KE = 1/((nu+1)*(1-2*nu))*... [ K1 K2 K3 K4; K2' K5 K6 K3'; K3' K6 K5' K2'; K4 K3 K2 K1']; end % === DISPLAY 3D TOPOLOGY (ISO-VIEW) === function display_3D(rho) [nely,nelx,nelz] = size(rho); hx = 1; hy = 1; hz = 1; % User-defined unit element size face = [1 2 3 4; 2 6 7 3; 4 3 7 8; 1 5 8 4; 1 2 6 5; 5 6 7 8]; set(gcf,'Name','ISO display','NumberTitle','off'); for k = 1:nelz z = (k-1)*hz; for i = 1:nelx x = (i-1)*hx; for j = 1:nely y = nely*hy - (j-1)*hy; if (rho(j,i,k) > 0.5) % User-defined display density threshold vert = [x y z; x y-hx z; x+hx y-hx z; x+hx y z; x y z+hx;x y-hx z+hx; x+hx y-hx z+hx;x+hx y z+hx]; vert(:,[2 3]) = vert(:,[3 2]); vert(:,2,:) = -vert(:,2,:); patch('Faces',face,'Vertices',vert,'FaceColor',[0.2+0.8*(1-rho(j,i,k)),0.2+0.8*(1-rho(j,i,k)),0.2+0.8*(1-rho(j,i,k))]); hold on; end end end end axis equal; axis tight; axis off; box on; view([30,30]); pause(1e-6); end % ========================================================================= % === This code was written by K Liu and A Tovar, Dept. of Mechanical === % === Engineering, Indiana University-Purdue University Indianapolis, === % === Indiana, United States of America === % === ----------------------------------------------------------------- === % === Please send your suggestions and comments to: kailiu@iupui.edu === % === ----------------------------------------------------------------- === % === The code is intended for educational purposes, and the details === % === and extensions can be found in the paper: === % === K. Liu and A. Tovar, "An efficient 3D topology optimization code === % === written in Matlab", Struct Multidisc Optim, 50(6): 1175-1196, 2014, = % === doi:10.1007/s00158-014-1107-x === % === ----------------------------------------------------------------- === % === The code as well as an uncorrected version of the paper can be === % === downloaded from the website: http://www.top3dapp.com/ === % === ----------------------------------------------------------------- === % === Disclaimer: === % === The authors reserves all

相关推荐
• 拓扑优化程序学习报告.rar
对一个具体的部件结构，从设计思路到力学计算，到最后的程序设计和说明，详细的分析了拓扑优化的设计思路，为学习者提供易于理解，易于学习的资料
• TOP3D.rar
这是Kai Liu 和Tovar开发的169行MATLAB程序的说明文章，采用了SIMP算法，用于三的结构拓扑优化
• 3D拓扑优化程序matlab.rar
针对三悬臂梁，进行静载荷下的拓扑优化设计
• top3d.zip
MATLAB三拓扑程序，可以进行三维拓扑优化
• top3d.zip
很好的matlab三维拓扑优化程序，建议大家学习
• matlab拓扑优化代码-Top3d:用MATLAB编写的高效3D拓扑优化程序
Top3d是高效而紧凑的Matlab代码，用于解决三维拓扑优化问题。 包含此代码的169行代码包括有限元分析，灵敏度分析，密度过滤器，最优标准优化器和结果显示。 基本代码解决了最小的合规性问题。 提出了一种系统的方法...
• Top3d-master.zip
代码，用于解决三维拓扑优化问题。 包含此代码的 169 行包括有限元分析、灵敏度分析、密度过滤器、最优准则优化器和结果显示。 基本代码解决了最低限度的合规性问题。 提出了一种系统方法来轻松修改支撑和外部载荷的...
• 基于MATLAB的无线回传拓扑规划含程序代码
基于MATLAB的无线回传拓扑规划，根据基站建立基站间的连接方式，包括最短路径，最小费用等规划
• matlab实现基于SIMP法的99和169行连续体结构二维和三维拓扑优化程序，采用优化准则法求解。另附10篇相关...
matlab实现基于SIMP法的99和169行连续体结构二维和三维拓扑优化程序，采用优化准则法求解。另附10篇相关研究的硕士博士学位论文 板壳结构动力学拓扑优化设计理论方法研究及二次开发_李耀明 基于拓扑优化的船舶结构...