声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3891|回复: 10

[动力学和稳定性] [求助]关于热动力学与弹性动力学的耦合问题

[复制链接]
发表于 2005-7-15 17:42 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 wdhd 于 2016-3-10 09:26 编辑

  关于温度与弹性变形相互影响的问题。温度问题不能由ansys计算, 用Fortran计算。计算的温度再输入到ansys计算出应力应变。然后再从ansys读出位移,再计算出新的温度。 依次循环。直到算到稳定状态。不知道大家对此有什么看法

  我看到有人提到“将ANSYS作为子程序调用 ,VC中的变量与APDL语言中的变量可以进行数据交换,不过不能直接互换.我采用的办法是,在VC中将变量结果写到一个文件中,然后再在ANSYS的APDL语言文件中读入这个文件的数据,再由ANSYS进行新的计算,计算结束之后,再由后处理处理结果,并将结果数据输出到一个文件中,然后用VC读入此文件中的数据,进行下一步处理.”

  我不清楚怎样在ansys中运行APDL,就是在ansys的command prompt中一句一句输入么?

  
[此贴子已经被作者于2005-7-15 17:44:52编辑过]

回复
分享到:

使用道具 举报

发表于 2005-7-15 20:29 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:27 编辑

  1. write APDL in "inpfile.ext"

  2. then in Ansys command prompt run : /input, inpfile, ext

  稳态问题可以分开计算,就像第一段所说的没问题。

  
[此贴子已经被作者于2005-7-15 20:31:21编辑过]

发表于 2005-7-22 21:26 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:28 编辑

  apdl二次开发[翻译]

  Chapter 4. APDL as a Macro Language

  4.1. What is an APDL Macro?

  You can record a frequently used sequence of ANSYS commands in a macro file (these are sometimes called command files). Creating a macro enables you to, in effect, create your own custom ANSYS command. For example, calculating power loss due to eddy currents in a magnetic analysis would require a series of ANSYS commands in the postprocessor. By recording this set of commands in a macro, you have a new, single command that executes all of the commands required for that calculation. In addition to executing a series of ANSYS commands, a macro can call GUI functions or pass values into arguments.

  You can also nest macros. That is, one macro can call a second macro, the second macro can call a third macro, and so on. You can use up to 20 nesting levels, including any file switches caused by the ANSYS /INPUT command. After each nested macro executes, the ANSYS program returns control to the previous macro level.

  The following is a very simple example macro file. In this example, the macro creates a block with dimensions 4, 3, and, 2 and a sphere with a radius of 1. It then subtracts the sphere from one corner of the block.

  /prep7

  /view,,-1,-2,-3

  block,,4,,3,,2

  sphere,1

  vsbv,1,2

  finish

  If this macro were called mymacro.mac, you could execute this sequence of commands with the following single ANSYS command

  *use,mymacro

  or (because the extension is .mac)

  mymacro

  Although this is not a realistic macro, it does illustrate the principle.

  This chapter provides information on the various ways you can create, store, and execute macros. It also discusses the basic information you need to use APDL as a scripting language in creating macros.
