MATLAB - ANSYS Interoperability Using Scripting

For those who have worked with SAP2000 and MATLAB, you should know that it is "easy" to link these programs to the API (MATLAB-SAP2000).

But at this point I need to use ANSYS and this software has no API with MATLAB (Thats what I know). So, in the documentation I found there is an option to "link" these software products, but I need to do Script por ANSYS (something with APDL).

My questions are: Do you know any places where I can find good information on scripting for ANSYS ?, Are there ANSYS APIs - MATLAB? Do you know pages that show procedures similar to attempts ?.

Thank you and any information is appreciated!

+3


source to share


3 answers


I don't know any API, but it's not that hard to connect programs. Typical way to interact with Ansys from Matlab:

(1) Create your ANSYS script (APDL) file, this basically has to build your model, run analyzes, process the results and generate output.

(2) Create input for APDL script. It can be generated by Matlab for example. write txt files or modify APDL script directly.

(3) Call Ansys from Matlab, sample code to get the idea:

dos( ' "d:\Program Files\ANSYS Inc\v150\ansys\bin\winx64\ANSYS150" -b -dir "d:\ANSYS working folder" -i "d:\ANSYS working folder\project.inp" -o "d:\Working Folder\ANSYS working folder\project.out" ');

      

Where project.inp

is the APDL script created in step (1) .

(4) Post-display the results generated by Ansys using Matlab.



(5) Repeat (2) - (4)

Note that these steps are not the most efficient, but FEM analysis usually takes significantly longer.

APDL is similar to Fortran (or is it Fortran?) And an indispensable tool if you want to do serious and / or parametric analysis. APDL scripting basics:

detailed introductory manual level
introductory book
official manual

Ansys usually has enough help and has sample scripts.

My experience is that usually the most time consuming part is writing the APDL script. If you are not familiar with the language, this can be "painful".

+3


source


Check out this post on File Exchange as well as this YouTube video. Good luck!



+2


source


There is a Matlab helper toolkit available for free download from the ANSYS User Portal that handles the ORB configuration in Matlab and makes it easy to access a remote ANSYS aaS session. It is available for Matlab versions later than 2014b.

I recommend:

In Matlab coding terms, if you have a solution installed it is pretty straight forward. It takes less than 10 minutes to install the solution if you have access to support.ansys.com.

  • First you need to run ANSYS on a remote machine with aaS enabled (the most common is to add -aas on the command line) and build the generated aaS key file and bring it to the Matlab machine. By default, the file name is aaS_MapdlId.txt.

  • Then you need to setup ORB Matlab (two lines of Matlab code)

ball = initialize_orb ();

load_ansys_aas ();

  1. Connect to ANSYS using aaS key file

    iCoMapdlUnit = actmapdlserver (ball, "aaS_MapdlId.txt);

  2. ANSYS disk from Matlab machine, for example:

    mapdlResult = char (iCoMapdlUnit.executeCommandToString (anyAPDLCommand))

Remember that all APDL commands are executed in the current working directory of the remote ANSYS machine. If certain files are stored on a Matlab machine but need to be used on an ANSYS machine, there are aaS commands that allow you to exchange files between an aaS client machine and an ANSYS machine.

This is part of a more general API that allows you to remove ANSYS command calls (APDLs) from any "CORBA programming language / programming environment" (eg Matlab, C ++, Java, Python ...). ANSYS is referred to as aaS in the documentation (as a server).

If you have a Matlab version not supported by the toolbar, you will need to configure the ORB Matlab. It is not difficult, but some people find it difficult. If this is your case, please post a new question and I will provide guidance in my answer.

Note: I am the author of the ANSYS blog post.

Sorin

+1


source







All Articles