> The use case for generating the sympy model from the Modelica model is that you can use sympy to convert it into state space format, solve the ode etc, and then linearize the model etc. analytically. I'm a developer of the PX4 autopilot, and I hate doing a bunch of Jacobians for estimators by hand. I added an example of going from a Modelica model to a bode plot via sympy on the spring notebook.
Ok, this makes sense. If the modelica libs don't provide ways to take derivatives I can see how this is useful. Thanks for the explanation. Jason moorepants.info +01 530-601-9791 On Tue, Apr 26, 2016 at 6:56 PM, James Goppert <[email protected]> wrote: > Hi Jason, > > Thanks for you interest: > > I think Modelica is a nicer format for the core mathematical model of > dynamic systems since it is made for mathematical modeling of dynamic > systems. With the object oriented nature/ inheritance etc. you can describe > very complicated systems with Modelica, which would look pretty ugly in > sympy. Also, you are guaranteed from the Modelica language that this all > maps back into a clean differential algebraic equation, unlike creating a > model in python/ c++ etc. My motivation is mathematical modelling > multi-rotors/ planes etc. I am very familiar with the sympy mechanics > toolbox as well, but I think the Modelica approach also has advantages over > that due to easy component reuse etc/ classes etc as mentioned above. > > I have tried to use JModelica, but I am on Ubuntu linux and despite my > experience have failed to get everything running each time. Also, > OpenModelica exists, but their compiler for OpenModelica is actually their > core research and I find the compiler very hard to hack, in addition to the > fact that their license isn't very friendly. I'm releasing this as BSD and > you can get it running with just "pip install pymola". Which is 10x easier > than any other Modelica compiler since it is pure python. > > The use case for generating the sympy model from the Modelica model is > that you can use sympy to convert it into state space format, solve the ode > etc, and then linearize the model etc. analytically. I'm a developer of the > PX4 autopilot, and I hate doing a bunch of Jacobians for estimators by > hand. I added an example of going from a Modelica model to a bode plot via > sympy on the spring notebook. > > For code generation I do plan to just use my AST and jinja2. Sympy is just > for the symbolic math. > > -James > > > > On Tuesday, April 26, 2016 at 6:22:27 PM UTC-4, Jason Moore wrote: >> >> This is cool stuff. I'd always imagined outputting modelica models from >> sympy instead of the other way around. Aren't there already a lot of >> software packages that take modelica models as input for various numerical >> analyses purposes? For multi-body dynamics models, constructing the model >> and generating the correct differential algebraic equations is the hard >> part. It'd be nice to pass these off to modelica based tools. Doesn't >> JModelica offer all the simulation side of things? I thought it generated >> code from modelica models and is Python based. >> >> What is the use case for converting a pre-generated modelica model into >> sympy symbolics? Why not generate code, your #2, directly from modelica >> model code? >> >> >> Jason >> moorepants.info >> +01 530-601-9791 >> >> On Tue, Apr 26, 2016 at 2:55 PM, James Goppert <[email protected]> >> wrote: >> >>> I'm working on a Modelica compiler written in pure python that outputs a >>> sympy model. Please let me know if anyone is interested in contributing. >>> >>> Please see the jupyter notebook below for a quick overview of the >>> current capabilities: >>> >>> https://github.com/jgoppert/pymola/blob/master/test/Spring.ipynb >>> >>> The useful thing about the modelica language is that it can all be >>> mapped into one differential algebraic equation, that can be represented in >>> certain cases well in sympy. >>> >>> This allows one model in Modelica to be used to generate: >>> 1. Sympy models for mathematical analysis/ simulation. >>> 2. C/C++ code for embedded controllers/ estimators (to be done). >>> 3. Whatever else you can dream up. >>> >>> The compiler is very hack-able. I'm using jinja 2 for rendering the AST. >>> I'm using antlr4 python runtime to robustly construct the AST. >>> >>> I really need some good python programmers to help me get to the point >>> that the compiler can handle more language constructs and parse the entire >>> Modelica standard library. >>> This will enable use of many pre-written modelica models that handle >>> multi-body mechanics, control blocks, and many other. >>> https://github.com/modelica/Modelica >>> >>> Feel free to contact me if you are interested: >>> [email protected] >>> https://github.com/jgoppert/pymola >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "sympy" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/sympy. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/sympy/f7c7d0e7-7d87-4ab4-8135-25d94e3664f2%40googlegroups.com >>> <https://groups.google.com/d/msgid/sympy/f7c7d0e7-7d87-4ab4-8135-25d94e3664f2%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/6ae27fb9-01f9-4176-916d-2f82886cfaf9%40googlegroups.com > <https://groups.google.com/d/msgid/sympy/6ae27fb9-01f9-4176-916d-2f82886cfaf9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1Ag8aeGXVm1WGmLp7DeEQPscE0tghqzNZ49KBg7bi-rg2g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