发表于 2005-7-22 21:27 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:28 编辑

  4.2. Creating a Macro

  You can create macros either within ANSYS itself or using your text editor of choice (such as emacs, vi, or wordpad). If your macro is fairly simple and short, creating it in ANSYS can be very convenient. If you are creating a longer, more complex macro or editing an existing macro then you will need a text editor. Also, using a text editor allows you to use a similar macro or ANSYS log file as the source for your macro.

  For any long, complex macro you should always consider either using a similar macro as a starting point or running the task interactively in ANSYS and using the resulting log file as the basis of your macro. Either method can greatly reduce the time and effort required to create a suitable macro.

  4.2.1. Macro File Naming Conventions

  Macros are a sequence of ANSYS commands stored in a file. Macros should not have the same name as an existing ANSYS command; ANSYS will execute the internal command instead of the macro. The following naming restrictions apply to macro files:

  · The file name cannot exceed 32 characters.

  · The file name cannot begin with a numeral.

  · The file extension cannot contain more than eight characters (if you are executing the macro as if it were an ANSYS command it should have the extension .mac.)

  · The file name or extension cannot contain spaces.

  · The file name or extension cannot contain any characters prohibited by your file system and for portability should not contain any characters prohibited by either UNIX or Windows file systems.

  To ensure that you are not using the name of an ANSYS command, before creating a macro try running the file name that you wish to use as an ANSYS command. If ANSYS returns the message shown below, you will know that the command is not used in the current processor. You should check the macro file name in each processor in which you plan to use the macro. (You could also check if the macro file name matches any command listed in the online documentation; however, this method cannot locate the names of undocumented commands.)

  Using the .mac extension allows ANSYS to execute the macro as it would any internal command. You should avoid using the extension .MAC because it is used for ANSYS internal macros.

  4.2.2. Macro Search Path

  By default, ANSYS searches for a user macro file (.mac extension) in the following locations:

  1. The ANSYSnn/docu directory.

  2. The directory (or directories) designated by the ANSYS_MACROLIB environment variable (if defined) or the login (home) directory. This environment variable is documented in the ANSYS installation and configuration guide for your platform.

  3. The directory designated by the $HOME environment variable.

  4. The working directory.

  You can place macros for your personal use in your home directory. Macros that should be available across your site should be placed in the ANSYSnn/docu directory or some commonly accessible directory that everyone can reference through the ANSYS_MACROLIB environment variable.

  · For Windows Me users: You must designate the "home directory" and drive using environment variables, see the ANSYS Installation and Configuration Guide for Windows.

  · For Windows XP, 2000, and NT users: The "current directory" is the default directory (usually a network resource) set by administrators and you should ask your network administrator for its location. You can use environment variables to create a local "home directory." The local home directory is checked after the default directory designated in your domain profile. See the ANSYS Installation and Configuration Guide for Windows for more information.

  4.2.3. Creating a Macro Within ANSYS

  You can create a macro by four methods from within ANSYS:

  · Issue the *CREATE command in the input window. Parameter values are not resolved and parameter names are written to the file.

  · Use the *CFOPEN, *CFWRITE, and *CFCLOS commands. Parameter names are resolved to their current values and those values are written to the macro file.

  · Issue the /TEE command in the input window. This command writes a list of commands to a file at the same time that the commands are being executed. As the commands are executed in the current ANSYS session, parameter names are resolved to their current values. However, in the file that is created, parameter values are not resolved and parameter names are written instead.

  · Choose the Utility Menu>Macro>Create Macro menu item. This method opens a dialog box that can be used as a simple, multi-line editor for creating macros. Parameter values are not resolved and parameter names are written to the file.

  The following sections detail each of these methods.

  4.2.3.1. Using *CREATE

  Issuing *CREATE redirects ANSYS commands entered in the command input window to the file designated by the command. All commands are redirected until you issue the *END command. If an existing file has the same name as the macro file name you specify, the ANSYS program overwrites the existing file.

  For example, suppose that you want to create a macro called matprop.mac, which automatically defines a set of material properties. The set of commands entered into the input window for this macro might look like this:

  *CREATE,matprop,mac,macros

  MP,EX,1,2.07E11

  MP,NUXY,1,.27

  MP,DENS,1,7835

  MP,KXX,1,42

  *END

  The *CREATE command takes arguments of the file name, the file extension, and the directory path (in this case, the macros directory is specified).

  When using *CREATE, all parameters used in commands are written to the file (the currently assigned values for the parameter are not substituted).

  You cannot use *CREATE within a DO loop.

  4.2.3.2. Using *CFWRITE

  If you wish to create a macro file in which current values are substituted for parameters you can use *CFWRITE. Unlike *CREATE, the *CFWRITE command cannot specify a macro name; you must first specify the macro file with the *CFOPEN command. Only those ANSYS commands that are explicitly prefaced with a *CFWRITE command are then written to the designated file; all other commands entered in the command input window are executed. As with the *CREATE command, *CFOPEN can specify a file name, a file extension, and a path. The following example writes a BLOCK command to the currently open macro file.

  *cfwrite,block,,a,,b,,c

  Note that parameters were used for arguments to the BLOCK command. The current value of those parameters (and not the parameter names) are written to the file. So, for this example, the line written to the macro file might be

  *cfwrite,block,,4,,2.5,,2

  To close the macro file, issue the *CFCLOS command.

  4.2.3.3. Using /TEE

  Issuing /TEE,NEW or /TEE,APPEND redirects ANSYS commands entered in the command input window to the file designated by the command at the same time that the commands are being executed. All commands are executed and redirected until you issue the /TEE,END command. If an existing file has the same name as the macro file name you specify with /TEE,NEW, the ANSYS program overwrites the existing file. To avoid this, use /TEE,APPEND instead.

  In addition to the Label argument (which can have a value of NEW, APPEND, or END), the /TEE command takes arguments of the file name, the file extension, and the directory path.

  As the commands are executed in the current ANSYS session, all parameter names are resolved to their current values. However, in the file that is created, parameter names are written (the currently assigned values for the parameter are not substituted). If your current parameter values are important, you can save the parameters to a file using the PARSAV command.

  For an example, see the description of the /TEE command in the ANSYS Commands Reference.

  4.2.3.4. Using Utility Menu>Macro>Create Macro

  Choosing this menu item opens an ANSYS dialog box that you can use as a simple editor for creating macros. You cannot open and edit an existing macro with this facility; if you use the name of an existing macro as the arguments for the *CREATE field, the existing file will be overwritten.
