sympy.vector Divergence() gives wrong answers in Cylindrical Coordinates

20 views
Skip to first unread message

Sean Logan

unread,
Oct 31, 2021, 8:42:13 PM10/31/21
to sympy
Hello,

I discovered that the divergence() function from sympy.vector gives incorrect answers sometimes when using Cylindrical coordinates.  For example:

divergence( 1 * rhat )
#  returns  0    when it should give 1/R

I found that this issue was raised last year, and a patch offered, but it was never integrated into the sympy release.


I went into sympy/vector/operators.py and commented out lines 366-368 by hand.  That seems to have fixed the problem.

I also found this library, called "symfields" which does div, grad, curl properly in cylindrical, spherical, or any curvilinear coordinate system


it does not use CoordSys3D.

Chris Smith

unread,
Nov 5, 2021, 1:32:00 AM11/5/21
to sympy
Could you please either show the code that gave that result or else add it as a test for #20047

/c

Chris Smith

unread,
Nov 5, 2021, 2:53:45 AM11/5/21
to sympy
nevermind - a test was added. If you would like to see more added, please see https://github.com/sympy/sympy/pull/22427

/c

Reply all
Reply to author
Forward
0 new messages