This has actually been discussed quite a bit before (a lot of people want to use Lagrangians). You can search the mailing list. From what I've seen, you will either have to write your own custom diff routine or do clever substitution of functions and derivatives with symbols. I don't think I've ever seen anyone suggest extending Symbol to hold a time derivative, which is essentially just a more formal way of doing the substation method. It might work.
Aaron Meurer On Jun 3, 2011, at 6:05 PM, Gilbert Gede wrote: > Hi, > I was trying to implement some functionality for PyDy for this year's GSoC, > and was looking for some advice. > In dynamics problems, you usually have time-varying quantities, like > generalized coordinates, speeds, and accelerations. Often, you want to take > the partial derivative of an expression with respect to the time derivative > of one of these quantities. This come up when using Lagrange's Method (or > Kane's Method). It's described to some degree here: > http://en.wikipedia.org/wiki/Lagrangian_mechanics > https://gist.github.com/1005937 > In Lagrange's Method, you end up taking the partial derivative of the energy > with respect to the time derivative of a generalized coordinate. I'm trying > to figure out a way to make this work in PyDy/SymPy. Derivative won't take in > anything but a Symbol. > The only idea I have come up with is to extend Symbol and write my own > .diff() method for it which returns a new symbol representing the time > differentiation of the original extended Symbol. Once my new object is > inside a Mul or Add sympy object, then my .diff() method is no longer called. > > Can anyone give some insight into how I could get this desired behavior, > taking the derivative of an expression wrt a time-differentiated symbol, to > work in a way consistent with existing SymPy behavior? Thanks. > > -Gilbert > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sympy@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.