[ Using sympy.diffgeom.CoordSystem to connect two coordinate systems ]
I was trying to follow the documentation in sympy.diffgeom using my own example. Instead of using cartesian and polar coordinates, I tried using cartesian and toroidal coordinates.
Here is my code from an ipython session :
from sympy.diffgeom import Manifold, Patch, CoordSystem
from sympy.abc import theta, eta, psi
import sympy as sym
x,y,z,a = sym.symbols("x y z a")
m = Manifold("M",2)
patch = Patch("P",m)
cartesian = CoordSystem("cartesian",patch)
toroidal = CoordSystem("toroidal",patch)
from sympy import sin,cos,sinh,cosh
toroidal.connect_to(cartesian,[eta,theta,psi],
[(a*sinh(eta)*cos(psi))/(cosh(eta) - cos(theta)),
(a*sinh(eta)*sin(psi))/(cosh(eta) - cos(theta)),
(a*sin(theta))/(cosh(eta) - cos(theta))])
When I try to execute the last line here, the code simply runs endlessly. Why is this not working ?
Answer 1
Try to put inverse=False as an argument in .connect_to( ... ):
toroidal.connect_to(cartesian,[eta,theta,psi],
[(a*sinh(eta)*cos(psi))/(cosh(eta) - cos(theta)),
(a*sinh(eta)*sin(psi))/(cosh(eta) - cos(theta)),
(a*sin(theta))/(cosh(eta) - cos(theta))], inverse=False)
It's likely that SymPy's solver encounters a lot of difficulty in inverting the transformation equations.
If you want to use the inverse transformations, I suggest call .connect_to( ... ) a second time, manually specifying the inverse transformations:
cartesian.connect_to(toroidal, ... , ... , inverse=False)