Skip to content

Conversation

sidhu1012
Copy link
Contributor

@sidhu1012 sidhu1012 commented Jun 30, 2021

References to other Issues or PRs

Brief description of what is fixed or changed

Other comments

Release Notes

  • physics.mechanics
    • Add masscenter_vel() to class Body to calculate velocity of one body's masscenter wrt other body's frame.
    • Add ang_vel_in() to class Body to calculate angular velocity of one body's frame wrt other body's frame.
    • Add dcm() to class Body to calculate dcm of one body's frame wrt other body's frame.

@sympy-bot
Copy link

sympy-bot commented Jun 30, 2021

Hi, I am the SymPy bot (v161). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • physics.mechanics
    • Add masscenter_vel() to class Body to calculate velocity of one body's masscenter wrt other body's frame. (#21689 by @sidhu1012)

    • Add ang_vel_in() to class Body to calculate angular velocity of one body's frame wrt other body's frame. (#21689 by @sidhu1012)

    • Add dcm() to class Body to calculate dcm of one body's frame wrt other body's frame. (#21689 by @sidhu1012)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.9.

Click here to see the pull request description that was parsed.
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->


#### Brief description of what is fixed or changed


#### Other comments


#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* physics.mechanics
    * Add `masscenter_vel()` to class `Body` to calculate velocity of one body's masscenter wrt other body's frame. 
    * Add `ang_vel_in()` to class `Body` to calculate angular velocity of one body's frame wrt other body's frame. 
    * Add `dcm()` to class Body to calculate dcm of one body's frame wrt other body's frame.
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@sidhu1012 sidhu1012 requested a review from moorepants as a code owner June 30, 2021 06:14
@@ -214,3 +214,64 @@ def apply_torque(self, vec):
if not isinstance(vec, Vector):
raise TypeError("A Vector must be supplied to add torque.")
self.loads.append((self.frame, vec))

def vel(self, body=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mass center does not move wrt to its body's frame, so you always need another body or frame here. I think you should accept a Body or a ReferenceFrame. Also a body can have an infinite number of points, so there are an infinite number of velocities. This should probably be named masscenter_vel() to be explicit about that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to think whether we will every store other points on in a Body object other than the mass center. If we wouldn't then sticking with vel() as the name is ok. I'll think a bit about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to think whether we will every store other points on in a Body object other than the mass center. If we wouldn't then sticking with vel() as the name is ok. I'll think a bit about it.

Current implementation stores masscenter only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that. But I'm trying to imagine the future. A body has an infinite number of points and some of those are important for any giving multi-body model. The first that comes to mind is locations that forces are applied on the body. But that only makes sense if we store forces in bodies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Body.loads does store point, force tuple.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so there is already a .loads attribute. That's interesting. More thought needs to go into this, especially since forces/torques have to ensure equal and opposite behavior.

Copy link
Contributor Author

@sidhu1012 sidhu1012 Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moorepants Yes, I think it would make applying forces and torques a bit easier.

class Forces:
    pass

F = Force(Body1, Body2)

Forces acting on Body1 can be +ve, and equal and opposite on Body 2, and can append the .loads and .torque of respective bodies. There is just one things that is tough is , to apply force on point other than masscenter, as we may need to take multiple parameters in Force for each body something like-
F = Forces(Body1, Body1_point=None, Body2, Body2_point=None)
where Body_point is the point on each body on which force is applied, which is masscenter by default.

Now problem 2 is gravity, as it should be wrt Newtonian frame, so shal we do something like-
F = Forces(body1, body1_point=None, body2, body2_point=None, gravity=Frame/Body/None)
If gravity is None then gravity is not applied, else a frame/Body should be supplied in which gravity is applied.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to special case a constant gravitational field. You'd simple do Force(Body1, Body1, g*Body1.x) where Body1 is the newtonian frame. You have to do it for all bodies, but we can think of ways to ease things if you have lots of bodies to apply it to.

We should open a new issue or discussion for this topic, to try to work out the design.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, have some example problems that show how the api will be used on a real problem is essential.

@sidhu1012 sidhu1012 requested a review from moorepants June 30, 2021 08:55
@moorepants
Copy link
Member

The Body object should actually have all the methods and attributes of a ReferenceFrame and have all the methods and attributes of a Point (but with masscenter_ prepended to the methods/attributes names. We can start with these though.

@sidhu1012 sidhu1012 requested a review from moorepants July 1, 2021 05:27
@moorepants
Copy link
Member

LGTM! Thanks.

@moorepants moorepants merged commit b061e63 into sympy:master Jul 1, 2021
@sidhu1012 sidhu1012 deleted the body branch July 1, 2021 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants