求 sympy.diffgeom 球体的黎曼曲率张量
Finding the Riemann curvature tensor with sympy.diffgeom for a sphere
我正在测试 sympy.diffgeom 库。我的目的是为从笛卡尔坐标和球坐标之间的变换中找到的预先计算的度量找到黎曼曲率张量。这是代码
from sympy.diffgeom import Manifold, Patch, CoordSystem, TensorProduct
import sympy as sym
from sympy import cos,sinh,cosh, sin
m = Manifold("M",3)
patch = Patch("P",m)
cartesian = CoordSystem("cartesian",patch, ["x", "y", "z"])
x, y, z = cartesian.coord_functions()
spherical = CoordSystem("spherical", patch, ["r", "theta", "phi"])
r, theta, phi = spherical.coord_functions()
g = sym.Matrix([[1, 0, 0], [0, r**2, 0], [0, 0, r**2*sin(theta)**2]])
diff_forms = toroidal.base_oneforms()
metric_diff_form = sum([TensorProduct(di, dj)*g[i, j] for i, di in enumerate(diff_forms) for j, dj in enumerate(diff_forms)])
# Find the Riemann curvature tensor
from sympy.diffgeom import metric_to_Riemann_components
R = metric_to_Riemann_components(metric_diff_form)
当我 运行 这样做时,最后一行出现以下错误
ValueError: The input expression concerns more than one coordinate systems, hence there is no unambiguous way to choose a coordinate system for the matrix.
我不明白为什么,因为我已经针对不同(更复杂)的指标测试了代码。
你的矩阵g是由坐标系spherical的坐标函数组成的,你把它们和两种形式混合了坐标系 环形.
试试这个,在将度量矩阵转换为两种形式的和之前:
diff_forms = spherical.base_oneforms()
错误消息非常简单。
我正在测试 sympy.diffgeom 库。我的目的是为从笛卡尔坐标和球坐标之间的变换中找到的预先计算的度量找到黎曼曲率张量。这是代码
from sympy.diffgeom import Manifold, Patch, CoordSystem, TensorProduct
import sympy as sym
from sympy import cos,sinh,cosh, sin
m = Manifold("M",3)
patch = Patch("P",m)
cartesian = CoordSystem("cartesian",patch, ["x", "y", "z"])
x, y, z = cartesian.coord_functions()
spherical = CoordSystem("spherical", patch, ["r", "theta", "phi"])
r, theta, phi = spherical.coord_functions()
g = sym.Matrix([[1, 0, 0], [0, r**2, 0], [0, 0, r**2*sin(theta)**2]])
diff_forms = toroidal.base_oneforms()
metric_diff_form = sum([TensorProduct(di, dj)*g[i, j] for i, di in enumerate(diff_forms) for j, dj in enumerate(diff_forms)])
# Find the Riemann curvature tensor
from sympy.diffgeom import metric_to_Riemann_components
R = metric_to_Riemann_components(metric_diff_form)
当我 运行 这样做时,最后一行出现以下错误
ValueError: The input expression concerns more than one coordinate systems, hence there is no unambiguous way to choose a coordinate system for the matrix.
我不明白为什么,因为我已经针对不同(更复杂)的指标测试了代码。
你的矩阵g是由坐标系spherical的坐标函数组成的,你把它们和两种形式混合了坐标系 环形.
试试这个,在将度量矩阵转换为两种形式的和之前:
diff_forms = spherical.base_oneforms()
错误消息非常简单。