ANSYS二次开发培训练习题.doc_第1页
ANSYS二次开发培训练习题.doc_第2页
ANSYS二次开发培训练习题.doc_第3页
ANSYS二次开发培训练习题.doc_第4页
ANSYS二次开发培训练习题.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

我从老板那里拿来的,好东西哦,给我加1分吧! ANSYS二次开发培训练习题 UIDL E.使用UIDL在ANSYS主菜单中增加一个菜单项,点击后可以出现一个子菜单或激活一个对话框。 APDL E. 使用APDL编制一个可以读写有限元模型的小程序,要求读出所有节点号和单元号,节点坐标以及单元节点列表。 E. 使用DNSOL,DESOL定义计算结果 UPF E. 使用ANSYS列表命令列出ANSYS某一结果文件的内容;编译并连接ANSYS二进制文件读写程序BINTST.F,读写二进制文件并与列表方式相比较。 E. 编译并连接ANSYS提供的示例程序USER01.F;在ANSYS命令行中使用/UCMD给用户命令赋新的名称,并运行。 E. 编译并连接ANSYS提供的示例程序USER03.F,使用动态数组保存有限元模型信息,如节点号、单元号、节点坐标、单元节点列表。使用UPF读写数据库子程序,读写模型中的有限元模型信息和载荷信息,并打印。 E. 使用ANSYS提供子程序试验矢量与矩阵的操作 E. 试验用户自定义材料 E. 试验用户单元 E. 使用/DEBUG命令调试ANSYS单元矩阵及载荷矢量 练习题答案: 说明: 1.  以下练习答案以ANSYS 5.5.1 UP199810001 Windows 95/98/NT的University Low版本(产品号为ansysul)为例,其它版本与此类似。 2.  假定机器中已经安装了Digital Visual Fortran 5.0C以上的版本 假设ANSYS安装目录为C:ANSYS55 3.  假设用户工作目录为D:user 4.  约定 DOS提示  D:user> DOS输入  copy c:ansys55docuUIFUNC2.GRN ANSYS输入框  ET,1,42 数据文件  :N Men_Training UIDL E. 使用UIDL在ANSYS主菜单中增加一个菜单项,点击后可以出现一个子菜单或激活一个对话框。 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.  在主菜单中加入自定义菜单项 D:user>edit UIMENU.GRN 在第4780应为 :A Main Menu 在第4803行插入以下几行: Menu_Training Sep_ 所得到的结果如下: Men_Aux12 Men_RunStat K_LN(BETA) Sep_ K_LN(BETA) Fnc_UNDO Sep_ Men_Training Sep_ Fnc_FINISH 将光标移至第4812行,插入以下一段 :! :N Men_Training :S 413, 76, 330 :T Menu :A Training Menu ANSYS Training MENU Fnc_Training :E END :! 删除该行 :X INDEX ADDED BY ANSYS 以后的全部行 存盘退出 3.  编辑新的菜单文件 D:user>edit newmenu.grn 键入以下文字 :F UIMENU.GRN 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 TrainingTraining 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   rm_/TITLE Welcome to ANSYS Training   Typ_Char,72,72    rm_/TITLE Welcome to ANSYS TrainingCmd_)/Go :E END :! 存盘退出 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.  启动ANSYS的launcher 在Working Directory框中键入 d:user 按OK键,启动ANSYS界面 APDL E. 使用APDL编制一个可以读写有限元模型的小程序,要求读出所有节点号和单元号,节点坐标以及单元节点列表。 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.  启动ANSYS,根据自己所熟悉的领域,建立一个有限元模型 3.  输入文件a.dat /input,a,dat 4.  检查 分别列出节点数,节点号列表,坐标,单元数,单元号列表,单元节点列表,与nlist,elist等对比。 *status,nnod *status,nodes *status,xy *status,nelm *status,elems *status,ndlst E. 使用DNSOL,DESOL定义计算结果 1 利用前面所建立或新建一个有限元模型 2 进入Post-processor /post26 或 Main Menu->General Postproc 3定义节点上的结果 手工定义 ->Nodal Results按对话框提示输入各点的结果数据 程序自动定义 /PREP7 BLC4,0,0,4,2 et,1,42esize,.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某一结果文件的内容;编译并连接ANSYS二进制文件读写程序BINTST.F,读写二进制文件并与列表方式相比较。 1.  建立一个自己所熟悉的有限元模型,单元数35即可,加载、设置边界条件并求解 6.  使用ANSYS列表命令 Utility Menu->File->List->Binary File 7.  在弹出的对话框中 DUMP Records to be list中选ALL Records FORM Amt of output per record中选Entire Records FILEAUX2 binary file to list中选择要显示的.rst文件 按OK键确认后,可以得到.rst文件的列表窗口 使用列表窗口的菜单保存列表窗口中的输出结果到文件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.  运行Custom.bat,编译并连接 D:user>custom 在工作目录中可生成一个运行程序bintst.exe 10.  运行bintst.exe D:user>bintst > out.txt 将bintst的运行结果转存到文件out.txt中 比较out.txt 与list.txt文件中的结果,并参考手册Guide to interfacing to ANSYS中Format of Binary Data Files的Format of the Results File分析文件结构。 E. 用户命令:编译并连接ANSYS提供的示例程序USER01.F;在ANSYS命令行中使用/UCMD给用户命令赋新的名称,并运行。 1.  清理用户工作目录下的文件 如果在用户工作目录下存在ANSYS二进制文件读取等程序,请全部删除 2.  拷贝以下文件到用户工作目录 D:user>copy c:ansys55customuserinteluser01.F D:user>copy c:ansys55customuserintelAnscust.bat D:user>copy c:ansys55customuserintelMakefile 1.  修改user01.F 修改以下几行 c c *userS 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 *userS 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语句中增加的字符是为了在ANSYS运行时表明user01.F确实是自己修改过的版本 将user01的值设成0,是为了使ANSYS给出正确信息,而不是警告 2.  修改Makefile 修改ansys55_dir的值使其指向ANSYS主目录 ansys55_dir=C:ansys55 修改下面这一行             siappst.lib 为 $(ansys55_dir)customlibintelsiappst.lib 3.  运行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 当出现goto end时表明编译、连接完成,这时应该在用户工作目录下出现一个可执行程序ansys.exe,约为34MB 4.  运行编译连接生成的ANSYS 在用户工作目录下 D:user>ansys -p ansysul 或 D:user>ansys55cust -custom .ansys.exe -p ansysul 如果在其它目录下运行 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.  执行用户命令 执行用户命令可以在字符界面下,也可在图形界面下 在出现 BEGIN: 提示信息后,键入以下命令 usr1 或者输入以下命令进行到图形用户界面 /show,win32 /menu,on 在工作站上的用户可以选择 /show,x11 /show,x11c /show,3D 详细说明可以参见ANSYS命令手册中关于/show的说明 在输入框中,键入命令 usr1 6.  用/UCMD命令自定义用户命令名 在ANSYS BEGIN提示信息后 /UCMD,aaa,1 aaa E. 编译并连接ANSYS提供的示例程序USER03.F,使用动态数组保存有限元模型信息,如节点号、单元号、节点坐标、单元节点列表。使用UPF读写数据库子程序,读写模型中的有限元模型信息和载荷信息,并打印。 以下是一个完整的程序,可由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       functionuser03 (intin,dpin,ch4in,ch8in) #include impcom.inc       externalwrinqr,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       double precisiondpin(12),xyz(3), xmean, ymean, zmean, stdxyz(3),      x sodx, sody, sodz       character*4ch4in(12)       character*8ch8in(12) #include ansysdef.inc #include 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_DOUBLE,hXcptr)       ycptr = HeapAllocPtr(numnp,YCoords ,HEAP_DOUBLE,hYcptr)       zcptr = HeapAllocPtr(numnp,ZCoords ,HEAP_DOUBLE,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 nodes xyz coordinates           dstack(xcptr + i) = xyz(1)           dstack(ycptr + i) = xyz(2)           dstack(zcptr + i) = xyz(3)           istack(ndptr + i) = node c while were 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 value* 999user03 = 0       return       end       subroutine wrdisp (nnod, nodes) #include impcom.inc #include ansysdef.inc       integer nnod, nodes(nnod)          external wrinqr, disget       integer wrinqr, disget          integer iott,i,rc,k       double precision value(4)          iott = wrinqr(WR_OUTPUT)       do i=1,nnod          rc = disget(nodes(i), 1, value(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), (value(k), k=1,4) 1010   format (Nodes=,i3, UX=,4(F8.2,)          endif       enddo          return       end 将上面程序编译并连接, 启动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提供子程序试验矢量与矩阵的操作    以下是一个完整的程序用来说明矢量矩阵操作c=a *deck,user01 user parallel ANSYS,INC       functionuser01 (intin,dpin,ch4in,ch8in) #include impcom.inc       externalwrinqr       integer wrinqr       integeruser01,intin(12), iott       double precisiondpin(12)       character*4ch4in(12)       character*8ch8in(12) c       double 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       

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论