发表于 2005-7-22 21:27 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:28 编辑

  4.3. Executing Macros and Macro Libraries

  You can execute any macro file by issuing the *USE command. For example, to execute the macro called MYMACRO (no extension) residing somewhere in the macro search path, you would issue

  *use,mymacro

  In this case, the macro takes no arguments. If instead the macro was called MYMACRO.MACRO and resided in /myaccount/macros, you could call it with

  *use,/myaccount/macros/mymacro.macro

  Note that the *USE command allows you to enter the path and extension along with the file name and that these are not entered as separate arguments.

  If a macro has a .mac file extension and resides in the search path, you can execute it as if it were an ANSYS command by simply entering it in the command input window. For example, to call mymacro.mac you could simply enter

  mymacro

  You can also execute macros with a .mac extension through the Utility Menu>Macro>Execute Macro menu item.

  If the same macro takes arguments (see Passing Arguments to a Macro for more information about passing arguments to macros), then these can be entered on the command line as follows

  mymacro,4,3,2,1.5

  or

  *use,mymacro.mac,4,3,2,1.5

  The Utility Menu>Macro>Execute Macro menu item dialog provides fields for arguments.

  Executing macros contained in macro libraries is similar. You must first specify the library file using the *ULIB command. For example, to specify that macros are in the mymacros.mlib file, which resides in the /myaccount/macros directory, you would issue the following command:

  *ulib,mymacros,mlib,/myaccount/macros/

  After selecting a macro library, you can execute any macro contained in the library by specifying it through the *USE command. As with macros contained in individual files, you can specify arguments as parameters in the *USE command.

  Note

  You cannot use the *USE command to access macros not contained in the specified macro library file after issuing the *ULIB command.
发表于 2005-7-22 21:27 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:29 编辑

  4.4. Local Variables

  APDL provides two sets of specially named scalar parameters which are available for use as local variables. These consist of

  · A set of scalar parameters that provide a way of passing command line arguments to the macro.

  · A set of scalar parameters that can be used within the macro. These provide a set of local variables that can be used to define values only within that macro.

  The following sections discuss both of these variable types in detail.

  4.4.1. Passing Arguments to a Macro

  There are 19 scalar parameters that you can use to pass arguments from the macro execution command line to the macro. These scalar parameters can be reused with multiple macros; that is, their values are local to each macro. The parameters are named ARG1 through AR19 and they can be used for any of the following items:

  · Numbers

  · Alphanumeric character strings (up to eight characters enclosed in single quotes)

  · Numeric or character parameters

  · Parametric expressions

  Note

  You can pass only the values of parameters ARG1 through AR18 to a macro as arguments with the *USE command. If you create a macro that can be used as an ANSYS command (the macro files has a .mac extension), you can pass the values of parameters ARG1 through AR19 to the macro.

  For example, the following simple macro requires four arguments, ARG1, ARG2, ARG3, and ARG4:

  /prep7

  /view,,-1,-2,-3

  block,,arg1,,arg2,,arg3

  sphere,arg4

  vsbv,1,2

  finish

  To execute this macro, a user might enter

  mymacro,4,3,2.2,1

  4.4.2. Local Variables Within Macros

  Each macro can have up to 79 scalar parameters used as local variables (AR20 through AR99). These parameters are completely local to the macro, and multiple macros can each have their own unique values assigned to these parameters. These parameters are not passed to macros called from macros (nested macros). They are passed to any files processed through a /INPUT command or a "do loop" processed within the macro.

  4.4.3. Local Variables Outside of Macros

  ANSYS also has a similar set of ARG1 through AR99 scalar parameters that are local to an input file, and are not passed to any macros called by that input file. Thus, once a macro finishes and execution returns to an input file, the values of ARG1 through ARG99 revert to whatever values were defined within the input file.
