How can I run ANSYS from MATLAB?

Hi,
Would you tell me about the cause and solution for stooping of ANSYS run from MATLAB?
I want to run ANSYS from MATLAB, and I tried "Shell Escape Function" (I wrote the DOS comand after "!").
However ANSYS stopped running at the stage of the solution .
It only indicates ANSYS stopped working.
I think DOS command is not wrong, because it run from CMD.exe, and it runs without problems partway.
I suspect the cause is stack overflow, but I do not know how to identify that.
My PC environment is
Windows 7 Enterprise Intel Core i7 970 16.0GB
Truly yours.

1 comentario

Akash Kunjalwar
Akash Kunjalwar el 14 de Mzo. de 2018
I'm a an undergraduate mechanical engineering student from Osmania University, India. We have to write a code based on calculus in MATLAB and run it in ANSYS APDL as our final project for the course. Please provide the detailed procedure for the same.

Iniciar sesión para comentar.

 Respuesta aceptada

Sarah Palfreyman
Sarah Palfreyman el 10 de En. de 2017

0 votos

See ANSYS for the MATLAB AAS Toolbox interface.

2 comentarios

Zhale Davo
Zhale Davo el 19 de Mayo de 2021
hi sarah
this link went to ansys homepage and nothing else. how can we as students download the matlab aas toolbox? because for downloading it we need to log in on ansys customer portal and if we are using the student version of ansys we do not have access to that toolbox. so how should we run ansys from matlab? is there any other way than the aas toolbox?
SorMun
SorMun el 16 de Nov. de 2023
The toolbox is now availabe for download from Mathworks File Exchange at
Thank you
Sorin

Iniciar sesión para comentar.

Más respuestas (6)

Nicolai Bloch
Nicolai Bloch el 27 de Jul. de 2015
Editada: Nicolai Bloch el 27 de Jul. de 2015
Hi All
I also had this issue receiving a error return code -1073741571 (alias c00000fd), which is a Windows error code indicating a stack overflow. Since this is really a system level error, ANSYS doesn't produce any error messages in its own log/error file. Support told me that 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..]')
I haven't played around with the stack size enough to find a critical value (may also be mesh size/solver dependent). At least the above setting worked for me.

10 comentarios

Arpad Rozsas
Arpad Rozsas el 20 de Nov. de 2015
Thank you very much! You saved me from going crazy.
Nikolay Perepelkin
Nikolay Perepelkin el 9 de Jun. de 2017
Thanks! Worked for me as well. (Matlab R2016a + ANSYS 18.0)
Viktor
Viktor el 13 de Sept. de 2017
Thank you. Worked for me also in Matlab 2017a + ANSYS 18.1.
Newsam Niu
Newsam Niu el 2 de Nov. de 2017
Awesome! It works with MATLAB R2016a + ANSYS17.1 as well.
MUJAHID UMAR
MUJAHID UMAR el 18 de Nov. de 2017
Totally just worked for me. Matlab R2016b and Ansys 15.
Changhui Cui
Changhui Cui el 8 de Dic. de 2017
Fantastic, it worked for me. Thank you!
Mohamed Alkalla
Mohamed Alkalla el 14 de Sept. de 2018
Editada: Mohamed Alkalla el 14 de Sept. de 2018
Hi Nicolai,
I've subscribed especially to be able to write this comment thanking you for your great help. I've tried several ways along many days but this command totally solved the problem.
Many thanks again.
Mohamed Alkalla
Thank you for the video and replying to comments. My concern is about Part 1. I have an ansys apdl code with a large number of nodes and elements. The MATLAB remains on Pause for a while when the ansys gets into the solution, then terminated. I tried the code you suggested as below:
!SET KMP_STACKSIZE=15000M & "C:\Program Files\ANSYS Inc\v161\ansys\bin\winx64\ANSYS161.exe" -b -i Run_1_Test.mac -o Run_1_Test_out.txt
But still having the same issue, while only 50% my computer RAM is in use. I appreciate your help in advance.
Jiantao Liu
Jiantao Liu el 12 de Mayo de 2019
Thank you so much, buddy, it is hard to find the sulution for this.
It fixed my problem.
Matlab 2018b + ANSYS R19
"It always return a status or ans =-1.0737e+009"
Davide Clerici
Davide Clerici el 5 de Jun. de 2020
Worked even for me. Ansys 19.0+MATLAB 2020A. Thank you!!!

