Dealing with vectors (fields in particular)

32 views
Skip to first unread message

Cavendish McKay

unread,
Sep 28, 2017, 8:34:20 AM9/28/17
to sympy
Hello,

I'm using sympy in my upper level undergraduate physics courses, and of course the subject of how to deal with vectors has come up. As far as I can tell, there are three fairly reasonable approaches at the moment:

1. use 1 x n or n x 1 matrices. Simple vector operations work fine, but vector calculus requires some additional work on the part of the end user.

2. use the physics.mechanics.vector module. We get vector calculus, but this doesn't support curvilinear coordinates, and there's a bug in the pretty printer (printing iterables of vectors raises an exception; if this isn't a known issue, I'd be happy to open an issue on GitHub). Since we spend a lot of time in spherical and cylindrical coordinates when doing electricity and magnetism (the course I'm currently teaching), the lack of curvilinear coordinates is a blow.

3. use the vector module. In the 1.1.1 release, curvilinear coordinates are not officially supported, but can be made to work using private methods (although one of the Lame coefficients for cylindrical coordinates is wrong, and I haven't checked to see if this is fixed in the current master). The pretty-printer for this module doesn't have the same bug as the physics.mechanics.vector module, but the labeling scheme is significantly less flexible, and the defaults violate standard typographical convention by making the base scalars bold face.

None of these is perfect, but my current favorite is (3). If I understand correctly, this was a GSoC project. What is its current status? Is the vector module going to be the right way to do vector fields going forward? 

I'm happy to contribute, if that would be helpful, but I don't want to step on anyone's toes, and if there's already a clear vision/roadmap I'd want to be sure that I don't take things in a different direction.

Cavendish

Jason Moore

unread,
Sep 28, 2017, 1:05:54 PM9/28/17
to sy...@googlegroups.com
Cavendish,

3 is definitely what you should use. 2 isn't made for your use case. There was work on 3 this summer. Look for the pull requests with relevant topics. I'm not sure all has been merged yet.

Feel free to help with any of the printing or other bugs. I opened an issue for the bug in 2 yesterday. It should be easy to fix.

Jason

--
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+unsubscribe@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/9c319390-382d-414a-9392-4f358a7dbce0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Francesco Bonazzi

unread,
Sep 29, 2017, 3:54:25 PM9/29/17
to sympy


On Thursday, 28 September 2017 08:34:20 UTC-4, Cavendish McKay wrote:

3. use the vector module. In the 1.1.1 release, curvilinear coordinates are not officially supported, but can be made to work using private methods

It's been a GSoC project this year. Actually the API is still to fix, we need to do it before the next release.

(although one of the Lame coefficients for cylindrical coordinates is wrong, and I haven't checked to see if this is fixed in the current master).

If you find an error, please report it. Thanks.
 
the defaults violate standard typographical convention by making the base scalars bold face.

This can be easily fixed in the printers.

None of these is perfect, but my current favorite is (3). If I understand correctly, this was a GSoC project. What is its current status?

The API needs some reviews, especially when connecting arbitrary coordinate systems. In the current master, we are probably using the inverse transformation when connecting two coordinate systems.
Reply all
Reply to author
Forward
0 new messages