Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an abstract base class for the mechanics *Method classes and create a commit set of attributes & methods #21772

Open
moorepants opened this issue Jul 23, 2021 · 5 comments

Comments

@moorepants
Copy link
Member

moorepants commented Jul 23, 2021

We currently have KanesMethod, LagrangesMethod, and very soon JointMethod. JointMethod is unique in that it will use KanesMethod or LagrangesMethod internally, but, even so, it would be helpful if all three of these methods had some common attributes and methods so that duck typing can work well and there is consistency among the methods.

Some reasons making these more consistent will be helpful:

  1. JointMethod(..., method=KanesMethod|LagrangesMethod|OtherNewMethods): JointMethod should be able to use a number of other Method classes to actually formulate the equations of motion. JointMethod simple collects the joints and bodies then passes the correct information to the internal methods. Being able to pass in these and future methods to JointMethod would give a clean, simple API.
  2. pydy.system.System currently consumes KanesMethod in its constructor. It should be able to consume any *Method object and also the SymbolicSystem object (https://github.com/sympy/sympy/blob/master/sympy/physics/mechanics/system.py).
  3. The idea for SymbolicSystem was/is that each method object could produce the SymbolicSystem, e.g. KanesMethod.export_symbolic_system(). The symbolic system is supposed to be the most general container that can describe any symbolic multibody system. If that works, then pydy.system.System() could consume it instead of (or in addition) to the *Methods classes.
  4. There are many more *Methods classes that could be created, e.g. HamiltonsMethod, TMTMethod, NewtonEulerMethod, etc. So having a common class to build them from is helpful.

Key things that Method() should likley have:

  • coordinates
  • speeds (if not the time derivative of coordinates)
  • mass matrix, M of M*u' = F
  • forcing equations, F of M*u' = F
  • algebraic constraint equations
  • equations for constraint forces (explicit or Lagrange multiplier eqs).
  • kinematic different equations (if not q' = u)
  • form_equations_of_motion() method, as this is such a time consuming step we have this explicit method for the Methods classes.
  • maybe more
@moorepants
Copy link
Member Author

@sidhu1012 I've opened this to work out how to unify the *Methods classes. It's worth thinking about this a bit before merging #21759 because we could make JointsMethod conform to a new standard.

@sidhu1012
Copy link
Contributor

@moorepants LagrangesMethod, JointsMethod and KanesMethod all have the major required attributes.

@moorepants
Copy link
Member Author

@moorepants LagrangesMethod, JointsMethod and KanesMethod all have the major required attributes.

I don't' know what that means.

@sidhu1012
Copy link
Contributor

LagrangesMethod , KanesMethod and JointsMethod all have mass_matrix, forcing, mass_matrix_full and forcing_full attributes.

@sidhu1012
Copy link
Contributor

The __init()__ kwargs are way too different between KanesMethod and LagrangesMethod, irrespective of denoting the same thing.

Also the Lagrangian for LagranesMethod should be calculated automatically rather than passing it as first argument in init.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants