Divergence wrong in cylindrical coordinates?

69 views
Skip to first unread message

Alexander Lindsay

unread,
Aug 26, 2020, 6:31:12 PM8/26/20
to sy...@googlegroups.com
Execution of the below code:

From sympy.vector import divergence, gradient, Vector, CoordSys3D
R = CoordSys3D('R', transformation='cylindrical')
divergence(R.i)

generates a zero result. I believe the result should be 1/r, right?

Alexander Lindsay

unread,
Aug 26, 2020, 6:40:29 PM8/26/20
to sy...@googlegroups.com
This patch fixes the bad behavior:

diff --git a/sympy/vector/operators.py b/sympy/vector/operators.py
index 2f303ee690..994894f379 100644
--- a/sympy/vector/operators.py
+++ b/sympy/vector/operators.py
@@ -362,6 +362,4 @@ def _diff_conditional(expr, base_scalar, coeff_1, coeff_2):
     """
     from sympy.vector.functions import express
     new_expr = express(expr, base_scalar.system, variables=True)
-    if base_scalar in new_expr.atoms(BaseScalar):
-        return Derivative(coeff_1 * coeff_2 * new_expr, base_scalar)
-    return S.Zero
+    return Derivative(coeff_1 * coeff_2 * new_expr, base_scalar)

Should I submit a PR?

Alan Bromborsky

unread,
Aug 26, 2020, 7:03:47 PM8/26/20
to sy...@googlegroups.com
If you are dealing with gradient you might find this link of interest -


the galgebra package is built on top of sympy.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CANFcJrFgKxs1S78dAWKRZeKKbxjHh_OsWWtT%2Btgz3EWW_3F6hw%40mail.gmail.com.


Faisal Riyaz

unread,
Aug 28, 2020, 9:05:33 AM8/28/20
to sy...@googlegroups.com
Hello,

This looks like a bug. Please do submit a PR.

Thanks
Faisal Riyaz

--

Alexander Lindsay

unread,
Sep 4, 2020, 1:19:55 PM9/4/20
to sy...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages