資源描述:
《fortran調(diào)用ansys做桁架結(jié)構(gòu)優(yōu)化例子》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、fortran調(diào)用ansys做桁架結(jié)構(gòu)優(yōu)化例子ANSYS命令流部分:/clearB=1000????????????!基本尺寸!進入PREP7并建模/PREP7*dim,A,,3,1??!定義一個3*1的數(shù)組*VREAD,A,E:projecttrussdata_1,txt,,IJK,3,1??!IJK表示讀入的順序(F7.2)A1=A(1,1)A2=A(2,1)A3=A(3,1)*cfopen,E:projecttrussdata_3,txt*vwrite,A1,A2,A3(F7.2,/
2、F7.2,/F7.2)*cfclosET,1,LINK1??????????!二維桿單元R,1,A1????????????!以參數(shù)形式的實參R,2,A2R,3,A3MP,EX,1,2.1E6????????!楊氏模量N,1,-B,0,0??????????!定義結(jié)點N,2,0,0,0N,3,B,0,0N,4,0,-B,0E,1,4??????????????!定義單元REAL,2E,2,4REAL,3E,3,4FINISH!!進入求解器,定義載荷和求解/SOLUD,1,ALL,0,,3?????
3、???????!結(jié)點UX=UY=0F,4,FX,200000??????????!結(jié)點4上的X方向載荷分量(工況1)F,4,FY,-200000??????????!結(jié)點4上的Y方向載荷分量(工況2)SOLVEFINISH!進入POST1并讀出狀態(tài)變量數(shù)值/POST1SET,LASTETABLE,EVOL,VOLU??????!將每個單元的體積放入ETABLESSUM????????????????!將單元表格內(nèi)數(shù)據(jù)求和*GET,VTOT,SSUM,,ITEM,EVOL??!VTOT=總體積RHO
4、=2.85E-4WT=RHO*VTOT????????!計算總體積ETABLE,SIG,LS,1????????!將軸向應(yīng)力放入ETABLE*GET,SIG1,ELEM,1,ETAB,SIG??!SIG1=第一個單元的軸向應(yīng)力*GET,SIG2,ELEM,2,ETAB,SIG??!SIG2=第二個單元的軸向應(yīng)力SIG1=ABS(SIG1)????????!計算軸向應(yīng)力的絕對值SIG2=ABS(SIG2)!/ESHAPE,2??????????!以實體單元模式顯示殼單元!/VIEW,1,1,1,1?
5、?????????!軸測視圖!EPLOT???? ??????!畫單元FINISH*cfopen,E:projecttrussdata_2,txt*vwrite,SIG1,SIG2,WT(F7.2,/F7.2,/F7.2)*cfclosFORTRAN程序部分:PROGRAMTRUSSUSEDFLIBIMPLICITNONEcharacter(len=20)::filename1="trussdata_2.txt"character(len=20)::filename2="trussdata_1
6、.txt"REAL,parameter::e=0.01??!e為計算精度REAL,parameter::xu=400??!xu為許用應(yīng)力INTEGER::fileid,kINTEGERiLOGICAL(4)resultREALu1(50),u2(50),ww(50),umax??!u1,u2為應(yīng)力比,umax為最大應(yīng)力REALsig1,sig2,W,ap??!sig1為桿1的最大應(yīng)力,sig2為桿2的最大應(yīng)力REALx1(50),x2(50),xx1,xx2??!x為桿截面面積i=1k=1x1(1
7、)=707??!定義桿的初始值x2(1)=707ap=10DO??????WHILE(ap>=e)!調(diào)用ANSYS做結(jié)構(gòu)分析result=SYSTEMQQ('C:ProgramFilesAnsysIncv110ANSYSbinintelANSYS110-b-p&&ane3fl-iE:projecttruss.txt-oE:projecttrussanswer.txt')fileid=10open(fileid,file=filename1)??!從ansys寫出的文件中讀入數(shù)
8、據(jù)(應(yīng)力和求得的重量)read(fileid,*)sig1,sig2,Wclose(fileid)ww(k)=wu1(i)=sig1/xuu2(i)=sig2/xuif(u1(i)>=u2(i))then??!判斷最大應(yīng)力??????umax=u1(i)else??????umax=u2(i)endif!射線步x1(i+1)=umax*x1(i)x2(i+1)=umax*x2(i)u1(i+1)=u1(i)/umax??!求出新的應(yīng)力比u2(i+1)=u2(i)/umax!調(diào)整步x