vector calculus (cylindrical/spherical coordinates)

636 views
Skip to first unread message

thomas hisch

unread,
Aug 12, 2014, 3:38:46 PM8/12/14
to sy...@googlegroups.com
Currently I do a lot of vector calculus with cartesian, cylindrical und spherical coordinate systems. It would be nice if sympy could help me with calculating curls,divergences and gradients of vectors/vectorfields especially in cylindrical and spherical coordinates. I've already tested the cartesian vector stuff in sympy, but I can't find any examples of common vector operations using curvilinear coordinates.

Regards
Thomas

Jason Moore

unread,
Aug 12, 2014, 3:46:43 PM8/12/14
to sy...@googlegroups.com
Thomas,

Sachin just submitted a Cartesian based vector calc package to sympy for this summer's GSoC:

https://github.com/sympy/sympy/tree/master/sympy/vector

The new documentation for this should be available this week.

Adding new CoordinateSystems like Spherical, etc should be relatively straightforward now that all that is in place.

There is code in this PR (https://github.com/sympy/sympy/pull/2208) that could be helpful and relevant, as it attempted to implement the other coordinate systems in another version of a vector calculus package.

So if you'd like to contribute this functionality, we'd welcome it. I'm sure Sachin has a lot of ideas about this.

--
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+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/6f9805f7-7473-44aa-837b-e75394703e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Bromborsky

unread,
Aug 12, 2014, 4:07:21 PM8/12/14
to sy...@googlegroups.com
--
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+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/6f9805f7-7473-44aa-837b-e75394703e3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
My fork of sympy

https://github.com/brombo/sympy

can do curvilinear coordinates (see attached).  You just have to define correct metric for coordinate system.  Cylindrical and spherical are easy.
curvi_linear_coords.pdf

Thomas Hisch

unread,
Aug 12, 2014, 4:09:37 PM8/12/14
to sy...@googlegroups.com
Great thx!


--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/4SIr_6iW6v4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

Alan Bromborsky

unread,
Aug 12, 2014, 4:20:10 PM8/12/14
to sy...@googlegroups.com
Attached is the correct example.  I forgot to normalize the basis for the spherical case.
curvi_linear_coords.pdf

Thomas Hisch

unread,
Aug 12, 2014, 4:40:23 PM8/12/14
to sy...@googlegroups.com
Alan, how did you create this pdf ? ipython nbconvert ?


Alan Bromborsky

unread,
Aug 12, 2014, 6:51:05 PM8/12/14
to sy...@googlegroups.com
I have a latex printer in the geometric algebra module.  I have attached the code used to generate the output and the module documentation in pdf format.  Ipython notebook with latex output does work but is not as flexible as the latex printer.  When I am using the geometric algebra module I usually get the terminal (text) output working and then I modify the code for latex (pdf) output.  The only problem with the latex output is that it is not produced until xpdf() is called at the end of the program so latex will not be output incrementally.  See attached code (code includes calls to Print_Fuction() which generates latex output of python code that produces the output).
curvi_linear_coords.py
GA.pdf

Sachin Joglekar

unread,
Aug 13, 2014, 6:57:57 AM8/13/14
to sy...@googlegroups.com
Hello Thomas,

Can you give an example of the kind of operations you would like to do with the vector module? Maybe we can think of ideas those things could be implemented in the vector module and plan it that way. As Jason mentioned, the documentation for the current stuff will be up on Sphnix dev page by the weekend.

Regards
Sachin Joglekar

Alan Bromborsky

unread,
Aug 13, 2014, 12:02:28 PM8/13/14
to sy...@googlegroups.com
Here are a more complete example for different curvilinear coordinate systems (takes about 6 minutes to run on i7-4930K).  The one example that is commented out hangs.   The example for a toroidal coordinate system does not have the basis vectors normalized.  There is an error if the basis vectors are normalized due to simplification of complicated scalar expressions with square roots in sympy.



On 08/12/2014 04:40 PM, Thomas Hisch wrote:
curvi_linear_coords.pdf
Reply all
Reply to author
Forward
0 new messages