Using the mechanics API

49 views
Skip to first unread message

Oscar Benjamin

unread,
May 13, 2019, 4:42:46 PM5/13/19
to sympy
Hi all,

I haven't really looked much at SymPy's mechanics module even though
mechanics is very much one of my interests and something that I like
to think I know a bit about. Today I finally took a look at it and I
found the whole API surprisingly complicated. I teach mechanics to
undergraduate students but I'm not sure if I would know how to teach
my students to use the mechanics module as it is now...

Firstly I looked through the documentation here:
https://docs.sympy.org/latest/modules/physics/mechanics/index.html
Is there any other guide/documentation that explains the general ideas
more simply with examples?

Suppose that I want to think about a simple 2D problem with a disc
rolling down a surface inclined at angle beta with (Coulomb) friction
coefficient mu. I want to know when/whether the disc will stick or
slip and get the equations of motion for each case. How would I go
about doing that using the mechanics module?

--
Oscar

Vishesh Mangla

unread,
May 13, 2019, 4:48:27 PM5/13/19
to sy...@googlegroups.com

Hey,I also love physics and math and would like to work on the changes which you want to include.Can I get included in this?I ‘ve chemistry as my subject in university but that too deals with a lot of physics Hermitian mostly but I know lagrangian too.So please let me make it. If you remember you helped me merge my first pull request but still one was not enough to get me enough experience to get good with it and I require help to get a few more merged.

 

Sent from Mail for Windows 10

--

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 sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.

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/CAHVvXxQXtAd_HGwTqaKrpDqQC_mNcyZAFgPrVe8Sq_hPwT6H0w%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

 

Jason Moore

unread,
May 14, 2019, 11:59:44 AM5/14/19
to sympy
Oscar,

There are some rolling disc examples here: https://github.com/pydy/pydy/tree/master/examples Note that the PyDy project started as an independent thing build on top of SymPy, then the symbolics were merged into sympy as the mechanic module and the numerics are now in the standalone PyDy package.

Also, I teach an entire graduate class using the module that include 20+ lecture videos and accompanying notebooks: https://moorepants.github.io/mae223/

There are also several scipy/pycon tutorials on the package:


The module may be complicated, but that may just reflect that 3D multibody rigid body mechanics is complicated. We've worked on some layers on top of the core code that have been merged or are in open PRs to help provide simpler interfaces that give a way to "assemble" bodies as you would in reality (with joints, etc) but it is still not polished for production. I could imagine a layer that makes it simpler to do 2D mechanics too, among other things.

I'll be working on things this summer because I am teaching the aforementioned course in the fall. Feel free to open issues for discussion on improvements.

Jason

Jason Moore

unread,
May 14, 2019, 1:32:31 PM5/14/19
to sympy
Oscar,

Also a specific answer to:

> Suppose that I want to think about a simple 2D problem with a disc
rolling down a surface inclined at angle beta with (Coulomb) friction
coefficient mu. I want to know when/whether the disc will stick or
slip and get the equations of motion for each case. How would I go
about doing that using the mechanics module?

This is way too simple of a problem to really use the mechanics module for. If I were teaching this I would just use the base sympy features to do the math. The mechanics module is not really geared towards things you find in introductory mechanics in physics and dynamics courses. It is geared toward dynamics of multibodies, 2D and 3D. Most schools teach this at the graduate level or some advanced upper level courses in engineering and physics.

I have another package called "resonance" that is aligned more for 2D dynamics and simulation. I do teach the students to derive equations of motion symbolically with sympy and use the resonance interface to do the simulation and analysis. This is here: https://github.com/moorepants/resonance/

Jason

Oscar Benjamin

unread,
May 14, 2019, 6:00:14 PM5/14/19
to sympy
Thanks Jason. Those links helped.

I guess if the module is not intended for simpler problems then that
makes sense. I would say though that the documentation could benefit
from more of a tutorial somewhere.

I'll try to use it for a real problem at some point and then see what I think...

--
Oscar
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AgY%3Dcq3q9DCAYk_0-4qV8rhoVZTTJp7WJku8A%2BX2%3Df_Mg%40mail.gmail.com.

Jason Moore

unread,
May 14, 2019, 6:10:38 PM5/14/19
to sympy

Oscar Benjamin

unread,
May 14, 2019, 7:29:50 PM5/14/19
to sympy
Hi Vishesh,

I have no plans to work on anything here but of course you can feel
free to contribute. Take a look at the module and see if there is
something that you think can be improved. There's always something
that can be improved so it's just a question of finding something that
is worth doing and that you can do yourself.

--
Oscar
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/5cd9d817.1c69fb81.1bcd0.8bad%40mx.google.com.

Vishesh Mangla

unread,
May 14, 2019, 9:02:57 PM5/14/19
to sy...@googlegroups.com
Ok but still if you get a specific requirement do let me know.

Peter Stahlecker

unread,
Jun 16, 2021, 5:52:23 AM6/16/21
to sympy
I have a question concerning the example 'rolling disc' in sympy- physics.mechanics.
It seems to me, this is really a pendulum totation around the fixed contact pount C. I understand that rolling means: contact point has zero speed in N, but unclear to me how to get from the 'pendulum to the rolling disc.
When I integrate the example numerically, it seems to confirm my feel that this is really a pendulum
Thanks for any help!




a


I have a que

Jason Moore

unread,
Jun 16, 2021, 7:05:46 AM6/16/21
to sympy
Peter,

If you add the differential equations that describe the yaw rate, longitudinal rate, and lateral rate to the equations found in this example, then you can solve for the complete motion. The coordinates associated with those equations are ignorable (from the dynamics perspective).

Jason

Peter Stahlecker

unread,
Jun 16, 2021, 7:42:38 AM6/16/21
to sy...@googlegroups.com
Dear Jason,

Thanks!!
I will try this right away.

Best regards,

Peter

--
Best regards,

Peter Stahlecker
Reply all
Reply to author
Forward
0 new messages