ansys实体模型中查看任意点应力的方法

两年前在做论文的时候,涉及到查看实体模型中任意点应力的问题,当时我用“路径”这么一个比较讨巧的做法。但后来,marain老师分享给我一段很经典的apdl宏文件,直接按照提示输入坐标值就可以在cmd窗口中看到改点的应力值了。

后来,在一个国外论坛中,我又见到了这段代码,看来是公认的终极解决方案啊。下面就是这段代码的全文了,你可以将其复制粘贴到记事本里,另存为mac文件,再运行即可。

另外强调一下,这真不是我写的,以往有类似分享的时候闹出了不少误会,令我情何以堪啊。

 

/nopr
!
!  sxyz.mac  a macro which calculates stresses at a
!              given point in space
!
!  usage:  sxyz,X,Y,Z,avg
!
!    where:  X= x coordinate
!            Y= y coordinate
!            Z= z coordinate
!            avg=0 for averaged result, 1 for unaveraged result
!
!  written by: John Crawford  date: 3-5-98
!
!  make sure we are in /post1
*get,ar20,active,,rout
*if,ar20,eq,31,then
!
!  turn off annoying warning messages
/uis,msgpop,3
/nerr,0
!
!  set up the vector _str to hold the data after the
!  macro is done running
_str=
*dim,_str,array,11
!
!  delete any existing path with the same name
padele,path1
!  set up the path
path,path1,2,,
!
!  define two path points
ppath,1,,arg1-.00001,arg2-.00001,arg3
ppath,2,,arg1,arg2,arg3
!
!  get sx
!
!  define the result on the path for sx
*if,arg4,eq,0,then
pdef,sx,s,x,avg
ar32=_status
*else
pdef,sx,s,x,noav
ar32=_status
*endif
!  check to see if the coordinate is in the model space
!  ar32 will be zero if it is, and 2 if it isn't
*if,ar32,eq,0,then
!  get the result from the last point on the path
*get,ar21,path,,max,sx
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(1)=ar21
!
!  get sy
!
!  define the result on the path for sy
*if,arg4,eq,0,then
pdef,sy,s,y,avg
*else
pdef,sy,s,y,noav
*endif
!  get the result from the last point on the path
*get,ar22,path,,max,sy
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(2)=ar22
!
!  get sz
!
!  define the result on the path for sz
*if,arg4,eq,0,then
pdef,sz,s,z,avg
*else
pdef,sz,s,z,noav
*endif
!  get the result from the last point on the path
*get,ar23,path,,max,sz
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(3)=ar23
!
!  get sxy
!
!  define the result on the path for sxy
*if,arg4,eq,0,then
pdef,sxy,s,xy,avg
*else
pdef,sxy,s,xy,noav
*endif
!  get the result from the last point on the path
*get,ar24,path,,max,sxy
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(4)=ar24
!
!  get syz
!
!  define the result on the path for syz
*if,arg4,eq,0,then
pdef,syz,s,yz,avg
*else
pdef,syz,s,yz,noav
*endif
!  get the result from the last point on the path
*get,ar25,path,,max,syz
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(5)=ar25
!
!  get sxz
!
!  define the result on the path for sz
*if,arg4,eq,0,then
pdef,sxz,s,xz,avg
*else
pdef,sxz,s,xz,noav
*endif
!  get the result from the last point on the path
*get,ar26,path,,max,sxz
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(6)=ar26
!
!  get s1
!
!  define the result on the path for s1
*if,arg4,eq,0,then
pdef,s1,s,1,avg
*else
pdef,s1,s,1,noav
*endif
!  get the result from the last point on the path
*get,ar27,path,,max,s1
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(7)=ar27
!
!  get s2
!
!  define the result on the path for s2
*if,arg4,eq,0,then
pdef,s2,s,2,avg
*else
pdef,s2,s,2,noav
*endif
!  get the result from the last point on the path
*get,ar28,path,,max,s2
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(8)=ar28
!
!  get s3
!
!  define the result on the path for s3
*if,arg4,eq,0,then
pdef,s3,s,3,avg
*else
pdef,s3,s,3,noav
*endif
!  get the result from the last point on the path
*get,ar29,path,,max,s3
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(9)=ar29
!
!  get sint
!
!  define the result on the path for sint
*if,arg4,eq,0,then
pdef,sint,s,int,avg
*else
pdef,sint,s,int,noav
*endif
!  get the result from the last point on the path
*get,ar30,path,,max,sint
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(10)=ar30
!
!  get seqv
!
!  define the result on the path for seqv
*if,arg4,eq,0,then
pdef,seqv,s,eqv,avg
*else
pdef,seqv,s,eqv,noav
*endif
!  get the result from the last point on the path
*get,ar31,path,,max,seqv
!  multiply by the scale factor and then put the
!  value into the result vector _str
_str(11)=ar31
!
!  print the result
*if,arg4,eq,0,then
*msg,info,arg1,arg2,arg3
%/ Averaged Stress Results at X= %g, Y= %g, Z= %g
*else
*msg,info,arg1,arg2,arg3
%/ Unaveraged Stress Results at X= %g, Y= %g, Z= %g
*endif
!
*msg,info,ar21
SX = %g
*msg,info,ar22
SY = %g
*msg,info,ar23
SZ = %g
*msg,info,ar24
SXY = %g
*msg,info,ar25
SYZ = %g
*msg,info,ar26
SXZ = %g
*msg,info,ar27
S1 = %g
*msg,info,ar28
S2 = %g
*msg,info,ar29
S3 = %g
*msg,info,ar30
SINT = %g
*msg,info,ar31
SEQV = %g
!
!  if the coordinate isn't in the model space then print a message
!  and quit
*else
*msg,ui,arg1,arg2,arg3
Coordinate x= %g y= %g z= %g is not within the model. %/ &
Check your coordinates and try again.
*endif
!
!  turn warning messages back on
/uis,msgpop,2
/nerr,defa
!
*else
!
!  print warning message if user is not in /post1
*msg,ui
*** You need to be in /POST1 to run SXYZ ***
*endif
/gopr

