Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling ANSYS from MATLAB

Status
Not open for further replies.

jpblasques

Marine/Ocean
Nov 24, 2006
20
0
0
DK
Hi everyone!

I have two batch files written in ANSYS APDL which I want to call from MATLAB. There is a small twist to it which is I would like to run them in parallel and not sequentially. I am running both programs in a UNIX machine.

So up to now I sorted out the following:

1. In the UNIX command prompt I can write something like

ansys100 <./Msc/Scripts/COMBI_SURF/MAIN.txt >./Msc/WD/OUT1.out -p aunivres -j Prop1 -s read -b list & ansys100 <./Msc/Scripts/COMBI/MAIN.txt >./Msc/WD/OUT2.out -p aunivres -j Prop2 -s read -b list &

which will run the two batch files (almost) in parallel. Note that this are two commands to launch ANSYS in batch mode separated by a '&'.

2. In MATLAB I can use the commands 'unix' or 'system' in order to write the former command to the command prompt. MATLAB would wait for the ANSYS analysis to finish before proceeding with the rest of the matlabe code if it was only one command. In this case there is a certain delay and the first command will finish first thus "saying" MATLAB that the analysis in ANSYS is over when in fact it is not true.

I think that the best solution for this problem would be to find a way to tell MATLAB to wait for a certain file (an output file from ANSYS) to exsit in a given directory before continuing reading from the MATLAB file. In this case, MATLAB would wait for the output from the second batch analysis before proceeding and my problems would be over.

Has anyone ever came across this problem and if so could you please help me with some tips? Do you have any other way of doing this?

Thanks a lot in advance.



DTU
Denmark
 
Replies continue below

Recommended for you

Yes that sounds right. IN horrible pseudocode:

In matlab

rm -f finished*.txt
call batchfile
wait until finished1.txt exists
wait until finished2.txt exists
//carry on

In batchfile

call bf1
call bf2
end

In bf1
run ansys
create finished1.txt
end

In bf2
run ansys
create finished2.txt
end

This will only allow matlab to proceed when both analysese have run, and it doesn't matter which finishes first.





Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.
Back
Top