声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1565|回复: 5

[结构分析] 各位高手 解释 一个 二次 开发 的例题 谢谢

[复制链接]
发表于 2006-11-20 14:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
UPF
E. 使用ANSYS列表命令列出ANSYS某一结果文件的内容;编译并连接ANSYS二进制文件读写程序BINTST.F,读写二进制文件并与列表方式相比较。
1.        建立一个自己所熟悉的有限元模型,单元数3~5即可,加载、设置边界条件并求解
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:\ansys55\custom\misc\intel\bintst.f D:\user>copy c:\ansys55\custom\misc\intel\bintrd.f D:\user>copy c:\ansys55\custom\misc\intel\bintwr.f D:\user>copy c:\ansys55\custom\misc\intel\Custom.bat D:\user>copy c:\ansys55\custom\misc\intel\Makefile D:\user>copy c:\ansys55\custom\misc\intel\binlib.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:\ansys55\custom\user\intel\user01.F
D:\user>copy c:\ansys55\custom\user\intel\Anscust.bat
D:\user>copy c:\ansys55\custom\user\intel\Makefile
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语句中增加的字符是为了在ANSYS运行时表明user01.F确实是自己修改过的版本
将user01的值设成0,是为了使ANSYS给出正确信息,而不是警告
2.        修改Makefile
修改ansys55_dir的值使其指向ANSYS主目录
ansys55_dir=C:\ansys55
修改下面这一行
            siappst.lib     \

$(ansys55_dir)\custom\lib\intel\siappst.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:\ansys55\bin\intel
D:\otherdir>ansys55cust -custom d:\user\ansys.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
      function  user03 (intin,dpin,ch4in,ch8in)
#include "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
      double precision  dpin(12),xyz(3), xmean, ymean, zmean, stdxyz(3),
     x          sodx, sody, sodz
      character*4  ch4in(12)
      character*8  ch8in(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 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 value  *****
999  user03 = 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
      function  user01 (intin,dpin,ch4in,ch8in)
#include "impcom.inc"

      external  wrinqr
      integer   wrinqr

      integer  user01,intin(12), iott
      double precision  dpin(12)
      character*4  ch4in(12)
      character*8  ch8in(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
      end

E. 用户自定义材料
1.        拷贝相关文件
D:\user>copy c:\ansys55\custom\user\intel\userpl.F
2.        运行编译连接(参见用户命令)
3.        启动ANSYS(参见用户命令)
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.        启动ANSYS(参见用户命令)
D:\user>ansys55cust -custom .\ansys.exe -p ansysul
6.        输入a.dat,记录结果
/input,a,dat

E. 用户单元
1.        拷贝相关文件
D:\user>copy c:\ansys55\custom\user\intel\uec101.F
D:\user>copy c:\ansys55\custom\user\intel\uel101.F
2.        编辑uel101.F
将下面的程序段
c
      call TrackBegin ('uel101')
c
c --- define initial data
c     --- elmdat pointers defined in elparm
      mat = elmdat(PMAT)
修改为:
c
      call TrackBegin ('uel101')
      iott=wrinqr(2)
      write (iott, *) 'In user element',elem
c
c --- define initial data
c     --- elmdat pointers defined in elparm
      mat = elmdat(PMAT)
3.        运行编译连接(参见用户命令)
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.        启动ANSYS(参见用户命令)
D:\user>ansys55cust -custom .\ansys.exe -p ansysul
6.        输入a.dat,注意OUTPUT窗口中打印出来的信息,记录结果
/input,a,dat
7.        修改命令流文件a.dat,将单元类型换成LINK8,重新分析,并与LINK8对比
D:\user>edit a.dat
/PREP7  
et,1,LINK8
mp,ex,1,2e6

E. 使用/DEBUG命令调试ANSYS单元矩阵及载荷矢量
1.        在ANSYS中以自己最熟悉的单元建立一个有限元模型,然后加载荷、边界条件,设定求解参数,如Time, Deltime等
2.        在ANSYS Input Box框中输入以下命令
/DEBUG,-3,,,1
3.        求解,键入求解命令
SOLVE
4.        观察OUTPUT窗口的输出
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-11-20 14:41 | 显示全部楼层
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单元矩阵及载荷矢量
 楼主| 发表于 2006-11-20 18:21 | 显示全部楼层
不知道 是怎么回事啊
多谢了
发表于 2006-11-20 18:46 | 显示全部楼层
眼睛都花了
 楼主| 发表于 2006-11-21 10:20 | 显示全部楼层
2.        拷贝以下文件到用户工作目录
D:\user>copy c:\ansys55\custom\user\intel\user01.F
D:\user>copy c:\ansys55\custom\user\intel\Anscust.bat
D:\user>copy c:\ansys55\custom\user\intel\Makefile
主要是这个文件找不到
不知道为什么我的电脑上没有
发表于 2008-1-24 16:24 | 显示全部楼层

回复 5楼 的帖子

安装时选custom才有
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-23 18:32 , Processed in 0.056338 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表