CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Example of an Autolev output test #15165
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 (v130). 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.2.1. 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.
Update The release notes on the wiki have been updated. |
|
||
p_o_e = l['point_o'].pos_from(l['point_e']).express(l['frame_d']) | ||
v_e_f = l['point_e'].vel(l['frame_f']).express(l['frame_d']) | ||
a_e_f = l['point_e'].acc(l['frame_f']).express(l['frame_d']) |
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 parser set these values but didn't call express. Shouldn't it call express and reassign the values?
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.
Nevermind, this is done in the parser.
@moorepants Did you have a look at the output comparisons of the examples in the GitLab repo? |
Here is the code the parser produced: import sympy.physics.mechanics as me
import sympy as sm
import math as m
import numpy as np
frame_c=me.ReferenceFrame('c')
frame_d=me.ReferenceFrame('d')
frame_f=me.ReferenceFrame('f')
fd, dc = me.dynamicsymbols('fd dc')
fdd, dcd = me.dynamicsymbols('fd dc', 1)
fdd2, dcd2 = me.dynamicsymbols('fd dc', 2)
r, l=sm.symbols('r l', real=True)
point_o=me.Point('o')
point_e=me.Point('e')
frame_d.orient(frame_f, 'Axis', [fd, frame_f.x])
frame_c.orient(frame_d, 'Axis', [dc, frame_d.y])
point_e.set_pos(point_o, r*frame_d.y-l*frame_c.x)
point_e.set_pos(point_o, (point_e.pos_from(point_o)).express(frame_d))
point_e.set_vel(frame_f, ((point_e.pos_from(point_o)).dt(frame_f)).express(frame_d))
point_e.set_acc(frame_f, ((point_e.vel(frame_f)).dt(frame_f)).express(frame_d)) I think the correct code should be: # Note that Autolev users could name variables "sm" and "me", so these could get clobbered.
import sympy as sm
import sympy.physics.mechanics as me
# Don't import math (ever!) and don't import numpy if not needed.
frame_c = me.ReferenceFrame('c')
frame_d = me.ReferenceFrame('d')
frame_f = me.ReferenceFrame('f')
fd, dc = me.dynamicsymbols('fd, dc')
# Use _d for dot and _dd for double dot, etc.
fd_d, dc_d = me.dynamicsymbols('fd, dc', 1)
fd_dd, dc_dd = me.dynamicsymbols('fd, dc', 2)
r, l = sm.symbols('r l', real=True)
point_o = me.Point('o')
point_e = me.Point('e')
# Need to check whether the correct DCMs are generated. Is this F wrt to D or D wrt F? I always forget.
frame_d.orient(frame_f, 'Axis', (fd, frame_f.x))
frame_c.orient(frame_d, 'Axis', (dc, frame_d.y))
point_o.set_pos(point_e, r*frame_d.y - l*frame_c.x)
point_o.set_pos(point_e, point_o.pos_from(point_e).express(frame_d))
point_e.set_vel(frame_f, point_e.pos_from(point_o).dt(frame_f).express(frame_d))
point_e.set_acc(frame_f, point_e.vel(frame_f).df(frame_f).express(frame_d)) |
No, I don't recall being told about them. |
@moorepants I had added output comparisons to some of the examples in the GitLab repo. They aren't very detailed though. In many cases, I have just shown the equivalence (I have only included comments in the example files) of the final eoms.
|
I am not able to find output examples in the Gitlab repo. Can you point me specifically to one (or them)? |
@moorepants I had just put the comparisons (mainly comments) at the end of the example files. |
I see. Ideally we encode them as I've done in this PR, as also ideally have as much as we can in the SymPy repo. Note that on my first one I seemingly uncovered an error(s) in the parser output. |
@moorepants |
Also fixed the position vector error observed in sympy#15165.
5c8f1ab
to
ab2f97d
Compare
Note that the P_O_E> parsed output is still incorrect. |
@moorepants Now that I took another look at the position vectors, I think the parser does it the right way.
|
ab2f97d
to
5778aee
Compare
|
||
g = {} | ||
l = {} | ||
exec(sympy_input, g, l) |
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.
Is this the best way to do this? I know that having exec()
s around aren't necessarily good, but I couldn't think of another way to do this.
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.
Not sure of another way either.
@asmeurer
In the doctest builds I'm getting:
Not quite sure what that is. |
@moorepants I placed the current test file |
This is ready for final review and merge. |
@NikhilPappu Would you mind reviewing this? |
@moorepants It looks great to me! |
These should also have |
@NikhilPappu I updated this thing in code but I am not able to run skipped tests on my local machine.The following code in
Sorry for messing things up again and again. |
The changed one is just to update the existing test files. It will
obviously pass as it isn't testing anything. The changes should be reverted
after running the second one. Can you post the Assertion errors here?
…On Fri 7 Sep, 2018, 9:23 PM Ayushman Koul, ***@***.***> wrote:
@NikhilPappu <https://github.com/NikhilPappu> I updated this thing in
code but I am not able to run skipped tests on my local machine.The
following code in test_autolev.py is causing assertion errors:
[image: assertionerror]
<https://user-images.githubusercontent.com/22992482/45229568-cbb8b400-b2e3-11e8-8d8b-fa6f6dc9ea4b.PNG>
Whereas on altering the above code as following yields no assertion error
on local machine:
[image: noerror]
<https://user-images.githubusercontent.com/22992482/45229675-25b97980-b2e4-11e8-9a96-93f0e8407b6f.PNG>
Sorry for messing things up again and again.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15165 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFGWJ6teaeA5Vl-9OjNCYvWmrHlQWfM5ks5uYpaWgaJpZM4WSHbL>
.
|
It'd be best to move this discussion to the respective issue or PR. |
References to other Issues or PRs
Based on #15006.
Brief description of what is fixed or changed
This is an example test that ensures the sympy code generated from the autolev parser generates the same output as the autolev code.
@NikhilPappu This is what I'm imagining for output verification tests. Let me know what you think. We should implement some of these for the more complicated examples you have (at least). I'd really like to see this kind of test for all the examples (in addition or instead of the current text comparison tests).
Other comments
Note that the position vector test doesn't pass. I think the parser outputs an incorrect result.
Release Notes