ansys与VC&Fortran程序的接口 及 二次开发经验

更新时间:2023-05-17 20:25:36 阅读: 评论:0

将ANSYS作为子程序调用
对于优化或参数化设计,可以在VC或FORTRAN中将ANSYS作为子程序调用。具体调用方法如下:
1.在VC中调用ANSYS
::WinExec("d:/ANSYS57/BIN/INTEL/ANSYS57 -b -p ansys_product_feature -i input_file -o output_file",SW_SHOWNORMAL);
2.在FORTRAN中调用ANSYS
LOGICAL(4) result
RESULT=SYSTEMQQ('d:\ANSYS57\BIN\INTEL\ANSYS57 -b -p
ansys_product_feature -i input_file -o output_file')
3.说明
1和2中,input_file为用APDL语言编写的ANSYS输入文件。
ansys_product_feature为你的ANSYS产品特征代码。
需要注意的是,在VC中调用ANSYS时,需要加一条判断语句,以确定ANSYS
已经执行完毕。
在ANSYS中当然也可以以VC或FORTRAN作为子程序调用。可以参看有关ANSYS二次开发方面的资料。
这个方法应该是与系统无关的。
在FORTRAN中不需要判断,FORTRAN会等ANSYS执行完毕才继续执行下一条语句。
在VC中,我没有找到与FORTRAN类似的函数,只好加一条循环判断语句。
如果谁能找着这样的函数,请告诉我,谢谢!
判断方法很简单,只需判断错误文件是否可写就可以了。
因为当ANSYS在运行时,是不可写的,只有当它运行完毕,此文件才可写。
Ur Programmable Features
UPFs: What Are They?
One of ANSYS’ strengths is that its toolbox will handle anything from a textbook plate with hole, all the way up to allowing you to recompile the code with FORTRAN scripts that you develop yourlf. The Ur Programmable Feature (UPF) capability allows urs to create their own subroutines and link them into ANSYS.
What Are UPFs Ud For?
There are a variety of common us for UPFs:
• Material models
• Ur-developed elements
• Ur commands
• Element orientation
•Ur beam definition
• Heat generation
•Defining real constants “on the fly”
How Hard Is It to Implement a UPF?
Implementing a UPF is definitely more work than simply programming the action using APDL. However, if you have existing FORTRAN code you want to include or run externally, or have any of the above-mentioned challenges, then APDL will not suffice.
To learn for yourlf, you will want to surround your lf with resources:
• This article!
•ANSYS Programmer’s Guide: Ur Programmable Features
o A must-have!!!!
o All the needed subroutines are documented here
•The hundreds of documented template scripts found within the installation directory in /custom/ur
•XANSYS. Submit your questions to the XANSYS community.
世博会志愿者•PADT. Submit your questions to us.
What is the Process?
1. Copy a sample routine from the ANSYS directories
2. Modify it to do what you want
3. U the ANSYS batch compile script to compile and link
4. Locate the new executable for u
5. In your model, activate ur features by applicable method
a. Define ur element
b. Define ur material model
c. Turn on ur feature in element real constants
d. Define ur command with /UCMD
e. Setup in USRCAL command
6. Debug
Do I have to u FORTRAN?
•All of the routines are called as FORTRAN and u FORTRAN calls to utility functions.
•You could u FORTRAN wrappers to call C routines, but that is usually not worth the effort.
•ANSYS provides you with a compile script to help with the process.
•Don’t freak out. FORTRAN is very easy to u, and creating UPFs and recompiling ANSYS is actually very easy.
You Want to Learn by Example?!?
自缚的初一女孩So before opening the ANSYS Programmer’s Guide, you want to take a look at what you’re getting into? Well then,
UPFs Example1, USER02.F
•USER02.F contains code to offt nodes by supplied x,y,z values
•Good example of structure of routines
•Shows how other routines are called
Typical Header Information. Includes source control data (*deck), copyright information, confidentiality, and pointer to more information. Also function statement.
*deck,ur02          ur
ANSYS,INC
function  ur02 (initin,dpin,ch4in,ch8in)
c *** primary function:  ur routine number 02
c    This demonstration offts lecte
d nodes with th
e command:
c      usr2,dx,dy,dz
c    *** ansys (r) copyright(c) 2000
c    *** ansys, inc.山东省多大
c *** Notice - This file contains ANSYS Confidential information
c /*************************************************************
\
滑稽的英语怎么说c | e ur01 for additional information on ur routines      |
c
\*************************************************************/ <snip>
Arguments Section. Describes input and output arguments, what type they are, and what they are ud for. Also, additional examples and help are put in this ction. Externally pasd and local variables are also defined here. Finally, the standard include statements are placed here.
<snip>
c input arguments:
c  variable (typ,siz,intent)  description
c  intin    (int,ar(12),in)  - integers from comman
d line
c  dpin    (dp,ar(12),in)  - double precision from cmn
d line
c  ch4in    (ch*4,ar(12),in) - upper ca 4 characters from cmnd
c  ch8in    (ch*8,ar(12),in) - as input 8 characters from cmnd
c output arguments: none
c  ur02  (int,sc,out)    - result code (shoul
d b
e zero)
c                              (which is ignore
d for now)
方便面怎么泡好吃c **************************************************************
c  intin(2), dpin(2), ch4in(2), & ch8in are all reprentations
c  of the contents of the con
d field on th
小肚子胀气
e command line
c  (the fiel
d after th
e command label)
c **************************************************************
第一个百年目标external  wrinqr,ndinqr,ndgxyz,ndpxyz,erhandler
integer  wrinqr,ndinqr,ndgxyz
integer  usr02,intin(12),iott,maxnp,i,kl
double precision  dpin(12),xyz(3)
character*4  ch4in(12)
character*8  ch8in(12)
#include "ansysdef.inc"
<snip>
Calculations. U ndinqr() to get max node number. This code snippet loops on all possible node nu
mbers, checks to e if the node is lected, and gets its x, y, and z values. Then it does the offt and updates the x,y,z position with ndpxyz().
<snip>
maxnp = ndinqr (0,DB_MAXDEFINED)
do i = 1,maxnp
kl = ndgxyz (i,xyz(i))
if (kl .eq. 1) then
xyz(1) = xyz(1) + dpin(2)
xyz(2) = xyz(2) + dpin(3)
xyz(3) = xyz(3) + dpin(4)
call ndpxyz (i,xyz(i))
endif
enddo
<snip>
Clean Up and Exit. This code snippet is ud to figure out the standard ouput unit, and then write a message to it. It will also write a message to a GUI pop-up box. It will then t the return value and leave.
<snip>
c ***** write to output file *****
iott = wrinqr(WR_OUTPUT)
write (iott,2000)
2000 format (/' NODE OFFSET COMPLETE '/)
c ***** write to GUI window *****
call erhandler ('ur02',3000,
x    2,'NODE OFFSET COMPLETE',0.0d0,' ')
c ***** require
d return valu
e *****
ur02 = 0
return
end
<snip>
成市UPFs: Example 2, USERCR.F
Creep strain due to constant applied stress:

本文发布于:2023-05-17 20:25:36,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/672162.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:调用   文件   判断
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图