UIDL
E.使用UIDL在ANSYS主菜單中增加一個(gè)菜單項(xiàng),點(diǎn)擊后可以出現(xiàn)一個(gè)子菜單或激活一個(gè)對(duì)話框。
APDL
E. 使用APDL編制一個(gè)可以讀寫(xiě)有限元模型的小程序,要求讀出所有節(jié)點(diǎn)號(hào)和單元號(hào),節(jié)點(diǎn)坐標(biāo)以及單元節(jié)點(diǎn)列表。
E. 使用DNSOL,DESOL定義計(jì)算結(jié)果
UPF
E. 使用ANSYS列表命令列出ANSYS某一結(jié)果文件的內(nèi)容;編譯并連接ANSYS二進(jìn)制文件讀寫(xiě)程序BINTST.F,讀寫(xiě)二進(jìn)制文件并與列表方式相比較。
E. 編譯并連接ANSYS提供的示例程序USER01.F;在ANSYS命令行中使用/ MD給用戶命令賦新的名稱,并運(yùn)行。
E. 編譯并連接ANSYS提供的示例程序USER03.F,使用動(dòng)態(tài)數(shù)組保存有限元模型信息,如節(jié)點(diǎn)號(hào)、單元號(hào)、節(jié)點(diǎn)坐標(biāo)、單元節(jié)點(diǎn)列表。使用UPF讀寫(xiě)數(shù)據(jù)庫(kù)子程序,讀寫(xiě)模型中的有限元模型信息和載荷信息,并打印。
E. 使用ANSYS提供子程序試驗(yàn)矢量與矩陣的操作
E. 試驗(yàn)用戶自定義材料
E. 試驗(yàn)用戶單元
E. 使用/DEBUG命令調(diào)試ANSYS單元矩陣及載荷矢量
練習(xí)題答案:
說(shuō)明:
1. 以下練習(xí)答案以ANSYS 5.5.1 UP199810001 Windows 95/98/NT的University Low版本(產(chǎn)品號(hào)為ansysul)為例,其它版本與此類(lèi)似。
2. 假定機(jī)器中已經(jīng)安裝了Digital Vis l Fortran 5.0C以上的版本 假設(shè)ANSYS安裝目錄為C:ANSYS55
3. 假設(shè)用戶工作目錄為D:user
4. 約定
DOS提示 D:user>
DOS輸入 copy c:ansys55docuUIFUNC2.GRN
ANSYS輸入框 ET,1,42
數(shù)據(jù)文件 :N Men_Training
UIDL E. 使用UIDL在ANSYS主菜單中增加一個(gè)菜單項(xiàng),點(diǎn)擊后可以出現(xiàn)一個(gè)子菜單或激活一個(gè)對(duì)話框。 A.
1. 拷貝文件
D:user>copy c:ansys55documenulist55.ans
D:user>copy c:ansys55docuUIMENU.GRN
D:user>copy c:ansys55docuUIFUNC1.GRN
D:user>copy c:ansys55docuUIFUNC2.GRN
2. 在主菜單中加入自定義菜單項(xiàng)
D:user>edit UIMENU.GRN
在第4780應(yīng)為
:A Main Menu
在第4803行插入以下幾行:
Men_Training
Sep_
所得到的結(jié)果如下:
Men_Aux12
Men_RunStat
K_LN(BETA)
Sep_
K_LN(BETA)
Fnc_UNDO
Sep_
Men_Training
Sep_
Fnc_FINISH
將光標(biāo)移至第4812行,插入以下一段
:!
:N Men_Training
:S 413, 76, 330
:T Menu
:A Training Menu
:D ANSYS Training MENU
Fnc_Training
:E END
:!
刪除該行
:X INDEX ADDED BY ANSYS
以后的全部行
存盤(pán)退出
3. 編輯新的菜單文件
D:user>edit newmenu.grn
鍵入以下文字
:F UIMENU.GRN
:D Modified on 98/10/01, Revision (SID) = 5.181.1.68 - For use with ANSYS 5.5
:I 1, 759, 809
:!
:N Fnc_Training
:S 627, 449, 170
:T Command
:A ANSYS Customizing Training
:D Training Exercises
:C )*GET,_z1,ACTIVE,,TITLE,,START,1
:C )*GET,_z2,ACTIVE,,TITLE,,START,9
:C )*GET,_z3,ACTIVE,,TITLE,,START,17
:C )*GET,_z4,ACTIVE,,TITLE,,START,25
:C )*GET,_z5,ACTIVE,,TITLE,,START,33
:C )*GET,_z6,ACTIVE,,TITLE,,START,41
:C )*GET,_z7,ACTIVE,,TITLE,,START,49
:C )*GET,_z8,ACTIVE,,TITLE,,START,57
:C )*GET,_z9,ACTIVE,,TITLE,,START,65
Fmt_H
Inp_NoApply
Cmd_)/NOPR
Cmd_)/TITLE
Fld_2
Prm_[/TITLE] Welcome to ANSYS Training
Typ_Char,72,72
Prm_[/TITLE] Welcome to ANSYS Training
Cmd_)/Go
:E END
:!
存盤(pán)退出
4. 修改menulist55.ans文件
D:user>edit menulist55.ans
修改文件的前三行,使其指向用戶工作目錄下的文件
d:userUIMENU.GRN
d:userUIFUNC1.GRN
d:userUIFUNC2.GRN
d:usernewmenu.grn
c:ansys55DOCUUICMDS.HLP
c:ansys55DOCUUIELEM.HLP
c:ansys55DOCUUIGUID.HLP
c:ansys55DOCUUITHRY.HLP
c:ansys55DOCUUIOTHR.HLP
5. 啟動(dòng)ANSYS的launcher
在Working Directory框中鍵入
d:user
按OK鍵,啟動(dòng)ANSYS界面
APDL E. 使用APDL編制一個(gè)可以讀寫(xiě)有限元模型的小程序,要求讀出所有節(jié)點(diǎn)號(hào)和單元號(hào),節(jié)點(diǎn)坐標(biāo)以及單元節(jié)點(diǎn)列表。
A.
1. 編輯文件a.dat
D:user>edit a.dat
*Get,nnod,NODE,0,COUNT
*Dim,xy,array,nnod,2
*Dim,nodes,array,nnod
*Get,nd,NODE,0,NUM,MIN
*Do,I,1,nnod,1
nodes(I)= nd
xy(I,1) = Nx(nd)
xy(I,2) = Ny(nd)
nd = Ndnext(nd)
*Enddo
*Get,nelm,ELEM,0,COUNT
*Dim,elems,array,nelm
*Dim,ndlst,array,nelm,4
*Get,el,ELEM,0,NUM,MIN
*Do,I,1,nelm,1
elems(I)= el
*Do,J,1,4
ndlst(I,J) = Nelem(el,J)
*Enddo
el = Elnext(nd)
*Enddo
2. 啟動(dòng)ANSYS,根據(jù)自己所熟悉的領(lǐng)域,建立一個(gè)有限元模型
3. 輸入文件a.dat
/input,a,dat
4. 檢查
分別列出節(jié)點(diǎn)數(shù),節(jié)點(diǎn)號(hào)列表,坐標(biāo),單元數(shù),單元號(hào)列表,單元節(jié)點(diǎn)列表,與nlist,elist等對(duì)比。
*status,nnod
*status,nodes
*status,xy
*status,nelm
*status,elems
*status,ndlst
E. 使用DNSOL,DESOL定義計(jì)算結(jié)果
1. 利用前面所建立或新建一個(gè)有限元模型
2. 進(jìn)入Post-processor
/post26
或
Main Menu->General Postproc
3.定義節(jié)點(diǎn)上的結(jié)果 手工定義 ->Nodal Results按對(duì)話框提示輸入各點(diǎn)的結(jié)果數(shù)據(jù) 程序自動(dòng)定義
/PREP7 BLC4,0,0,4,2 et,1,42 esize,.5 amesh,1
/POST1 dof,temp *Get,nnod,NODE,0,COUNT
*Dim,xy,array,nnod,2 *Dim,nodes,array,nnod *Get,nd,NODE,0,NUM,MIN
*Do,I,1,nnod,1 nodes(I)= nd xy(I,1) = Nx(nd) xy(I,2) = Ny(nd) nd = Ndnext(nd) *Enddo
*Do,i,1,nnod,1
dist = sqrt((xy(i,1)-2)*(xy(i,1)-2)+(xy(i,2)-1)*(xy(i,2)-1)) tmp = dist*100 Dnsol,nodes(i),temp,,tmp *Enddo
nsel,all plnsol,temp
UPF
E. 使用ANSYS列表命令列出ANSYS某一結(jié)果文件的內(nèi)容;編譯并連接ANSYS二進(jìn)制文件讀寫(xiě)程序BINTST.F,讀寫(xiě)二進(jìn)制文件并與列表方式相比較。
1. 建立一個(gè)自己所熟悉的有限元模型,單元數(shù)3~5即可,加載、設(shè)置邊界條件并求解
6. 使用ANSYS列表命令
Utility Menu->File->List->Binary File
7. 在彈出的對(duì)話框中
[DUMP] Records to be list中選ALL Records
[FORM] Amt of output per record中選Entire Records
[FILEAUX2] binary file to list中選擇要顯示的.rst文件
按OK鍵確認(rèn)后,可以得到.rst文件的列表窗口
使用列表窗口的菜單保存列表窗口中的輸出結(jié)果到文件list.txt
File->Save As
8. 拷貝以下文件到工作目錄
D:user>copy c:ansys55custommiscintelbintst.f D:user>copy c:ansys55custommiscintelbintrd.f D:user>copy c:ansys55custommiscintelbintwr.f D:user>copy c:ansys55custommiscintelCustom.bat D:user>copy c:ansys55custommiscintelMakefile D:user>copy c:ansys55custommiscintelbinlib.a
9. 運(yùn)行Custom.bat,編譯并連接
D:user>custom
在工作目錄中可生成一個(gè)運(yùn)行程序bintst.exe
10. 運(yùn)行bintst.exe
D:user>bintst > out.txt
將bintst的運(yùn)行結(jié)果轉(zhuǎn)存到文件out.txt中
比較out.txt 與list.txt文件中的結(jié)果,并參考手冊(cè)Guide to interfacing to ANSYS中Format of Binary Data Files的Format of the Results File分析文件結(jié)構(gòu)。
E. 用戶命令:編譯并連接ANSYS提供的示例程序USER01.F;在ANSYS命令行中使用/ MD給用戶命令賦新的名稱,并運(yùn)行。
1. 清理用戶工作目錄下的文件
如果在用戶工作目錄下存在ANSYS二進(jìn)制文件讀取等程序,請(qǐng)全部刪除
2. 拷貝以下文件到用戶工作目錄
D:user>copy c:ansys55customuserinteluser01.F
D:user>copy c:ansys55customuserintelAnscust.bat
D:user>copy c:ansys55customuserintelMakefile
1. 修改user01.F
修改以下幾行
c
c ***** user'S CODE IS INSERTED HERE *****
write (iott,2000)
2000 format (//' ***** CALL TO ANSYS,INC DUMMY USER01 *****'//)
c
c ***** do not return this result code in a real user routine
user01 = -654321
c ***** instead return a zero *****
c user01 = 0
c
為
c
c ***** user'S CODE IS INSERTED HERE ***** write (iott,2000) 2000 format (//' wby*** CALL TO ANSYS,INC DUMMY USER01 *****'//) c c ***** do not return this result code in a real user
c user01 = -654321 c ***** instead return a zero ***** user01 = 0 c
在format語(yǔ)句中增加的字符是為了在ANSYS運(yùn)行時(shí)表明user01.F確實(shí)是自己修改過(guò)的版本
將user01的值設(shè)成0,是為了使ANSYS給出正確信息,而不是警告
2. 修改Makefile
修改ansys55_dir的值使其指向ANSYS主目錄
ansys55_dir=C:ansys55
修改下面這一行
siappst.lib
為
$(ansys55_dir)customlibintelsiappst.lib
3. 運(yùn)行ANSCUST.BAT編譯并連接
忽略掉如下WARNING提示信息
LINK : warning LNK4049: locally defined symbol "_free" imported
LINK : warning LNK4049: locally defined symbol "_malloc" imported
LINK : warning LNK4049: locally defined symbol "_fflush" imported
LINK : warning LNK4049: locally defined symbol "_fread" imported
LINK : warning LNK4049: locally defined symbol "_fwrite" imported
LINK : warning LNK4049: locally defined symbol "_ftell" imported
LINK : warning LNK4049: locally defined symbol "_fseek" imported
當(dāng)出現(xiàn)goto end時(shí)表明編譯、連接完成,這時(shí)應(yīng)該在用戶工作目錄下出現(xiàn)一個(gè)可執(zhí)行程序ansys.exe,約為34MB
4. 運(yùn)行編譯連接生成的ANSYS
在用戶工作目錄下
D:user>ansys -p ansysul
或
D:user>ansys55cust -custom .ansys.exe -p ansysul
如果在其它目錄下運(yùn)行
D:otherdir>set path=c:ansys55binintel
D:otherdir>ansys55cust -custom d:useransys.exe -p ansysul
或
D:otherdir>set path=d:user
D:otherdir>ansys -p ansysul
5. 執(zhí)行用戶命令
執(zhí)行用戶命令可以在字符界面下,也可在圖形界面下
在出現(xiàn)
BEGIN:
提示信息后,鍵入以下命令
usr1
或者輸入以下命令進(jìn)行到圖形用戶界面
/show,win32
/menu,on
在工作站上的用戶可以選擇
/show,x11
/show,x11c
/show,3D 詳細(xì)說(shuō)明可以參見(jiàn)ANSYS命令手冊(cè)中關(guān)于/show的說(shuō)明
在輸入框中,鍵入命令
usr1
6. 用/ MD命令自定義用戶命令名
在ANSYS BEGIN提示信息后
/ MD,aaa,1
aaa
E. 編譯并連接ANSYS提供的示例程序USER03.F,使用動(dòng)態(tài)數(shù)組保存有限元模型信息,如節(jié)點(diǎn)號(hào)、單元號(hào)、節(jié)點(diǎn)坐標(biāo)、單元節(jié)點(diǎn)列表。使用UPF讀寫(xiě)數(shù)據(jù)庫(kù)子程序,讀寫(xiě)模型中的有限元模型信息和載荷信息,并打印。
以下是一個(gè)完整的程序,可由user03.F修改得到
*deck,user03 user ANSYS,INC
c sid 5.1 copy of file s.user03.F last changed by jtm on 98/03/09
function user03 (intin,dpin,ch4in,ch8in)
#incl? "impcom.inc"
external wrinqr,ndinqr,ndgxyz,ndnext,HeapAllocPtr,
x HeapDealloc,erhandler
integer wrinqr,ndinqr,ndgxyz,ndnext,HeapAllocPtr
integer user03, intin(12), iott, i, ksel, xcptr, hXcptr, ycptr,
x hYcptr, zcptr, hZcptr, ndptr, hNdptr, numnp, node
do le precision dpin(12),xyz(3), xmean, ymean, zmean, stdxyz(3),
x sodx, sody, sodz
character*4 ch4in(12)
character*8 ch8in(12)
#incl? "ansysdef.inc"
#incl? "stack.inc"
c
c Get nodal xyz locations and calculate standard deviation of
c x coordinates, y coordinates, & z coordinates
c
c get number of currently selected nodes
numnp = ndinqr (0,DB_NUMSELECTED)
if (numnp .le. 0) go to 999
c allocate memory for x, y, & z coordinates of nodes
xcptr = HeapAllocPtr(numnp,'XCoords ',HEAP_DO LE,hXcptr)
ycptr = HeapAllocPtr(numnp,'YCoords ',HEAP_DO LE,hYcptr)
zcptr = HeapAllocPtr(numnp,'ZCoords ',HEAP_DO LE,hZcptr)
ndptr = HEapAllocPtr(numnp,'Nodes ',HEAP_INTEGER,hNdptr)
c loop through all selected nodes
i=1
node = 0
xmean = 0.0d0
ymean = 0.0d0
zmean = 0.0d0
10 node = ndnext(node)
if (node .gt. 0) then
c get xyz coordinates
ksel = ndgxyz (node,xyz(1))
c store this node's xyz coordinates
dstack(xcptr + i) = xyz(1)
dstack(ycptr + i) = xyz(2)
dstack(zcptr + i) = xyz(3)
istack(ndptr + i) = node
c while we're looping, accumulate sums to calculate means
xmean = xmean + xyz(1)
ymean = ymean + xyz(2)
zmean = zmean + xyz(3)
c increment index
i = i + 1
c loop back up for next selected node
goto 10
endif
call wrdisp (numnp, istack(ndptr+1))
c node = 0, at the end of node list
c calculate mean of xyz coordinates
xmean = xmean / numnp
ymean = ymean / numnp
zmean = zmean / numnp
c calculate standard deviation for xyz coordinates
sodx = 0
sody = 0
sodz = 0
do i=1, numnp
sodx = sodx + (dstack(xcptr+i) - xmean)**2
sody = sody + (dstack(ycptr+i) - ymean)**2
sodz = sodz + (dstack(zcptr+i) - zmean)**2
enddo
stdxyz(1) = sqrt(sodx / (numnp-1))
stdxyz(2) = sqrt(sody / (numnp-1))
stdxyz(3) = sqrt(sodz / (numnp-1))
c ***** write to output file *****
iott = wrinqr(WR_OUTPUT)
write (iott,2000) stdxyz(1),stdxyz(2),stdxyz(3)
2000 format (/' STD FOR X COORDINATES:',G12.5,/,
X ' STD FOR Y COORDINATES:',G12.5,/,
X ' STD FOR Z COORDINATES:',G12.5)
c ***** write to GUI window *****
call erhandler ('user03',5000,2,
x 'STD FOR X COORDINATES: %G %/ STD FOR Y
x COORDINATES: %G %/ STD FOR Z COORDINATES: %G',stdxyz(1),' ')
c release dynamically allocated memory
call HeapDealloc(hXcptr)
call HeapDealloc(hYcptr)
call HeapDealloc(hZcptr)
call HeapDealloc(hNdptr)
c ***** required return val *****
999 user03 = 0
return
end
s routine wrdisp (nnod, nodes)
#incl? "impcom.inc"
#incl? "ansysdef.inc"
integer nnod, nodes(nnod)
external wrinqr, disget
integer wrinqr, disget
integer iott,i,rc,k
do le precision val(4)
iott = wrinqr(WR_OUTPUT)
do i=1,nnod
rc = disget(nodes(i), 1, val(1))
if (rc .eq. 0) then
write (iott,1000) nodes(i)
1000 format ('Nodes=',i3,' No x displacement constraint')
else
write (iott,1010) nodes(i), (val(k), k=1,4)
1010 format ('Nodes=',i3,' UX=',4(F8.2,','))
endif
enddo
return
end
將上面程序編譯并連接,
啟動(dòng)ANSYS,并輸入下面的命令流,觀察OUTPUT窗口的輸出信息
/prep7
blc4,0,0,4,2
et,1,42
esize,.5
amesh,1
nsel,s,loc,x,4
d,all,ux,8
nsel,s,loc,x,0
d,all,ux,-9
nsel,all
usr3
E. 使用ANSYS提供子程序試驗(yàn)矢量與矩陣的操作
以下是一個(gè)完整的程序用來(lái)說(shuō)明矢量矩陣操作{c}={a}
*deck,user01 user parallel ANSYS,INC
function user01 (intin,dpin,ch4in,ch8in)
#incl? "impcom.inc"
external wrinqr
integer wrinqr
integer user01,intin(12), iott
do le precision dpin(12)
character*4 ch4in(12)
character*8 ch8in(12)
c
do le precision a(3), b(4,3), c(4)
integer i,j,k
data a /5,6,7/
data b /3,3,9,8, 4,7,4,3, 5,9,5,2/
iott = wrinqr(2)
call vzero (c(1), 4)
write (iott, *) '*** matrix b ='
do i=1,4
write (iott, 101) (b(i,k), k=1,3)
enddo
write (iott, *) '*** vector a='
do i=1,3
write (iott, 100) a(i)
enddo
call maxv(b(1,1),a(1),c(1), 4,3)
write (iott, *) '*** vector c='
do i=1,4
write (iott, 100) c(i)
enddo
100 format (F9.2, 3x)
101 format (3(F9.2, 3x))
user01 = 0
c
return
end
E. 用戶自定義材料
1. 拷貝相關(guān)文件
D:user>copy c:ansys55customuserinteluserpl.F
2. 運(yùn)行編譯連接(參見(jiàn)用戶命令)
3. 啟動(dòng)ANSYS(參見(jiàn)用戶命令)
D:user>ansys55cust -custom .ansys.exe -p ansysul
4. 編輯命令流文件a.dat
D:user>edit a.dat
/PREP7
et,1,42
mp,ex,1,2e6
mp,nuxy,1,.3
r,1,100,0
tb,user,1
tbdata,1,100,2e3
blc4,0,0,4,2
esize,.5
type,1
mat,1
real,1
amesh,1
nsel,s,loc,x,0
d,all,all,0
nsel,s,loc,x,4
nsel,r,loc,y,0
f,all,fy,-1000
nsel,all
/solu
antype,static
time,1
solve
5. 啟動(dòng)ANSYS(參見(jiàn)用戶命令)
D:user>ansys55cust -custom .ansys.exe -p ansysul
6. 輸入a.dat,記錄結(jié)果
/input,a,dat
E. 用戶單元
1. 拷貝相關(guān)文件
D:user>copy c:ansys55customuserintelc101.F
D:user>copy c:ansys55customuserintell101.F
2. 編輯l101.F
將下面的程序段
c
call TrackBegin ('l101')
c
c --- define initial data
c --- elmdat pointers defined in elparm
mat = elmdat(PMAT)
修改為:
c
call TrackBegin ('l101')
iott=wrinqr(2)
write (iott, *) 'In user element',elem
c
c --- define initial data
c --- elmdat pointers defined in elparm
mat = elmdat(PMAT)
3. 運(yùn)行編譯連接(參見(jiàn)用戶命令)
4. 編輯命令流文件a.dat
D:user>edit a.dat
/PREP7
et,1,USER101
mp,ex,1,2e6
mp,nuxy,1,.3
r,1,100,0
k
k,,100,0
l,1,2
esize,10
type,1
mat,1
real,1
lmesh,1
nsel,s,loc,x,0
d,all,all,0
nsel,s,loc,x,100
f,all,fx,1000
nsel,all
/solu
antype,static
time,1
solve
5. 啟動(dòng)ANSYS(參見(jiàn)用戶命令)
D:user>ansys55cust -custom .ansys.exe -p ansysul
6. 輸入a.dat,注意OUTPUT窗口中打印出來(lái)的信息,記錄結(jié)果
/input,a,dat
7. 修改命令流文件a.dat,將單元類(lèi)型換成LINK8,重新分析,并與LINK8對(duì)比
D:user>edit a.dat
/PREP7
et,1,LINK8
mp,ex,1,2e6
E. 使用/DEBUG命令調(diào)試ANSYS單元矩陣及載荷矢量
1. 在ANSYS中以自己最熟悉的單元建立一個(gè)有限元模型,然后加載荷、邊界條件,設(shè)定求解參數(shù),如Time, Deltime等
2. 在ANSYS Input Box框中輸入以下命令
/DEBUG,-3,,,1
3. 求解,鍵入求解命令
SOLVE
4. 觀察OUTPUT窗口的輸出
相關(guān)文章
- 2021-08-30從零開(kāi)始AutoCAD 2014中文版機(jī)械制圖基礎(chǔ)培訓(xùn)教程 [李
- 2021-08-30從零開(kāi)始AutoCAD 2014中文版建筑制圖基礎(chǔ)培訓(xùn)教程 [朱
- 2021-08-23精通AutoCAD三維設(shè)計(jì)與開(kāi)發(fā)PDF下載
- 2021-08-22AutoCAD 2013應(yīng)用與開(kāi)發(fā)系列中文版AutoCAD 2013室內(nèi)裝
- 2021-08-22AutoCAD 2013應(yīng)用與開(kāi)發(fā)系列中文版AutoCAD 2013機(jī)械圖
- 2021-08-19數(shù)字化成圖-最新AutoCAD地形圖測(cè)繪高級(jí)開(kāi)發(fā)PDF下載
- 2021-08-14新編AutoCAD 2004中文版計(jì)算機(jī)輔助設(shè)計(jì)應(yīng)用技能培訓(xùn)教
- 2021-08-11中文版 AutoCAD Mechanical 2005 機(jī)械制圖基礎(chǔ)教程PDF
- 2021-08-10中文版AutoCAD 2012機(jī)械制圖培訓(xùn)教程 [導(dǎo)向工作室 編
- 2021-08-04中文版AutoCAD2010快捷命令一冊(cè)通 [康士廷 劉昌麗 王