点赞

长河

十千牛(10kN.com)博主,地产土博,高校教师。联系方式:sun@10kn.com

21 条评论

  1. 淋淋沥沥

    怎么查看任意面的应力应变

    • 长河

      首先用nsel选择一部分实体,要查看的截面是选定实体的一个边界,然后查看节点解就行了。这是比较方便的做法

    • 淋淋沥沥

      @长河 谢谢

  2. BRIDGEMAN

    这个具体是怎么用的,怎么在/post1输入命令流之后没有反应?

    • 这是一个宏文件,直接像运用函数那样调用宏就可以啦

  3. 您好,cmd里显示,坐标0,0,0不在模型中,我应该在什么地方输入坐标,是在! usage: sxyz,X,Y,Z,avg这吗,如果是,它提示sxyz命令不应该出现在/post1中,新手,看不明白。谢谢!

  4. 您好,为什么我按你的步骤没有反应呢,如果就把原文按你说的方法做会出现“*** You need to be in /POST1 to run SXYZ ***”,如果加上/post1 就没有任何反应了,请问这是怎么回事?急求,谢谢!

    • 在cmd窗口查看

  5. C.King

    感谢分享,新手求问,为什么我把这个MAC文件导进去后,在ansys命令框里输入这个文件名,却没有反应呢???急求急求,多谢多谢!!!

    • 把这个文章放到工作目录里,然后调用文件名就可以了

    • C.King

      @长河 我把.mac文件放到C:Program FilesAnsys Incv121ANSYSAPDL 目录下,但是调用这个文件名之后ansys没有反应哎!!!大神约个时间能不能QQ细谈?178肆07玖16。。。麻烦您了啊!!!

    • @C.King 当然不是这个目录了。你运行开始菜单Mechanical APDL Product Launcher 12.1这个程序,指定一个working directory即可

  6. Barrett

    这段程序中的坐标在哪输入?另外,如果想测量任意点的位移怎么测?

    • 输入这段命令后会有提示。位移就直接读取就行,应力需要用位移来积分,所以才这么做一下

    • Barrett

      @长河 我主要想读一下某点的位移变化,但是这个点非节点,我找了很长时间还没有找到可行的方法?希望您耐心的讲解一下。

    • @Barrett 最好是建模的时候在特征点上设置节点,实在不行,就设置一个硬点。总之,直接读取某点的位移是最准确的

  7. 不是很懂你们表达的是什么意思。

  8. 这段代码确实很经典。很熟悉

  9. 太棒了,谢谢分享,ANSYS高手,我最近也准备把ANSYS的只是捡回来。

  10. 网挣加盟网http://www.518jmw.com/

  11. 非常感谢分享!
    分析了一下,基本原理应该是定义一个极小路径,然后获取路径上解的最大值作为所求点的结果。
    初步试用了下,还不错哦!

相关推荐

微信扫一扫

微信扫一扫

微信扫一扫,分享到朋友圈

ansys实体模型中查看任意点应力的方法