当我尝试使用sympy.diffgeom
库时,我收到以下错误:
File "/usr/local/lib/python2.7/dist-packages/sympy-0.7.7.dev0-
py2.7.egg/sympy/diffgeom/diffgeom.py", line 1463, in twoform_to_matrix
raise ValueError('The input expression concerns more than one '
ValueError: The input expression concerns more than one coordinate systems,
hence there is no unambiguous way to choose a coordinate system for the
matrix.
坐标系定义为
CoordSystem(egg_carton, Patch(P, Manifold(M, 2)), (u, v))
以双格式表示如下
metric = (sin(v)**2*sin(u)**2 + 1)*TensorProduct(dv, dv) + (cos(v)**2*cos(u)**2 + 1)*TensorProduct(du, du) + (-cos(2*v - 2*u)/8 + cos(2*v + 2*u)/8)*TensorProduct(du, dv) + (-cos(2*v - 2*u)/8 + cos(2*v + 2*u)/8)*TensorProduct(dv, du)
以下代码
print type(metric)
print type(u)
print type(v)
print type(du)
print type(dv)
产生以下输出
<class 'sympy.core.add.Add'>
<class 'sympy.diffgeom.diffgeom.BaseScalarField'>
<class 'sympy.diffgeom.diffgeom.BaseScalarField'>
<class 'sympy.diffgeom.diffgeom.Differential'>
<class 'sympy.diffgeom.diffgeom.Differential'>
当我尝试将此指标用作以下任何函数的参数时
sympy.diffgeom.metric_to_Christoffel_1st
sympy.diffgeom.metric_to_Christoffel_2nd
sympy.diffgeom.metric_to_Ricci_components
sympy.diffgeom.metric_to_Riemann_components
我得到了ValueError。这里似乎有什么问题?
修改1:
我也在Sympy google group上发布了这个问题。
编辑2:
如果我只是对每个指标进行硬编码,那么每件事都能正常运行。例如,以鸡蛋盒表面为例,
from sympy.diffgeom import Manifold, Patch, CoordSystem, TensorProduct
from sympy import sin,cos
dim = 2
m = Manifold("M",dim)
patch = Patch("P",m)
system = CoordSystem('egg_carton', patch, ["u", "v"])
u,v = system.coord_functions()
du,dv = system.base_oneforms()
metric = (sin(v)**2*sin(u)**2 + 1)*TensorProduct(dv, dv) +\
(cos(v)**2*cos(u)**2 + 1)*TensorProduct(du, du) +\
(-cos(2*v - 2*u)/8 + cos(2*v + 2*u)/8)*TensorProduct(du, dv) +\
(-cos(2*v - 2*u)/8 + cos(2*v + 2*u)/8)*TensorProduct(dv, du)
我可以使用任何metric_to_ *函数而不会获得ValueError。
此外,这里分别是sympy.srepr
和u
的{{1}}输出:
du