Iniciar sesión para comentar.

Yusuke
Yusuke el 27 de Oct. de 2014

0 votos

Thank you for your answer.
I will try if I can not find any other solutions.
However I want to know how to run ANSYS by DOS command and solutions for error.
Because, my program is almost written.
Do you have any other ideas?
Your continued support will be greatly appreciated.
Ola
Ola el 20 de Nov. de 2014

0 votos

Hi, i have the exact same problem as you Yusuke. Ansys stops working just as it's about to calculate the solution. The odd thing is that it works perfectly fine if i run my batch file outside of matlab. Sadly I have not yet found the solution for this problem, but was hoping that you could replay the answer if or when you find it. If not, then i'll try to post my solution if i find one, good luck.

2 comentarios

Yusuke
Yusuke el 21 de Nov. de 2014
Hi, thank you for getting touch with me.
I have already cleared my problem.
The cause of my problem was using matlab2014b.
If I use matlab2014a, I can run ANSYS from matlab.
I don't know the exact reason for this problem, however I think matlab2014b has some bugs.
So please try to use matlab 2014a.
I hope this helps you.
Ola
Ola el 23 de Nov. de 2014
Ah, thank you man! This really saved me, running it from 2014a worked for me aswell. Thanks for the quick reply :)

Iniciar sesión para comentar.

Georg
Georg el 3 de Jun. de 2015
I can confirm this behavior when running Matlab 2014b and 2015a with any verison of ANSYS. At the same time it works perfectly with Matlab 2013a. That really annoying. I tried two different ways of initiating the Ansys execution:
cmd = sprintf(['"' ansys_path '"' ...
' -b' ...
' -j ' jobname ...
' -i "' skriptFileName '.inp"' ...
' -o "' outputFilename '.txt"' ...
]);
then:
[o, txt] = system(cmd, '-echo')
... just like:
rt = java.lang.Runtime.getRuntime()
p = rt.exec(cmd)
p.waitFor()
crashes with something I think is a stack overflow.
When running the java-code from e.g. Netbeans (jdk 1.8) it works perfectly. Also the execution from the command prompt works perfectly. So I assume it's definetly a Matlab related problem.

2 comentarios

Georg
Georg el 3 de Jun. de 2015
FYI:
Problemsignatur:
Problemereignisname: APPCRASH
Anwendungsname: ANSYS.exe
Anwendungsversion: 16.0.0.0
Anwendungszeitstempel: 54808089
Fehlermodulname: ANSYS.exe
Fehlermodulversion: 16.0.0.0
Fehlermodulzeitstempel: 54808089
Ausnahmecode: c00000fd
Ausnahmeoffset: 0000000007dbfe27
Betriebsystemversion: 6.1.7601.2.1.0.256.4
Gebietsschema-ID: 2055
Zusatzinformation 1: c516
Zusatzinformation 2: c516bfdf78867a45b65f55f9a72f0328
Zusatzinformation 3: 2abc
Zusatzinformation 4: 2abc3a60b12a51f515354adc2ddacd65
Lesen Sie unsere Datenschutzbestimmungen online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0407
Wenn die Onlinedatenschutzbestimmungen nicht verfügbar sind, lesen Sie unsere Datenschutzbestimmungen offline:
C:\Windows\system32\de-DE\erofflps.txt
As per my original post (above), but using your code instead, this should do the trick:
cmd = sprintf(['SET KMP_STACKSIZE=2048k & "' ansys_path '"' ...
' -b' ...
' -j ' jobname ...
' -i "' skriptFileName '.inp"' ...
' -o "' outputFilename '.txt"' ...
]);
[o, txt] = system(cmd, '-echo');

Iniciar sesión para comentar.

Seth
Seth el 7 de Abr. de 2016

0 votos

Thank you - this thread was a big help to me several times (I forgot about the problem and rediscovered it a few times) ;-)
Akshay Kumar
Akshay Kumar el 13 de Jun. de 2018
Editada: Walter Roberson el 14 de Jun. de 2018

0 votos

Check this out, might be helpful. https://youtu.be/sE3NkH1m24w using MATLAB to run (ANSYS) APDL macro code

Categorías

Más información sobre Downloads en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 27 de Oct. de 2014

Comentada:

el 16 de Nov. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by