3

I recently found the paper "MAKING MODELICA MODELS AVAILABLE FOR ANALYSIS IN PYTHON CONTROL SYSTEMS LIBRARY" explaining how to use JModelica in combination with CasADi to get linearized models in Python. This is exactly what I am looking for, but apparently the paper is from 2014 and JModelica 1.12 is used. The described approach is deprecated and used functions are not available anymore.

The documentation of JModelica is very limited regarding this topic and I have no idea how to accomplish the described task using the latest version of JModelica. The class CasadiModel is not used anymore and the function compile_fmux throws a compilation error.

My final goal involves the modeling of (nonlinear) systems in Modelica. I need a symbolic representation of this model to perform the linearization myself. The linearized model is then used to design a controller in Python.

Does anyone have a suggestion?

Yannick
  • 177
  • 1
  • 10

1 Answers1

1

Yes, casadiModelObject = CasadiModel('FourTanks.fmux')" causes error.

as the warning says,

DeprecationWarning: CasadiModel is obsolete. The CasadiPseudoSpectralAlg and LocalDAECollocationAlgOld are no longer supported. To solve an optimization problem with CasADi use pyjmi.transfer_optimization_problem instead

So try somethig like this,

from pyjmi import transfer_optimization_problem
op = transfer_optimization_problem('TankSystems.FourTanks','fourTank.mop',
                                  accept_model=True)

then type

op

you will find the flattend object

miki
  • 11
  • 1
  • Thank you, this actually works. Sadly, I am not very familiar with CasADi and hoped to orientate myself towards the article mentioned in my question. I don't know how to continue with the `op` object. – Yannick Sep 13 '18 at 12:31