《ANSYS优化设计(含几个实例).pdf》由会员分享,可在线阅读,更多相关《ANSYS优化设计(含几个实例).pdf(22页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、.ANSYS 优化设计 1.认识 ANSYS 优化模块 1.1 什么时候我需要它的帮忙?什么是 ANSYS 优化?我想说明一个例子要比我在这里对你絮叨半天容易理解的多。注意过普通的水杯吗?底面圆圆的,上面加盖的哪一种。仔细观察一下,你会发现比较老式的此类水杯有一个共同特点:底面直径水杯高度。图 1 水杯的简化模型 为什么是这样呢?因为只有满足这个条件,才能在原料耗费最少的情况下使杯子的容积最大。在材料一定的情况下,如果水杯的底面积大,其高度必然就要小;如果高度变大了,底面积又大不了,如何调和这两者之间的矛盾?其实这恰恰就反应了一个完整的优化过程。在这里,一个水杯的材料是一定的,所要优化的变量就
2、是杯子底面的半径 r 和杯子的高度 h,在 ANSYS 的优化模块里面把这些需要优化的变量叫做设计变量(DV);优化的目标是要使整个水杯的容积最大,这个目标在 ANSYS 的优化过程里叫目标函数(OBJ);再者,对设计变量的优化有一定的限制条件,比如说整个杯子的材料不变,这些限制条件在 ANSYS的优化模块中用状态变量(SV)来控制。下面我们就来看看 ANSYS 中怎么通过设定 DV、SV、OBJ,利用优化模块求解以上问题。首先参数化的建立一个分析文件(假设叫 volu.inp),水杯初始半径为 R1,高度为 H1(DV),由于水杯材料直接喝水杯的表面积有关系,这里假设水杯表面积不能大于 10
3、0,这样就有 S2RH2R2 SOLUTION HAS CONVERGED TO POSSIBLE OPTIMUM (BASED ON OBJ TOLERANCE BETWEEN BEST AND FINAL DESIGNS)可见是因为导致循环提前结束。(注:细观上图,Fj=157.20,Fb=151.62,默认公差似乎此处应该是 1.5720,似乎还没有满足这个收敛准则,为什么 ANSYS 却认为满足了,这里就不得而知,可能 ANSYS 内部对默认公差里面的当前值另有解释;如果你强行规定目标函数公差为1,可以看到循环多进行一步后也会提前结束,不过这时候当前解151.65和最优解151.62倒
4、的确相差小于公差 1 了)。此时,大家一定可以理解例子中为什么要对公差的限制如此严谨了(0.01)。因为程序的取样,迭代都有随机性,只有这样,才能保证程序不会因为上述公差太大的缘故自动停止而得不到最优解。有兴趣的同学还可以改变一下其他参数的公差大小,甚至用 opsubp 命令改变默认循环的次数等,这些实验将会更加加深你对优化过程、收敛准则的理解,便于提高你都负责优化问题的驾驭能力。.拓扑优化实例/clear/TITLE,A 2-D,multiple compliance minimization problem subjected to volume constraint/PREP7 BLC4
5、,0,0,3,1 !Create solid model(3 x 1 rectangle)ET,1,82 !Use 2-D solids.Type 1 is optimized ET,2,82 !Type 2 is not optimized.MP,EX,1,118E9 !Linear isotropic,material MP,NUXY,1,0.3 ESIZE,0.05 !Use a relatively fine mesh density TYPE,1 AMESH,ALL !Free,rectangular-element meshing NSEL,S,LOC,X,0,0.4 !Selec
6、t region not to be optimized ESLN TYPE,2 EMODIF,ALL !Define type 2 elements ALLSEL NSEL,S,LOC,X,0 D,ALL,ALL,0 !Fixed at X=0 NSEL,S,LOC,X,3 D,ALL,ALL,0 !Fixed at X=3 FORCE=1000 !Value for applied load NSEL,S,LOC,X,1 NSEL,R,LOC,Y,1 F,ALL,FY,FORCE !Define first load case ALLSEL LSWRITE,1 !Write first l
7、oad case FDEL,ALL NSEL,S,LOC,X,2 NSEL,R,LOC,Y,0 F,ALL,FY,-FORCE !Define second load case ALLSEL LSWRITE,2 !Write second load case FDEL,ALL TOCOMP,MCOMP,MULTIPLE,2!Define multiple compliance function !MCOMP for topological optimization TOVAR,MCOMP,OBJ !Define MCOMP as topological objective TOVAR,VOLU
8、ME,CON,50 !Define VOLUME as topological constraint;50 percent volume reduction TOTYPE,OC !Specify solution approach TODEF !Initialize topological opt./SHOW,topo,grph !Put graphics in a file(remove if interactive)/DSCALE,OFF./CONTOUR,2 TOLOOP,12,1 !Perform no more than 12 iterations FINISH TOGRAPH,OB
9、J !Graph final objective(compliance)history TOGRAPH,CON !Graph final constraint(volume)history TOPRINT,OBJ !Print final objective(compliance)history TOPRINT,CON !Print final constraint(volume)history*GET,TITER,TOPO,ITER !Get iteration counter*GET,OCMP,TOPO,TITER-1,TOHO!Get final compliance value.第 3
10、 例 复杂形状实体的创建实例螺栓 本例提示 在使用 ANSYS 软件进行结构分析时,建立实体模型是最复杂最难以掌握的一个过程。因此,有必要熟练掌握实体模型的创建。本例使用 ANSYS 软件提供的各种建模工具,对复杂形状实体的创建进行了练习。/PREP7 CSYS,1 K,1,0.008,0,-0.002 K,2,0.008,90,-0.0015 K,3,0.008,180,-0.001 K,4,0.008,270,-0.0005 K,5,0.008,0,0/VIEW,1,1,1,1 L,1,2 L,2,3 L,3,4 L,4,5 LGEN,7,ALL,0.002 NUMMRG,KP,LOW L
11、COMB,ALL K,80,0.008+0.0015/4,90,0.012+0.002/4.K,81,0.008+2*0.0015/4,180,0.012+2*0.002/4 K,82,0.008+3*0.0015/4,270,0.012+3*0.002/4 K,83,0.008+4*0.0015/4,0,0.012+4*0.002/4 L,35,80 L,80,81 L,81,82 L,82,83 CSYS,0 K,90,0.008,0,-0.00025 K,91,0.006918,0,-0.002 K,92,0.006918,0,0/PNUM,KP,1 /PNUM,LINE,1 GPLOT
12、 LSTR,1,90 LSTR,91,92 LANG,7,90,60,0 LANG,7,1,120,0 AL,6,9,10,11 VDRAG,1,1,2,3,4,5/PNUM,KP,0 /PNUM,LINE,0/PNUM,AREA,1/PNUM,VOLU,1 CYLIND,0.0079,0,0.04,0,360 VSEL,U,6 CM,VVV2,VOLU ALLS VSBV,6,VVV2/REPLOT.K,93,0.0065,0,0 K,94,0.0095,0,0.003 K,95,0,0,0 K,96,0,0,0.03 LSTR,93,94 AROTAT,6,95,96,360 ASEL,S
13、,1,4,1 VSBA,7,ALL ASEL,ALL VDELE,1,1 RPRISM,0.04,0.05,6,0.0131 CONE,0.03477,0.00549,0.03,0.055,0,360 VINV,1,3/REPLOT VPLOT FINISH .第 26 例 优化设计实例梁的优化设计 本例提示 介绍了优化设计的相关理论和应用,讲述了将设计问题的物理模型转化为数学模型选取设计变量、写出目标函数、给出约束条件的方法。1.优化分析文件!H=0.06 B=0.06 L=1 /PREP7 ET,1,BEAM3 R,1,B*H,B*H*H*H/12,H MP,EX,1,2E11 MP,NU
14、XY,1,0.3 K,1,0,0,0 K,2,L,0,0 LSTR,1,2 LESIZE,1,50 LMESH,1 FINISH /SOLU DK,1,UX DK,1,UY DK,2,UX DK,2,UY SFBEAM,ALL,1,PRES,5000 SOLVE SAVE FINISH./POST1 ETABLE,E_VOL,VOLU SSUM*GET,V_TOT,SSUM,ITEM,E_VOL NSORT,U,Y *GET,UY_MIN,SORT,MIN UY_MAX=ABS(UY_MIN)FINISH 2.优化控制文件!/FILNAME,EXAMPLE26/OPT OPCLR FINISH
15、/CLEAR/INPUT,EXAMPLE26,LGW /OPT OPANL,EXAMPLE26,LGW OPVAR,B,DV,0.05,0.1,0.001 OPVAR,H,DV,0.05,0.1,0.001 OPVAR,UY_MAX,SV,0,2E-4,1E-5 OPVAR,V_TOT,OBJ,1E-5 OPSAVE,EXAMPLE26,OPT OPTYPE,FIRST OPFRST,30 OPEXEC OPLIST,ALL FINISH.3.求解方法 先分别以文件名 EXAMPLE26.LGW、EXAMPLE26_OPT.TXT 将优化分析文件和优化控制文件存储在 ANSYS 的工作文件夹里
16、,再在 ANSYS 的输入窗口输入/INPUT,EXAMPLE26_OPT,TXT,回车,开始求解。.第 27 例 优化设计实例曲柄摇杆机构的优化设计 本例提示 介绍了一个更复杂、更接近于实际的优化设计实例。1.优化分析文件!PI=3.1415926 A=2 B=8 C=7.5 D=9.5 AX=1 AY=4 BATA_OPT=PI/16 K=7 GAMA=PI/3!建立有限元模型/PREP7 BATA=BATA_OPT-PI/2 OMGA1=0.5 T=60/OMGA1 ET,1,COMBIN7 ET,2,BEAM4 .MP,EX,1,2E11 MP,PRXY,1,0.3 MP,DENS,1
17、,1E-14 R,1,1E9,1E3,1E3,0 R,2,4E-4,1.3333E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,2,9,UX NSOL,3,9,UY.*DIM,X9,ARRAY,100 *DIM,Y9,ARRAY,100 VGET,X9,2 VGET,Y9,3*DO,I,1,1
21、00 X9(I)=KX+X9(I)Y9(I)=KY+Y9(I)*ENDDO G2=B+C-A-D G3=C+D-A-B G4=B+D-A-C COS_GAMA1=(B*B+C*C-(D-A)*(D-A)/2/B/C COS_GAMA2=(B*B+C*C-(D+A)*(D+A)/2/B/C*IF,COS_GAMA1,GE,-1,AND,COS_GAMA1,LE,1,THEN G5=ACOS(COS_GAMA1)-30*PI/180*ELSE G5=-1*ENDIF*IF,COS_GAMA2,GE,-1,AND,COS_GAMA2,LE,1,THEN G6=150*PI/180-ACOS(COS_
22、GAMA2)*ELSE G6=-1*ENDIF F2=0*DO,I,1,10 F2=F2+(Y9(I*10)-Y_OBJ(I)*(Y9(I*10)-Y_OBJ(I)+(X9(I*10)-X_OBJ(I)*(X9(I*10)-X_OBJ(I)*ENDDO FINISH 2.优化控制文件.!/OPT OPCLR FINISH !/CLEAR/INPUT,EXAMPLE27,LGW /OPT OPANL,EXAMPLE27,LGW OPVAR,A,DV,0.1,10,0.001 OPVAR,B,DV,0.1,10,0.001 OPVAR,C,DV,0.1,10,0.001 OPVAR,D,DV,0.
23、1,10,0.001 OPVAR,AX,DV,0.1,5,0.001 OPVAR,AY,DV,0.1,5,0.001 OPVAR,BATA_OPT,DV,0.1,PI,0.001 OPVAR,K,DV,0,10,0.001 OPVAR,GAMA,DV,0.1,PI,0.001 OPVAR,G2,SV,0,100 OPVAR,G3,SV,0,100 OPVAR,G4,SV,0,100 OPVAR,G5,SV,0,100 OPVAR,G6,SV,0,100 OPVAR,F2,OBJ,0.001 OPSAVE,EXAMPLE27,OPT OPTYPE,FIRST OPEXEC OPLIST,ALL
24、FINISH 3.求解方法.先分别以文件名 EXAMPLE27.LGW、EXAMPLE27_OPT.TXT 将优化分析文件和优化控制文件存储在 ANSYS 的工作文件夹里,再在 ANSYS 的输入窗口输入/INPUT,EXAMPLE27_OPT,TXT,回车,开始求解。.第 28 例 载荷工况组合实例简支梁 本例提示 介绍了载荷工况组合的应用场合和使用方法、步骤,并使用解析解对有限元分析结果进行了验证。/CLEAR/FILNAME,EXAMPLE28 /PREP7 ET,1,BEAM3 R,1,7.069e-4,3.976e-8,0.03 MP,EX,1,2E11 MP,NUXY,1,0.3 K,1,0,0,0 K,2,0.5,0,0 LSTR,1,2 HPTCREATE,LINE,1,RATIO,0.4 LESIZE,1,50 LMESH,1 FINISH /SOLU DK,1,UX DK,1,UY DK,2,UX DK,2,ROTZ FK,3,FY,-500 LSWRITE,1 DKDELE,2,ALL DK,2,UY LSWRITE,2 LSSOLVE,1,2,1.FINISH /POST1 LCDEF,1,1 LCDEF,2,2 LCASE,1 LCOPER,ADD,2 PLDISP FINISH