-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add new features to class Body
#21689
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
Conversation
✅ 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:
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.
Update The release notes on the wiki have been updated. |
sympy/physics/mechanics/body.py
Outdated
@@ -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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
The |
LGTM! Thanks. |
References to other Issues or PRs
Brief description of what is fixed or changed
Other comments
Release Notes
masscenter_vel()
to classBody
to calculate velocity of one body's masscenter wrt other body's frame.ang_vel_in()
to classBody
to calculate angular velocity of one body's frame wrt other body's frame.dcm()
to class Body to calculate dcm of one body's frame wrt other body's frame.