I am working with curvilinear coordinates, especiallt how to determine
scale factors for spherical coordinates and how to express the unit vectors
i terms of i, j, k (cartesian base vectors). I submit some code
#
# curvilinear.py
#from sympy import *
x, y, z = symbols("x y z")
rho= symbols("rho",positive=True,real=True)
theta = symbols("theta",positive=True,real=True)
phi = symbols("phi",positive=True,real=True)
# spherical coord
x=rho*sin(phi)*cos(theta)
y=rho*sin(phi)*sin(theta)
z=rho*cos(phi)
A=Matrix([[x],[y],[z]])
r=A
dr=diff(r,rho)
hr=dr.norm()
hr=simplify(hr)
dphi=diff(r,phi)
hphi=dphi.norm()
hphi=simplify(hphi)
dtheta=diff(r,theta)
htheta=dtheta.norm()
htheta=simplify(htheta)
r_hat=dr/hr
fi_hat=dphi/hphi
th_hat=dtheta/htheta
print(fi_hat)
print(th_hat)
print(r_hat)
#
#
Problems with th_hat. Despite telling sympy that phi is positive, I get
Abs(sin(phi)) instead of sin(phi). Thus python does not cancel the factor
sin(phi).
Has anyone some hints how to solve this issue. Maybe a bug in sympy?
/Staffan L
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/717dfd84-7b24-4a28-83c5-19ba7ca53e97n%40googlegroups.com.