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
Function to return Total Energy in physics/mechanics #16202
Conversation
✅ Hi, I am the SymPy bot (v145). 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.5. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
|
…ticle.py and better comment in rigidbody.py for total_energy
Codecov Report
@@ Coverage Diff @@
## master #16202 +/- ##
=============================================
+ Coverage 73.596% 73.719% +0.123%
=============================================
Files 618 619 +1
Lines 158481 158455 -26
Branches 37187 37134 -53
=============================================
+ Hits 116636 116813 +177
+ Misses 36417 36219 -198
+ Partials 5428 5423 -5 |
Also I had the same doubt but it is due to the function which calculates the |
I have added new functions |
I do not know much about the physics module so there are others who are more suitable to review the functionality. |
please add release notes, too |
Thank you for your reply @smichr. Also what exactly do I have to write in release notes? |
👓 See this for more information |
@smichr I have added release notes, please reivew them. Regards. |
I think something like: would do. |
@oscargus could you guide me what has to be done to complete this PR? |
>>> B.total_energy(N) | ||
M*g*h + M*v**2/2 + omega**2/2 | ||
""" | ||
return self.kinetic_energy(frame) + self.potential_energy |
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.
This should raise an error if potential energy is not defined.
g*h*m + m*v**2/2 | ||
|
||
""" | ||
return self.kinetic_energy(frame) + self.potential_energy |
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.
Should raise an error if potential_energy is not defined.
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.
At present, potential_energy for a body for which potential_energy is not explicitly defined is taken as zero. I think this makes sense. What do you think 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.
It is a bit misleading. If I type "total_energy" I'm expecting to get KE + PE, but if PE is zero by default I'm not getting any PE contribution. I feel like it would be best to inform the user that they aren't getting what they ask for. Maybe a warning message that tells the user that PE is zero and not set is sufficient.
This looks useful, I've provided some comments. |
@moorepants please review the changes. |
If you add warnings when PE is zero for the total_energy functions then it LGTM. |
@moorepants I was trying to complete this PR. I have the following
Therefore, in both cases when |
@ritesh99rakesh Would you like to complete this PR? |
IMO, |
Closed in favour of #18838 |
Fixes #16201
Brief description of what is fixed or changed
At present, we have function to get the kinetic energy and potential energy of rigid body, but we do not have any function to give the total energy of the rigid body. This PR adds a function under
sympy/physics/mechanics/rigidbody.py
to return the total energy of the body.I have defined total_energy = kinetic_energy + potential_energy
Other comments
Please review it and comment your suggestions.
Release Notes