发表于 2005-7-22 21:28 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:29 编辑

  第四章 宏命令

  4.1 什么是APDL宏命令?

  用户可以将一些经常使用的ANSYS命令记录在一个宏文件当中(有时也称为命令流文件)。通过宏可以更加有效地定制用户自己的ANSYS命令。例如,再磁场分析中,由于计算旋涡电流而产生的功率消耗需要一系列的ANSYS后处理命令,通过将这些命令记录在一个宏文件里,用户就能得到一个新的,单一的命令,当需要计算时只要执行这个命令即可。除了执行一个系列的命令以外,宏也能够调用GUI函数,将赋值传给变量。

  宏能够嵌套使用,即一个宏可以调用第二个宏,第二个宏可以调用第三个宏,以此类推,最多可嵌套二十个层,包括ANSYS命令“/INPUT”引起的任何文件转换。在每个嵌套的宏执行完后,ANSYS软件将会返回到其上一层的位置。

  下面是一个非常简单的宏文件例字,其内容是:先生成一个4*3*2的块,然后再生成一个半径为一的球体,随后从块的一角减去球体。其命令流文件为:

  /PREP7

  /VIEW,,-1,-2,-3

  BLOCK,,4,,3,,2

  SPHERE,1

  VSVB,1,2

  FINISH

  如果这个宏名叫做“Mymacro.mac”,就可以使用下面的命令来执行这个宏文件。

  *USE,mymacro

  或者 mymacro

  尽管这并不是一个实际的宏,但它说明了一个原理。下面将介绍使用各种不同的方法来生成、储存、执行宏,同时也会讨论在使用APDL作为一种语言生成宏时的基本知识。

  4.2创建宏

  可以使用ANSYS本身或文本编辑软件,如记事本等,来创建一个宏。如果宏相对简单而且很短,则用ANSYS软件是非常方便的。如果生成的宏较长,且很复杂,或者是要编辑已经存在的宏,那么最好采用文本编辑软件。同时使用文本编辑软件可以使用类似的宏或ANSYS的LOG文件作为生成自己宏文件的参考。

  对于一个复杂且长的宏来说,应该考虑是采用类似的宏作为参考的蓝本还是先用ANSYS的GUI模式交互执行任务,然后再将其LOG文件作为生成宏文件的基础。上述两种方法都可以减少生成一个合适宏文件的时间和精力。

  4.2.1宏文件的命名规则

  宏文件就是将一系列的ANSYS命令贮存在一个文件里。因此宏的名称不应该与ANSYS系统内已经存在的命令名相同。否则ANSYS会执行其内部命令而不是宏。下面是对宏命名的限制规则:

  •宏名不能超过32个字符。

  •宏名不能用数字作为开头。

  •文件的扩展名不能超过8个字符,如果在执行宏,那么按照ANSYS命令,其扩展名应该是“.mac”。

  •文件名和扩展名不能包括空格。文件名和扩展名不能包含系统所禁止的任何字符。

  为了保证没有使用与ANSYS命令相同的文件名,在生成宏之前,事先在ANSYS软件里运行一下这个文件名。类似的,应该用这个名称在所有的处理器中都试一下,直到没有相同的ANSYS命令时,才可以使用这个名称作为宏名。还有一种简便的方法是将该名称放在在线帮助文档中,进行搜索,可以查出是否与存在的ANSYS命令名相同。但这种方法不能检查出没有帮助文档的ANSYS命令。

  使用扩展名“.mac”,可以使ANSYS在执行该宏时,当作一个内部命令一样使用。但最好避免使用这个扩展名,因为它被ANSYS内部宏所使用。

  4.2.2宏的搜索路径

  在缺省方式下,ANSYS通过下列路径搜索用户自定义的宏文件(其扩展名为.mac)。

  ⑴目录:/AnsysInc/v70/ANSYS/apdl。

  ⑵在ANSYS_MACROLIB环境下指定的路径或者注册目录。

  ⑶由$HOME环境变量所指定的目录。

  ⑷工作目录。

  可以将自己个人使用的宏放在用户主目录下。对于经常要使用的宏应该放在/Ansys Inc/v70/ANSYS/apdl或者某些经常进入的目录下,这样任何人通过ANSYS_MACROLIB环境变量都可以找到。

  对于Windows用户,当前目录常常就是一个由管理员设置的缺省目录,对于这个位置,用户应该请教管理员,也可以使用环境变量生成一个局部的“主目录”。

  4.2.3用ANSYS生成宏

  在ANSYS系统内,可以用四种方法来定制一个宏:

  •在命令输入中执行“*CREAT”命令,这时参数值将不重新求解,参数名被写入文件里。

  •使用命令“*CFOPEN”、“CFWRITE”和“CFCLOS”,参数将重新求解,并得到他们的当前值,这些值将被写入到宏文件中。

  •在命令输入行中执行“/TEE”命令,这个命令在执行输入命令的同时,也把这些命令列出一个清单,并写入到一个文件里。命令在当前ANSYS的对话框中执行时,参数名会重新求解并得到它们的当前值。然而在生成的文件中,参数值没有求解,仅仅写入了参数名。

  •选择GUI模式:Utility Menu>Marco>Creat Macro,这种方法将打开一个对话框,对生成宏来说,可作为一个简单多行编辑器,参数值将不会被求解,参数名将被写入到文件中。

  4.2.3.1使用命令“*CREAT”

  执行命令“*CREAT”后,将会使在命令输入行中执行的ANSYS命令改向进入到由该命令指定的文件中,在执行命令“*END”之前, 所有输入的命令都将会改向。如果已经存在的文件名与用户指定的文件名相同,ANSYS会覆盖掉这个已经存在的文件。

  假设要生成一个名叫“matprop.mac”的文件,这个文件能够自动定义材料的性能参数,为生成这个宏,在命令输入行中输入下列命令流即可。

  *CREAT,matrop,mac,macros

  MP,EX,1,2.07E11

  MP,NUXY,1.27

  MP,DENS,1.7835

  MP,KXX,1.42

  *END

  命令“*CREAT”包含有文件名、扩展名和目录路径(大多数情况指定为“macros”)等变量。

  当使用命令“*CREAT”时,在命令中使用的所有参数都将会写入到文件中,但并不会将值赋给参数。

  但要注意,命令“*CEREAT”不能在DO-LOOP循环中使用。

  4.2.3.2使用命令“*CFWRITE”

  如果希望在生成一个宏的同时,参数能够被当前的值所取代,这时可以使用命令“*CFWRITE”。与命令“*CREAT”不相同的是,命令“*CFWRITE”并不能指定一个文件名,必须先由“CFOPEN”指定一个宏文件,然后只有那些在命令输入行中输入的且用“*CFWRITE”作为前缀的命令才能够写入到指定的文件名、扩展名和工作目录。

  下列的一个例子就是将一个“BLOCK”命令写入到当时打开的宏文件里。

  *CFWRITE,BLOCK,,a,,b,,c

  对于“BLOCK”命令来说,由于这些参数被作为变量使用,这些参数的当前值也要被写入到文件中,因此,对于这个例子来说,将要写入到宏文件里的这一行也可写成:

  *CFWRITE,BLOCK,,4,,2.5,,2

  要关闭这个打开的宏文件,可使用命令“*CFCLOS”。

  4.2.3.3使用“/TEE”

  执行“/TEE,NEW”或者“/TEE,APPEND”命令后,命令输入行中的命令会改向并进入到由命令指定的文件中,同时这些命令也会被执行。除非执行了“/TEE,END”命令,否则输入的命令都将会被改向,并执行。如果在执行命令“/TEE,NEW”后,已存在的文件名与指定的宏文件相同,ANSYS系统将会覆盖它,因此建议使用命令“/TEE,APPEND”。

  另外,在命“/TEE”中除了label变量外,还可以指定文件名、扩展名和目录的路径。

  命令在ANSYS对话框中执行时,所有的参数名都将会重新求解,并得到它们的当前值。然而在生成的文件中,参数名被写入,当前对参数指定的值并不会取代。如果感到当前的参数值非常重要,用户可用命令“PARSAV”将这些参数保留在一个文件里。

  4.2.3.4使用操作路径

  GUI:Utility Menu>Macro>Creat Macro

  当执行这一操作后,系统会弹出一个对话框,在这个对话框中,用户可以输入命令并生成一个宏文件。但不能利用这个特征去打开或编辑已经存在的宏文件,如果用户在“*CREAT”域内输入一个与已经存在的文件同名的宏名,则已经存在的文件将会被覆盖掉。

  与命令“*CREAT”类似,参数并不去求解,而是全部写入到宏文件当中。但最后一行要写上“*END”命令。

  4.2.3.5使用文本编辑器

  可以使用你最喜爱文本编辑器来生成或编辑一个宏文件。任何ASCII文本编辑器均可。同时ANSYS宏要求每行都有一个终止符(即回车符),以表示输入命令结束。因此在某个平台上生成的宏文件可以在任何平台上工作。

  使用这种方法生成的宏文件,其内容不要包含“*CREAT”和“*END”命令。

  4.2.3.6使用宏库文件

  为了方便起见,ANSYS系统也允许将一系列的宏放在一个文件里。这个文件就称之为宏库文件。可以采用文本编辑器或命令“*CREAT”来生成这个宏库文件,由于宏库文件的命令行数肯定要比单个宏命令要多,也许使用文本编辑器是一种最好的方式。

  宏库文件没有确定的文件扩展名,其文件名的命名规则与宏文件类似,宏库文件有如下的结构:

  MACRONAME1

  ……

  /EOF

  MACRONAME2

  ……

  /EOF

  MACRONAME3

  ……

  /EOF

  如下的宏库文件里包含着两个简单的宏:

  mybloc

  /PREP7

  /VIEW,,-1,-2,-3

  BLOCK,,4,,3,,2

  FINISH

  /EOF

  mysphere

  /PREP7

  /VIEW,,-1,-2,-3

  SPHERE,1

  FINISH

  /EOF

  从上述例子可以看出,在宏库文件里,每个宏都以宏名作为起始位置,再用“/EOF”命令作为结束的标志。

  宏库文件能够放在系统的任何位置,尽管这样,最好还是将其放在宏搜索的路径里。与宏文件不同之处是,宏库文件的扩展名可以使用8个字符。
