Luke Peterson from UC Davis came to visit me in Reno and we spent the last weekend hacking on the Python Dynamics package that uses SymPy to calculate equations of motion for basically any rigid body system.

On Friday we did some preliminary work, mostly on the paper, Luke showed me his rolling torus demo that he did with the proprietary autolev package. We set ourselves a goal to get this implemented in SymPy by the time Luke leaves and then we went to the Atlantis casino together with my boss Pavel and other guys from the Desert Research Institute and I had my favourite meal here, a big burger, fries and a beer.

On Saturday we started to code and had couple lines of the autolev torus script working. Then we went on the bike ride from Reno to California. I took some pictures with Luke's iphone:

Those mountains are in California and we went roughly to the snow line level and back:

This is Nevada side:

That was fun. Then we worked hard and by the evening we had a dot product and a cross product working, so we went to an Irish pub to have couple beers and I had my burger as usual.

On Sunday we spent the whole day and evening coding and we got the equations of motion working. On Monday we worked very hard again:

and fixed some remaining nasty bugs. I taught Luke to use git, so our code is at: http://github.com/hazelnusse/pydy, for the time being we call it pydy and after we polish everything, we'll probably put it into sympy/physics/pydy.py. If you run rollingtorus.py, you get this plot of the trajectory of the torus in a plane:

It's basically if you throw a coin on the table, e.g. this model takes into account moments of inertia, yaw (heading), lean, spin and the x-y motion in the plane. Depending on the initial conditions, you can get many different trajectories, e.g for example:

or:

This is very exciting, as the code is very short, and most of the things that Luke needs are needed for all the other applications of sympy, e.g. a good printing of equations and vectors (both in the terminal and in latex), C code generation, fast handling of expressions, nice ipython terminal for experimentation, plotting, etc.

Together with the atomic physics package that we started to develop with Brian sympy will soon be able to cover some basic areas of physics. Other areas are general relativity (there is some preliminary code in examples/advanced/relativity.py) and quantum field theory and Feynman diagrams - for that we need someone enthusiastic that needs this for his/her research --- if you are interested, drop me an email, you can come to Reno (or work remotely) and we can get it done.

My vision is that sympy should be able to handle all areas of physics, e.g. it needs good assumptions (if you want to help out, please help us test Fabian's patches here), then faster core, we have a pretty good optional Cython core here, so we'll be merging it after the new assumptions are in place. Then sympy should have basic modules for most areas in physics so that one can get started really quickly. From our experience so far in sympy/physics, those modules will not be big, as most of the functionality is not module specific.

Subscribe to:
Post Comments (Atom)

## 6 comments:

Looks like great riding :-)

What are the pros and cons of a Python Dynamics built on SymPy vs. using a common physics engine such as Bullet or ODE? Are the use cases that different?

Tom,

The main goal of our project is to develop a tool that helps one derive the equations of motion for a mechanical system, in analytical form. It is more geared to analyst that wants to study the stability of a dynamic system, run numerical simulations or design feedback controllers to meet some control objective. While visualization is a definite goal, our project seeks to transparently show how the equations of motion are derived and what they actually are.

It seems to me that Bullet and ODE are more geared towards visualization for creation of games and less about the study of the underlying equations. Although I haven't used either Bullet or ODE, this is my impression from looking at their website. Our project would align more closely with what would be taught in undergraduate/graduate mechanical engineering multibody dynamics courses, and could be used as a tool to learn dynamics.

Hope this helps.

Thanks for the reply.

Just learned that Blogger remembers the user's picture at the time of posting ...

Let me comment this:

" The main goal of our project is to develop a tool that helps one derive the equations of motion for a mechanical system, in analytical form. It is more geared to analyst that wants to study the stability of a dynamic system, run numerical simulations or design feedback controllers to meet some control objective. "

I find this ABSOLUTELY AWESOME!! It's what I would personally love to have (as most of the engineers I know), and I strongly encourage to keep this direction. I am personally trying to push SAGE people to pursue some physics analysis, so I will be glad to keep using sympy from there to accomplish my task

Regards

Maurizio

Post a Comment