Calling MATLAB from YADE

Asked by Pouyan

Hello,

I need to call a pretrianed MATLAB ANN from YADE to calculate drag force (https://link.springer.com/article/10.1007%2Fs11242-019-01308-9).

The MATLAB engine "matlab.engine.start_matlab" enable Python to call MATLAB functions . The command simply return input and output arguments.

I could call the MATLAB script to compute the drag force from a python script.

However, when I run a .py script from terminal using "python yade test.py", I face the error "Segmentation fault (core dumped)".

test.py contains the following:

from yade import pack, plot
import matlab.engine
matlab.engine.start_matlab()

Has anyone had the same problem?

Thanks in advance,

Regards

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#1

Dear Poyan,
There can be many reasons for such a segfault unfortunately.
I have absolutely no experience with interfacing matlab and python.
BUT, your test script suggests a library problem I think. Random ideas:

1. is it possible to reproduce the segfault _without_ yade, by importing the most obvious python dependencies of yade: matplotlib, numpy, ... such things.

2. could it be that matlab ships its own version of libraries like cholmod or lapack (I wouldn't be surprised, and then segfault because the same library has two versions)?

3. could you try the same thing with a debug build of yade? a debug build of matlab? At least you would know where the crash comes from.

4. possible workaround: instead of starting yade as a program, start python and import yade (so you can e.g. load matlab first, then yade). All you need to do that is to create a symlink to yade executable that you'll name *.py. See an example here [1].

I hope it helps.

Bruno

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#2

Oh wait, what is this?
> "python yade test.py"

This is not a possible yade invocation.
Choose between python and yade (as explained in point 4), not both.

B

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#3

Can you help with this problem?

Provide an answer of your own, or ask Pouyan for more information if necessary.

To post a message you must log in.