发表于 2005-7-22 21:28 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:29 编辑

  4.3执行宏文件和宏库文件

  用户可以通过使用“/*USE”命令来执行任何宏文件,如果要执行一个放在宏搜索路径中叫“mymacro”的宏时,可以使用:

  *use,mymacro

  在这种情况下,宏没有变量。如果要执行一个保存在“/myaccount/macro”中且名称为“mymacro.macro”的宏时,执行语句为:

  *use,/myaccount/macros/mymacro.macro

  由于“*USE”命令能够自动进入路径并搜索到文件名,因此没有必要指定分离的变量。

  如果一个宏有一个“.mac”的扩展名,并且保存在搜索路径里。这时就可以象执行ANSYS内部命令一样在命令输入行中执行这个宏。如果要调用mymacro.mac这个宏时,只要在命令输入行中简单的输入:“mymacro”,并回车即可。

  当然,也可以利用下拉菜单执行这个以“.mac”作为扩展名的宏。其中执行路径为:

  GUI:UTILITY Menu>Macro>Execute Macro

  如果一个宏有许多变量,那么可以直接在命令行中输入。如:

  mymacro,4,3,2,1.5

  或者 *use,mymacro.mac,4,3,2,1.5

  而用下拉菜单即操作路径“UTILITY Menu>Macro>Execute Macro”时,会弹出一个对话框,其变量则在对话框中输入即可。

  执行一个包含在宏库文件里的宏,其过程与执行宏文件是相似的。首先必须用命令“*ULIB”来指定一个文件,如指定宏是在“mymacros.mlib”库文件里,且保存在“/myaccount/macros”目录里,这时要执行下列操作:

  *ulib,mymacros,mlib,/myaccount/macros/

  在选择了一个宏文件后,就可以使用命令“*USE”来执行包含在这个宏库文件中的任何宏。就像包含在单个文件里一样,在使用“/*USE”时可以指定变量作为参数。

  但要注意,在执行“*ULIB”命令后不能使用“*USE”命令去执行没有包含在指定宏库文件中的宏名。

  4.4局部变量

  APDL提供了两组特定命名的标量参数,他们被利用来作为局部变量使用。即:

  •一组标量参数,为命令行中的变量传递给宏提供了一条通道。

  •一组能够在宏里面使用的标量参数,它提供了能够定义值的一组局部变量,并且只在定义的那个宏里有效。

  .4.1将变量传递给宏

  可以使用19个标量参数将执行命令行中宏的变量传递给宏,这些标量参数能够在多个宏中重复使用,也就是说,它们的值对于宏来说是局部的。这些参数名是:ARG1-AR19,并且它们能够在下列范围内使用:

  •数值。

  •字符型字符串(用单引号括起来且不超过8个字符)。

  •数值或字符参数。

  •参数表达式。

  但要注意,当使用命令“*USE”时只能将ARG1-AR19的参数值作为变量传递给宏。但如果生成的宏可以作为一个ANSYS命令使用,即它有一个扩展名“.mac”时,这时可以将ARG1-AR19的参数值传递给宏。

  如下所示的宏需要4个变量:ARG1、ARG2、ARG3和ARG4。

  /PREP7

  /VIEW,,-1,-2,-3

  BLOCK,,ARG1,,ARG2,,ARG3

  SPHERE,ARG4

  VSBV,1,2

  FINISH

  为了执行这个宏,用户应该输入:

  mymacro,4,3,2.2,1

  4.4.2宏里面的局部变量

  每个宏最多可以使用79个标量作为局部变量(AR20-AR99),这些参数对宏来说是完全局部的,多重宏也都有他们自己唯一的赋值给这些参数。这些参数并不传递给由宏调用的嵌套宏。它们被传递给由“/INPUT”命令输入的任何文件,或者是在宏里面进行的“DO-LOOP”。

  4.4.3宏外面的局部变量

  ANSYS也有一组类似的ARG1-AR99的标量参数,它们对于输入文件来说是局部的,它们并不传递给由输入文件所调用的任何宏。因此一旦宏执行完成,系统又返回到输入文件时,ARG1-ARG99的值又恢复到当前输入文件里所定义的值。

  4.4.4在元件和部件中使用宏

  为了使大的实体模型便于管理,可以根据不同类型的实体,如节点、单元关键点、线、面和体等,将一个模型分成离散的元件,每个元件可以容纳一种类型的实体,这样做的目的是可以根据分离的实体;来完成施加载荷或者生成图象等任务。

  也可以生成部件,它们是成组的,是由两个或者多个元件甚至是多个部件组成的。一个部件最多可以嵌套5层,如可以建立一个由stator、permmag、rotor和windings等元件生成的名叫“motor”的部件。
发表于 2005-7-22 21:31 | 显示全部楼层
本帖最后由 wdhd 于 2016-3-10 09:30 编辑

  APDL_宏文件的使用

  1,符号

  !

  2,处理

  /ang/ANGLE,WN,THETA,Axis,KINCR(绕指定轴旋转视图)

  /pnum/PNUM,Label,KEY(设置图形显示风格)

  【注】Label=NODE、ELEM、KP、LINE、AREA、VOLU、DOMAIN、SEC、MAT、TYPE、REAL、LOC、SVAL、TABNAM、STAT、ESYS、DEFA。

  /prep7

  /psymb/PSYMB,Label,KEY(符号显示控制)

  /solu/SOLU(进入求解器单元)

  /view/VIEW,WN,XV,YV,ZV(改变观察方向)

  3,大写

  ESLVESLV,type(选择当前有效体上的单元)

  EXTOPTEXTOPT,Lab,Val1,Val2,Val3(扫掠体生成控制选项)

  RECTNGRECTNG,X1,X2,Y1,Y2(两角(左下、右上)生成矩形)

  VEXTVEXT,NA1,NA2,NINC,DX,DY,DZ,RX,RY,RZ(将面按比例延伸生成体)

  4,一般命令

  (1)选择

  allselALLSEL,LabT,Entity(选择所有实体)

  【注】LabT=ALL(指定实体及其所有下层实体)、BELOW(指定实体及其下一层实体);

  Entity=ALL、VOLU、AREA、LINE、KP、ELEM、NODE。

  aselASEL,Type,Item,Comp,VMIN,VMAX,VINC,KSWP(选择面)

  【注】Item =HPT时,选择包含硬点的面。

  eselESEL, Type, Item, Comp, VMIN, VMAX, VINC, KABS(选择单元子集)

  lselLSEL,Type,Item,Comp,VMIN,VMAX,VINC,KSWP(选择线)

  【注】Item =HPT时,选择包含硬点的线。

  nselNSEL,Type,Item,Comp,VMIN,VMAX,VINC,KABS(节点的选择)

  【注】 选择方式Type=S(选择一组节点为Active的节点)、R(在现有的Active节点中,再选择某些节点为Active节点)、A(再选择某些节点,加入现有Active节点中)、U(在现有Active节点中,排除某些节点)、ALL(全部);

  vsel

  (2)画图

  aplotAPLOT,NA1,NA2,NINC,DEGEN,SCALE(显示所选面)

  eplotEPLOT(元素显示)

  gplotGPLOT(多窗口显示实体)

  vplotVPLOT,NV1,NV2,NINC,DEGEN,SCALE(显示所选体)

  (3)其它

  acelACEL,ACEX,ACEY,ACEZ(定义结构的线性加速度)

  aglueAGLUE,NA1,NA2,…,NA8,NA9(面间相互粘接)

  alAL,L1,L2,…,L9,L10(以线定义面)

  ameshAMESH,NA1,NA2,NINC(划分面生成面单元)

  AMESH,AREA,KP1,KP2,KP3,KP4(通过点划分面单元)

  antypeANTYPE,Antype,Status,LDSTEP, SUBSTEP, Action(定义分析类型)

  【注】Label =STATIC、BUCKLE、MODAL、HARMIC、TRANS…;

  Status=NEW、REST;

  Action= CONTINUE、ENDSTEP、RSTCREATE。

  cmCM, cname, entity(定义组元,将几何元素分组形成组元)

  【注】cname: 由字母数字组成的组元名

  entity: 组元的类型(volu, area, line, kp, elem, node)

  daDA, AREA, Lab, Value1, Value2(定义截面的自由度)

  esurfESURF,XNODE,Tlab,Shape(在既有单元表面生成表面单元)

  eslnESLN, Type, EKEY, NodeType(选择已选节点上的单元)

  etET,ITYPE,Ename,KOPT1,KOPT2,KOPT3,KOPT4,KOPT5,KOPT6,INOPR(定义单元)

  【注】KOPT1~KOPT6为元素特性编码,BEAM3的KOPT6=1时,表示分析后的结果可输出节点的力或力矩。

  finish

  kK,NPT,X,Y,Z(定义关键点)

  【注】NPT:关键点号,如果赋0,则分配给最小号

  keyoptKEYOPT, ITYPE, KNUM, VALUE(单元主要选项设置)

  lL,P1,P2,NDIV,SPACE,XV1,YV1,ZV1,XV2,YV2,ZV2(定义线)

  lesizeLESIZE,NL1,SIZE,ANGSIZ,NDIV,SPACE,KFORC,LAYER1,LAYER2,KYNDIV(指定所选线上单元数)

  matMAT,MAT(指定材料特性)

  mpMP,Lab,MAT,C0,C1,C2,C3,C4(定义线性材料特性)

  nlgeomNlgeom,key

  nslaNsla,type,nkey(选择与已选截面有关的计节点)

  nsubNSUBST,NSBSTP,NSBMX,NSBMN,Carry(直接指定子步数)

  numcmpNUMCMP,Label(压缩编号消除空号)

  nummrgNUMMRG, Label, TOLER, GTOLER, Action, Switch(合并)

  outresOUTRES, Item,FREQ,Cname(控制数据库和结果文件中的记录内容)

  【注】欲选择结果的内容Item=ALL(系统默认);负载的次数FREQ=LAST(最后负载)。

  save

  sfeSFE,ELEM,LKEY,Lab,KVAL,VAL1,VAL2,VAL3,VAL4(分布力作用单元上)

  rR,NSET,R1,R2,R3,R4,R5,R6(定义实常数)

  【注】实常数是与单元类型一起使用的,实常数中R1、R2等值对不同的单元类型有不同的意义。

  realREAL,NSET(指定实常数)

  tbTB,Lab,MAT,NTEMP,NPTS,TBOPT,EOSOPT(在非线性材料属性或特殊单元输入中激活一单元表格)

  tbdatTBDATA,STLOC,C1,C2,C3,C4,C5,C6(定义单元表格中的数据)

  timeTIME,TIME(通过时间定义载荷步)

  typeTYPE,ITYPE(指定单元类型)

  vmeshVMESH,NV1,NV2,NINC(划分体生成体单元)
发表于 2005-8-3 10:16 | 显示全部楼层

回复:(FSI)1. write APDL in "inpfile.ext" 2....

本帖最后由 wdhd 于 2016-3-10 09:31 编辑

  以下是引用FSI在2005-7-15 20:29:54的发言:

  1. write APDL in "inpfile.ext"

  2. then in Ansys command prompt run : /input, inpfile, ext

  稳态问题可以分开计算,就像第一段所说的没问题。

  能说得具体点吗?
发表于 2006-6-1 10:07 | 显示全部楼层
还是不很清楚。
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-4-28 05:23 , Processed in 0.103562 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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