Search
Close this search box.
Notifications
Clear all

From Matlab to Abaqus using python

2 Posts
2 Users
0 Reactions
544 Views
Posts: 3
Topic starter
(@alexa01eden)
New Member
Joined: 11 years ago

Dear all,

in Abaqus i created some macros, thus i have .py file with all the macros which i can run normally through Abaqus.

What i would like to do is, using Matlab, to open the .py file, modify for instance one dimension of my model and then run again the Abaqus job.

I would like also to know how to run it by selecting the macros to apply.

It would be nice if it can be also made by using parameters, (es. in matlab i insert the dimension a=10 and in the macro i update the variable a).

Did somebody make something similar?

Can you please provide just the few lines of Matlab code which allow me to do that?

I know how it should work theoretically but then to traslate it in a code is something else!

So that would help me a lot since i did not find any guide or tutorial for that.

Thank you very much,

Michele.

Topic Tags
1 Reply
Posts: 2
(@PowerM)
New Member
Joined: 10 years ago

Hello Michele,

I have done a similar program, but I was modifying the variables of a fortran code through Python, instead of changing the variables of a python code through MATLAB. However the logic of connecting both software should be the same behind it should be mostly the same. There are more elegant ways of doing it, but it is quite specific for each language.

First, you code your python script to read the value of the variables you want to change (e.g. variable a) from a previously created .txt file, which can be easily done with the open() function. This .txt would have been created by your MATLAB code (or manually when you are testing).

Then you modify your MATLAB script to create the .txt file, which will be read by the python script. Run both separately and check if it works smoothly.

After this is done you need a MATLAB library, similar to pythons subprocess, that can access the command line or run other files in your directory. This library will enable the MATLAB code to run the python script and voila, you have matlab and python connected.

So, in a nutshell. Matlab creates the .txt file with the variable values and runs the python script which reads the values in the .txt file and runs the Abaqus job.

have a good one,

Pedro

Topic Tags
1 Reply
Share: