MATLAB调用ANSYS
matlab调用ansys不需要在后面加exit命令,MATLAB会等ansys运行结束后自动回到MATLAB,同时ansys运行生成的中间文件都放在MATLAB的运行路径文件夹内,除了-o内容指定的output文件
system('D:\Ansys\v100\ANSYS\bin\intel\ansys100 -b -p ansys-product-feature -i input file -o out file.bat')
The options are:
-b = batch mode
-p = product: ANSYS/Mechanical for example
-i = your input file: file.inp for example
-o = the output file of ansys: file.out for example
ansys-product-feature ansys的产品输入代码。例如:ane3fl
other options:
-j = jobname
-m = memory size
-db = database size
-g = graphic mode
-l = language
...etc
注意:matlab中对空格有限制,所以ANSYS的安装路径中不能有空格。
网上还有很多人问,ansys的产品特征代码在哪找?大家可以:
help->>feature names
屏幕左下角“开始”->>“ansys10.0”->>"help"->>installation and licensing。查找Product Variable Table。



特别注意
the problem is related to a particular piece of 3rd party software (OpenMP) used by MATLAB. As of 2014b, when running system commands, the stack size is limited to 512k through an environment variable called KMP_STACKSIZE. It is possible to verify the existence and value of this environment variable by issuing the following command listing all the variables (in Windows):
System('SET')
(produces a list of all environment variables currently set...)
For ANSYS to be able to run, you need to increase the stack size before calling the ANSYS executable. You can do this by wrapping the ANSYS call in a batch script or you can do the following:
System('SET KMP_STACKSIZE=2048k & "C:\path_to_ansys\ansys[version].exe" [input arguments..]')
例子
%% matlab调用ANSYS进行分析
%%
% ansys 版本中的可执行文件,path中有空格要加:""
ansys_path=strcat('"E:\ANSYS16_install\ANSYS Inc\v160\ansys\bin\winx64\ANSYS160.exe"');
% jobname,不需要后缀
jobname='tianqiao1';
% 是命令流文件,也就是用ansys写的apdl语言,matlab调用时,他将以批处理方式运行,需要后缀
skriptFileName='F:\cuichanghui_here_all\mll\C92_movingload_all_use.txt';
% 输出文件所在位置,输出文件保存了程序运行的相关信息,需要后缀
outputFilename='F:\cuichanghui_here_all\cch_test.out';
% 最终总的调用字符串,其中:32代表空格的字符串ASCII码
sys_char=strcat('SET KMP_STACKSIZE=2048k &',32,ansys_path,32,...
'-b -p ane3fl -i',32,skriptFileName,32,...
'-j',32,jobname,32,...
'-o',32,outputFilename),
% 调用ANSYS
ans1=system(sys_char);
网友评论