GSoC 2012 post 5
This has been a very interesting week for me. I have learned a lot more about the intricacies of Python and how sympy.physics.mechanics has been written. I should admit that as an engineer, my programming background isn’t as strong as that of others so maybe I’m not asking the right questions. But I’m also with several questions after writing my first ‘formal’ code.
I have opened a pull request with my functions for angular momenta for both particles and rigid body. I don’t intend to go into the details of the mechanics of it but one thing that I have asked myself upon writing my first set of code is whether it is useful in and of itself. I’m not convinced about it being the best implementation. The code definitely spits out the (linear or angular) momentum of any individual component of a system but I haven’t found a suitable way to determine the momentum of an entire system that may compromise a multi-body system i.e. one that has more than one kind of object, in this case ‘Particles’ and ‘RigidBodies’. I believe it is fairly trivial to deal with just one of these object types when they comprise a system but it’s a lot more intriguing to think about how to incorporate a system with multiple objects. The way I’m thinking of it right now is that ‘Particles’ and ‘RigidBodies’ must be derived classes of a more general class, somethig like ‘class System(object):’ with the rest of the code following that. But I also feel, at the same time, that I’m not approaching this problem the right way. I gave myself a couple days to figure this out and I was really hoping that I could figure this out on my own but I guess I will need more guidance on this issue. This has also made me question the simple code that I have to determine the energies, kinetic and potential, of either system. It is useful as it stands for individual components of multibody systems as it is trivial to have a method to determine either energy of a particle or a rigid body but adding this functionality keeping in mind that it has to be used to determine the Lagrangian of a more complex multibody system is also proving to be a bit of barrier. I’m uncertain but I feel that the answer to this also lies in what I have spoken about prior- the issues with angualr momentum of a system.
This has been primarily what has dominated my time since I have worked on my momenta functions.
In terms of tangibles, I have the momenta code up and running. I have also tested the better checking methods for vectors and dyadics as per PR 1269. (Note- That particular pull request has proven to be extremely crucial to my work. When angular momentum vector of a rigid body is to be found about the mass center, the generic formula for angular momentum that I implemented in ‘mechanics’ falls apart because in the math that follows, a cross product between a zero vector and a non zero vector needs to be performed. It turns out that the methods currently available in ‘mechanics’ aren’t up to task to cope with this (even though cross products between a vector and a zero vector are performed correctly.)) After having spent almost 2 days trying to examine why this generic formula wasn’t working, I ended up writing some patchy code with some conditional statements for the angular momentum to work with the current setup. After this I went through Gilbert’s updated code (PR 1269) and saw that it handles the math being performed in my angular momentum function perfectly. I hope that both that PR and mine get merged in that order. And as I am also waiting on that merge, I have been furhter examining the pydy.org website. I have jotted down several recommendations that I have to make for that page. This will prove to be important because that is the page that students in UC Davis use to learn sympy.physics,mechanics. As this has already turned into a bit of a prosaic blog post, I shall end this here. But, yes this has been a long week and a lot has been learned and I’m pretty satisfied with what I’ve learned and am even more invigorated for all that is in store in the coming weeks.