微分几何#

介绍#

基类引用#

class sympy.diffgeom.Manifold(name, dim, **kwargs)[源代码]#

数学流形。

参数:

name :结构

流形的名称。

dim :内景

歧管的尺寸。

解释

A manifold is a topological space that locally resembles Euclidean space near each point [1]. This class does not provide any means to study the topological characteristics of the manifold that it represents, though.

实例

>>> from sympy.diffgeom import Manifold
>>> m = Manifold('M', 2)
>>> m
M
>>> m.dim
2

工具书类

class sympy.diffgeom.Patch(name, manifold, **kwargs)[源代码]#

流形上的补丁。

参数:

name :结构

修补程序的名称。

歧管 :歧管

定义面片的流形。

解释

坐标面片,简称patch,是围绕流形中一点的简单连通的开集 [1] . 在流形上,可以有许多不总是包含整个流形的补片。在这些图块上可以定义一个实数块的坐标。

此类不提供任何方法来研究它所表示的面片的拓扑特性。

实例

>>> from sympy.diffgeom import Manifold, Patch
>>> m = Manifold('M', 2)
>>> p = Patch('P', m)
>>> p
P
>>> p.dim
2

工具书类

[R176]

G. Sussman, J. Wisdom, W. Farr, Functional Differential Geometry (2013)

class sympy.diffgeom.CoordSystem(name, patch, symbols=None, relations={}, **kwargs)[源代码]#

在面片上定义的坐标系。

参数:

name :结构

坐标系的名称。

补丁 :修补程序

定义坐标系的面片。

符号 :符号列表,可选

定义坐标符号的名称和假设。

关系 :dict,可选

Key is a tuple of two strings, who are the names of the systems where the coordinates transform from and transform to. Value is a tuple of the symbols before transformation and a tuple of the expressions after transformation.

解释

坐标系是使用一个或多个坐标来唯一确定流形上的点或其他几何元素的位置的系统 [1] .

By passing Symbols to symbols parameter, user can define the name and assumptions of coordinate symbols of the coordinate system. If not passed, these symbols are generated automatically and are assumed to be real valued.

By passing relations parameter, user can define the transform relations of coordinate systems. Inverse transformation and indirect transformation can be found automatically. If this parameter is not passed, coordinate transformation cannot be done.

实例

We define two-dimensional Cartesian coordinate system and polar coordinate system.

>>> from sympy import symbols, pi, sqrt, atan2, cos, sin
>>> from sympy.diffgeom import Manifold, Patch, CoordSystem
>>> m = Manifold('M', 2)
>>> p = Patch('P', m)
>>> x, y = symbols('x y', real=True)
>>> r, theta = symbols('r theta', nonnegative=True)
>>> relation_dict = {
... ('Car2D', 'Pol'): [(x, y), (sqrt(x**2 + y**2), atan2(y, x))],
... ('Pol', 'Car2D'): [(r, theta), (r*cos(theta), r*sin(theta))]
... }
>>> Car2D = CoordSystem('Car2D', p, (x, y), relation_dict)
>>> Pol = CoordSystem('Pol', p, (r, theta), relation_dict)

symbols property returns CoordinateSymbol instances. These symbols are not same with the symbols used to construct the coordinate system.

>>> Car2D
Car2D
>>> Car2D.dim
2
>>> Car2D.symbols
(x, y)
>>> _[0].func
<class 'sympy.diffgeom.diffgeom.CoordinateSymbol'>

transformation() method returns the transformation function from one coordinate system to another. transform() method returns the transformed coordinates.

>>> Car2D.transformation(Pol)
Lambda((x, y), Matrix([
[sqrt(x**2 + y**2)],
[      atan2(y, x)]]))
>>> Car2D.transform(Pol)
Matrix([
[sqrt(x**2 + y**2)],
[      atan2(y, x)]])
>>> Car2D.transform(Pol, [1, 2])
Matrix([
[sqrt(5)],
[atan(2)]])

jacobian() method returns the Jacobian matrix of coordinate transformation between two systems. jacobian_determinant() method returns the Jacobian determinant of coordinate transformation between two systems.

>>> Pol.jacobian(Car2D)
Matrix([
[cos(theta), -r*sin(theta)],
[sin(theta),  r*cos(theta)]])
>>> Pol.jacobian(Car2D, [1, pi/2])
Matrix([
[0, -1],
[1,  0]])
>>> Car2D.jacobian_determinant(Pol)
1/sqrt(x**2 + y**2)
>>> Car2D.jacobian_determinant(Pol, [1,0])
1

工具书类

base_oneform(coord_index)[源代码]#

返回基础1表单字段。此坐标系的基础一表单字段。它也是向量场上的一个算子。

base_oneforms()[源代码]#

返回所有基本oneforms的列表。有关详细信息,请参阅 base_oneform 此类的方法。

base_scalar(coord_index)[源代码]#

返回 BaseScalarField 它获取一个点并返回其中一个坐标。

base_scalars()[源代码]#

返回所有坐标函数的列表。有关详细信息,请参阅 base_scalar 此类的方法。

base_vector(coord_index)[源代码]#

返回基向量字段。此坐标系的基向量场。它也是标量场上的一个运算符。

base_vectors()[源代码]#

返回所有基向量的列表。有关详细信息,请参阅 base_vector 此类的方法。

coord_function(coord_index)[源代码]#

返回 BaseScalarField 它获取一个点并返回其中一个坐标。

coord_functions()[源代码]#

返回所有坐标函数的列表。有关详细信息,请参阅 base_scalar 此类的方法。

coord_tuple_transform_to(to_sys, coords)[源代码]#

变换 coords 至坐标系 to_sys .

jacobian(sys, coordinates=None)[源代码]#

Return the jacobian matrix of a transformation on given coordinates. If coordinates are not given, coordinate symbols of self are used.

参数:

sys : CoordSystem

coordinates : Any iterable, optional.

返回:

sympy.ImmutableDenseMatrix

实例

>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> R2_p.jacobian(R2_r)
Matrix([
[cos(theta), -rho*sin(theta)],
[sin(theta),  rho*cos(theta)]])
>>> R2_p.jacobian(R2_r, [1, 0])
Matrix([
[1, 0],
[0, 1]])
jacobian_determinant(sys, coordinates=None)[源代码]#

Return the jacobian determinant of a transformation on given coordinates. If coordinates are not given, coordinate symbols of self are used.

参数:

sys : CoordSystem

coordinates : Any iterable, optional.

返回:

sympy.Expr

实例

>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> R2_r.jacobian_determinant(R2_p)
1/sqrt(x**2 + y**2)
>>> R2_r.jacobian_determinant(R2_p, [1, 0])
1
jacobian_matrix(sys, coordinates=None)[源代码]#

Return the jacobian matrix of a transformation on given coordinates. If coordinates are not given, coordinate symbols of self are used.

参数:

sys : CoordSystem

coordinates : Any iterable, optional.

返回:

sympy.ImmutableDenseMatrix

实例

>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> R2_p.jacobian(R2_r)
Matrix([
[cos(theta), -rho*sin(theta)],
[sin(theta),  rho*cos(theta)]])
>>> R2_p.jacobian(R2_r, [1, 0])
Matrix([
[1, 0],
[0, 1]])
point(coords)[源代码]#

创建一个 Point 坐标系中给出的坐标。

point_to_coords(point)[源代码]#

计算这个坐标系中一点的坐标。

transform(sys, coordinates=None)[源代码]#

返回坐标变换的结果 selfsys . 如果未给出坐标,则 self 被使用。

参数:

sys : CoordSystem

coordinates : Any iterable, optional.

返回:

sympy.ImmutableDenseMatrix containing CoordinateSymbol

实例

>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> R2_r.transform(R2_p)
Matrix([
[sqrt(x**2 + y**2)],
[      atan2(y, x)]])
>>> R2_r.transform(R2_p, [0, 1])
Matrix([
[   1],
[pi/2]])
transformation(sys)[源代码]#

Return coordinate transformation function from self to sys.

参数:

sys : CoordSystem

返回:

sympy.Lambda

实例

>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> R2_r.transformation(R2_p)
Lambda((x, y), Matrix([
[sqrt(x**2 + y**2)],
[      atan2(y, x)]]))
class sympy.diffgeom.CoordinateSymbol(coord_sys, index, **assumptions)[源代码]#

一种符号,表示给定上下文下坐标系第i个坐标的抽象值。

参数:

coord_sys :坐标系

指数 :整数

解释

坐标系中的每个坐标都用唯一的符号表示,如笛卡尔坐标系中的x、y、z。

您不能直接构造这个类。相反,使用 \(symbols\) 协调系统方法。

实例

>>> from sympy import symbols, Lambda, Matrix, sqrt, atan2, cos, sin
>>> from sympy.diffgeom import Manifold, Patch, CoordSystem
>>> m = Manifold('M', 2)
>>> p = Patch('P', m)
>>> x, y = symbols('x y', real=True)
>>> r, theta = symbols('r theta', nonnegative=True)
>>> relation_dict = {
... ('Car2D', 'Pol'): Lambda((x, y), Matrix([sqrt(x**2 + y**2), atan2(y, x)])),
... ('Pol', 'Car2D'): Lambda((r, theta), Matrix([r*cos(theta), r*sin(theta)]))
... }
>>> Car2D = CoordSystem('Car2D', p, [x, y], relation_dict)
>>> Pol = CoordSystem('Pol', p, [r, theta], relation_dict)
>>> x, y = Car2D.symbols

CoordinateSymbol contains its coordinate symbol and index.

>>> x.name
'x'
>>> x.coord_sys == Car2D
True
>>> x.index
0
>>> x.is_real
True

You can transform CoordinateSymbol into other coordinate system using rewrite() method.

>>> x.rewrite(Pol)
r*cos(theta)
>>> sqrt(x**2 + y**2).rewrite(Pol).simplify()
r
class sympy.diffgeom.Point(coord_sys, coords, **kwargs)[源代码]#

在坐标系中定义的点。

参数:

coord_sys :坐标系

坐标 :列表

点的坐标。

解释

从数学上讲,点是在流形中定义的,它本身没有任何坐标。坐标系是通过坐标图将坐标嵌入到点上。但是,由于实现这种逻辑的困难,您必须提供一个坐标系和坐标来定义这里的一个点。

此对象定义后的用法与定义它时使用的坐标系无关,但是由于简化例程的限制,如果使用不适当的坐标系,则可能会得到复杂的表达式。

实例

>>> from sympy import pi
>>> from sympy.diffgeom import Point
>>> from sympy.diffgeom.rn import R2, R2_r, R2_p
>>> rho, theta = R2_p.symbols
>>> p = Point(R2_p, [rho, 3*pi/4])
>>> p.manifold == R2
True
>>> p.coords()
Matrix([
[   rho],
[3*pi/4]])
>>> p.coords(R2_r)
Matrix([
[-sqrt(2)*rho/2],
[ sqrt(2)*rho/2]])
coords(sys=None)[源代码]#

点在给定坐标系中的坐标。如果未传递坐标系,则返回定义点的坐标系中的坐标。

class sympy.diffgeom.BaseScalarField(coord_sys, index, **kwargs)[源代码]#

给定坐标系流形上的基标量场。

参数:

coord_sys :坐标系

指数 :整数

解释

标量字段以点为参数并返回标量。坐标系的基标量字段获取一个点,并返回该点在该坐标系中的坐标之一。

要定义标量字段,需要选择坐标系和坐标索引。

标量字段定义后的使用与定义标量字段的坐标系无关,但是由于简化例程的限制,如果使用不适当的坐标系,可能会得到更复杂的表达式。只需构建包含复杂表达式的标量字段就可以了 BaseScalarField 实例。

实例

>>> from sympy import Function, pi
>>> from sympy.diffgeom import BaseScalarField
>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> rho, _ = R2_p.symbols
>>> point = R2_p.point([rho, 0])
>>> fx, fy = R2_r.base_scalars()
>>> ftheta = BaseScalarField(R2_r, 1)
>>> fx(point)
rho
>>> fy(point)
0
>>> (fx**2+fy**2).rcall(point)
rho**2
>>> g = Function('g')
>>> fg = g(ftheta-pi)
>>> fg.rcall(point)
g(-pi)
class sympy.diffgeom.BaseVectorField(coord_sys, index, **kwargs)[源代码]#

给定坐标系流形上的基向量场。

参数:

coord_sys :坐标系

指数 :整数

解释

向量场是一个使用标量场并返回方向导数(也是标量场)的运算符。基向量场是同一类型的运算符,但是推导是针对所选坐标进行的。

要定义基向量场,需要选择坐标系和坐标索引。

向量场定义后的使用与定义它的坐标系无关,但是由于简化程序的限制,如果使用不适当的坐标系,可能会得到更复杂的表达式。

实例

>>> from sympy import Function
>>> from sympy.diffgeom.rn import R2_p, R2_r
>>> from sympy.diffgeom import BaseVectorField
>>> from sympy import pprint
>>> x, y = R2_r.symbols
>>> rho, theta = R2_p.symbols
>>> fx, fy = R2_r.base_scalars()
>>> point_p = R2_p.point([rho, theta])
>>> point_r = R2_r.point([x, y])
>>> g = Function('g')
>>> s_field = g(fx, fy)
>>> v = BaseVectorField(R2_r, 1)
>>> pprint(v(s_field))
/ d           \|
|---(g(x, xi))||
\dxi          /|xi=y
>>> pprint(v(s_field).rcall(point_r).doit())
d
--(g(x, y))
dy
>>> pprint(v(s_field).rcall(point_p))
/ d                        \|
|---(g(rho*cos(theta), xi))||
\dxi                       /|xi=rho*sin(theta)
class sympy.diffgeom.Commutator(v1, v2)[源代码]#

两个向量场的交换子。

解释

两个向量场的交换子 \(v_1\)\(v_2\) 定义为向量场 \([v_1, v_2]\) 对每个标量场求值 \(f\) 等于 \(v_1(v_2(f)) - v_2(v_1(f))\) .

实例

>>> from sympy.diffgeom.rn import R2_p, R2_r
>>> from sympy.diffgeom import Commutator
>>> from sympy import simplify
>>> fx, fy = R2_r.base_scalars()
>>> e_x, e_y = R2_r.base_vectors()
>>> e_r = R2_p.base_vector(0)
>>> c_xy = Commutator(e_x, e_y)
>>> c_xr = Commutator(e_x, e_r)
>>> c_xy
0

不幸的是,当前代码无法计算所有内容:

>>> c_xr
Commutator(e_x, e_rho)
>>> simplify(c_xr(fy**2))
-2*cos(theta)*y**2/(x**2 + y**2)
class sympy.diffgeom.Differential(form_field)[源代码]#

返回窗体字段的差分(外部导数)。

解释

形式微分(即外导数)在一般情况下有一个复杂的定义。差速器 \(df\) 0-形式的 \(f\) 为任何向量场定义 \(v\) 作为 \(df(v) = v(f)\) .

实例

>>> from sympy import Function
>>> from sympy.diffgeom.rn import R2_r
>>> from sympy.diffgeom import Differential
>>> from sympy import pprint
>>> fx, fy = R2_r.base_scalars()
>>> e_x, e_y = R2_r.base_vectors()
>>> g = Function('g')
>>> s_field = g(fx, fy)
>>> dg = Differential(s_field)
>>> dg
d(g(x, y))
>>> pprint(dg(e_x))
/ d           \|
|---(g(xi, y))||
\dxi          /|xi=x
>>> pprint(dg(e_y))
/ d           \|
|---(g(x, xi))||
\dxi          /|xi=y

应用外部导数运算符两次总是会导致:

>>> Differential(dg)
0
class sympy.diffgeom.TensorProduct(*args)[源代码]#

形式的张量积。

解释

张量积允许从低阶域(如1-形式和向量场)中创建多线性泛函(即高阶张量)。然而,由此产生的高张量缺乏另一类乘积,即楔形积所提供的有趣特征,即它们不是反对称的,因此不是形式域。

实例

>>> from sympy.diffgeom.rn import R2_r
>>> from sympy.diffgeom import TensorProduct
>>> fx, fy = R2_r.base_scalars()
>>> e_x, e_y = R2_r.base_vectors()
>>> dx, dy = R2_r.base_oneforms()
>>> TensorProduct(dx, dy)(e_x, e_y)
1
>>> TensorProduct(dx, dy)(e_y, e_x)
0
>>> TensorProduct(dx, fx*dy)(fx*e_x, e_y)
x**2
>>> TensorProduct(e_x, e_y)(fx**2, fy**2)
4*x*y
>>> TensorProduct(e_y, dx)(fy)
dx

你可以嵌套张量积。

>>> tp1 = TensorProduct(dx, dy)
>>> TensorProduct(tp1, dx)(e_x, e_y, e_x)
1

你可以做部分收缩,例如当'提高一个指数'。放 None 在第二个论点中 rcall 表示张量积中的相应位置保持原样。

>>> TP = TensorProduct
>>> metric = TP(dx, dx) + 3*TP(dy, dy)
>>> metric.rcall(e_y, None)
3*dy

或者自动用 None 没有具体说明。

>>> metric.rcall(e_y)
3*dy
class sympy.diffgeom.WedgeProduct(*args)[源代码]#

形状的楔形产品。

解释

在一体化的背景下,只有完全反对称的形式才有意义。楔形产品允许创建这种形式。

实例

>>> from sympy.diffgeom.rn import R2_r
>>> from sympy.diffgeom import WedgeProduct
>>> fx, fy = R2_r.base_scalars()
>>> e_x, e_y = R2_r.base_vectors()
>>> dx, dy = R2_r.base_oneforms()
>>> WedgeProduct(dx, dy)(e_x, e_y)
1
>>> WedgeProduct(dx, dy)(e_y, e_x)
-1
>>> WedgeProduct(dx, fx*dy)(fx*e_x, e_y)
x**2
>>> WedgeProduct(e_x, e_y)(fy, None)
-e_x

你可以嵌套楔形产品。

>>> wp1 = WedgeProduct(dx, dy)
>>> WedgeProduct(wp1, dx)(e_x, e_y, e_x)
0
class sympy.diffgeom.LieDerivative(v_field, expr)[源代码]#

关于向量场的Lie导数。

解释

定义Lie导数的输运算符是沿着导出的场的积分曲线导出的场的前推。

实例

>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> from sympy.diffgeom import (LieDerivative, TensorProduct)
>>> fx, fy = R2_r.base_scalars()
>>> e_x, e_y = R2_r.base_vectors()
>>> e_rho, e_theta = R2_p.base_vectors()
>>> dx, dy = R2_r.base_oneforms()
>>> LieDerivative(e_x, fy)
0
>>> LieDerivative(e_x, fx)
1
>>> LieDerivative(e_x, e_x)
0

张量场与另一张量场的李导数等于其交换子:

>>> LieDerivative(e_x, e_rho)
Commutator(e_x, e_rho)
>>> LieDerivative(e_x + e_y, fx)
1
>>> tp = TensorProduct(dx, dy)
>>> LieDerivative(e_x, tp)
LieDerivative(e_x, TensorProduct(dx, dy))
>>> LieDerivative(e_x, tp)
LieDerivative(e_x, TensorProduct(dx, dy))
class sympy.diffgeom.BaseCovarDerivativeOp(coord_sys, index, christoffel)[源代码]#

关于基向量的协变导数算子。

实例

>>> from sympy.diffgeom.rn import R2_r
>>> from sympy.diffgeom import BaseCovarDerivativeOp
>>> from sympy.diffgeom import metric_to_Christoffel_2nd, TensorProduct
>>> TP = TensorProduct
>>> fx, fy = R2_r.base_scalars()
>>> e_x, e_y = R2_r.base_vectors()
>>> dx, dy = R2_r.base_oneforms()
>>> ch = metric_to_Christoffel_2nd(TP(dx, dx) + TP(dy, dy))
>>> ch
[[[0, 0], [0, 0]], [[0, 0], [0, 0]]]
>>> cvd = BaseCovarDerivativeOp(R2_r, 0, ch)
>>> cvd(fx)
1
>>> cvd(fx*e_x)
e_x
class sympy.diffgeom.CovarDerivativeOp(wrt, christoffel)[源代码]#

协变导数算子。

实例

>>> from sympy.diffgeom.rn import R2_r
>>> from sympy.diffgeom import CovarDerivativeOp
>>> from sympy.diffgeom import metric_to_Christoffel_2nd, TensorProduct
>>> TP = TensorProduct
>>> fx, fy = R2_r.base_scalars()
>>> e_x, e_y = R2_r.base_vectors()
>>> dx, dy = R2_r.base_oneforms()
>>> ch = metric_to_Christoffel_2nd(TP(dx, dx) + TP(dy, dy))
>>> ch
[[[0, 0], [0, 0]], [[0, 0], [0, 0]]]
>>> cvd = CovarDerivativeOp(fx*e_x, ch)
>>> cvd(fx)
x
>>> cvd(fx*e_x)
x*e_x
sympy.diffgeom.intcurve_series(vector_field, param, start_point, n=6, coord_sys=None, coeffs=False)[源代码]#

返回场的积分曲线的级数展开式。

参数:

vector_field

给出积分曲线的向量场

param

函数的参数 \(\gamma\) 从R到曲线

start_point

与之相对应的点 \(\gamma(0)\)

n

扩展的顺序

coord_sys

展开系数的坐标系(默认为False)-如果为True,则返回展开元素的列表

解释

积分曲线是函数 \(\gamma\) 接受一个参数 \(R\) 流形中的某个点。它验证了等式:

\(V(f)\big(\gamma(t)\big) = \frac{d}{dt}f\big(\gamma(t)\big)\)

在给定的 vector_field 表示为 \(V\) . 这对任何价值都有效 \(t\) 对于参数和任何标量字段 \(f\) .

这个方程也可以分解为一个坐标函数的基 \(V(f_i)\big(\gamma(t)\big) = \frac{{d}}{{dt}}f_i\big(\gamma(t)\big) \quad \forall i\)

此函数返回 \(\gamma(t)\) 在坐标系方面 coord_sys . 由于没有其他方法来表示流形上点之间的运动(即一般流形没有点差这一点),因此方程和展开必须以坐标系相关的方式进行。

实例

使用预定义的R2歧管:

>>> from sympy.abc import t, x, y
>>> from sympy.diffgeom.rn import R2_p, R2_r
>>> from sympy.diffgeom import intcurve_series

指定起点和向量场:

>>> start_point = R2_r.point([x, y])
>>> vector_field = R2_r.e_x

计算级数:

>>> intcurve_series(vector_field, t, start_point, n=3)
Matrix([
[t + x],
[    y]])

或者在列表中获取展开元素:

>>> series = intcurve_series(vector_field, t, start_point, n=3, coeffs=True)
>>> series[0]
Matrix([
[x],
[y]])
>>> series[1]
Matrix([
[t],
[0]])
>>> series[2]
Matrix([
[0],
[0]])

极坐标系中的级数:

>>> series = intcurve_series(vector_field, t, start_point,
...             n=3, coord_sys=R2_p, coeffs=True)
>>> series[0]
Matrix([
[sqrt(x**2 + y**2)],
[      atan2(y, x)]])
>>> series[1]
Matrix([
[t*x/sqrt(x**2 + y**2)],
[   -t*y/(x**2 + y**2)]])
>>> series[2]
Matrix([
[t**2*(-x**2/(x**2 + y**2)**(3/2) + 1/sqrt(x**2 + y**2))/2],
[                                t**2*x*y/(x**2 + y**2)**2]])
sympy.diffgeom.intcurve_diffequ(vector_field, param, start_point, coord_sys=None)[源代码]#

返回场的积分曲线的微分方程。

参数:

vector_field

给出积分曲线的向量场

param

函数的参数 \(\gamma\) 从R到曲线

start_point

与之相对应的点 \(\gamma(0)\)

coord_sys

给出方程式的坐标系

返回:

元组(方程式、初始条件)

解释

积分曲线是函数 \(\gamma\) 接受一个参数 \(R\) 流形中的某个点。它验证了等式:

\(V(f)\big(\gamma(t)\big) = \frac{d}{dt}f\big(\gamma(t)\big)\)

在给定的 vector_field 表示为 \(V\) . 这对任何价值都有效 \(t\) 对于参数和任何标量字段 \(f\) .

此函数返回 \(\gamma(t)\) 在坐标系方面 coord_sys . 由于没有其他方法来表示流形上点之间的运动(即一般流形没有点差这一点),因此方程和展开必须以坐标系相关的方式进行。

实例

使用预定义的R2歧管:

>>> from sympy.abc import t
>>> from sympy.diffgeom.rn import R2, R2_p, R2_r
>>> from sympy.diffgeom import intcurve_diffequ

指定起点和向量场:

>>> start_point = R2_r.point([0, 1])
>>> vector_field = -R2.y*R2.e_x + R2.x*R2.e_y

得到方程式:

>>> equations, init_cond = intcurve_diffequ(vector_field, t, start_point)
>>> equations
[f_1(t) + Derivative(f_0(t), t), -f_0(t) + Derivative(f_1(t), t)]
>>> init_cond
[f_0(0), f_1(0) - 1]

极坐标系中的级数:

>>> equations, init_cond = intcurve_diffequ(vector_field, t, start_point, R2_p)
>>> equations
[Derivative(f_0(t), t), Derivative(f_1(t), t) - 1]
>>> init_cond
[f_0(0) - 1, f_1(0) - pi/2]
sympy.diffgeom.vectors_in_basis(expr, to_sys)[源代码]#

转换指定坐标基的基向量中的所有基向量。当新的基向量在新的坐标系基础上时,任何系数都保留在旧坐标系中。

实例

>>> from sympy.diffgeom import vectors_in_basis
>>> from sympy.diffgeom.rn import R2_r, R2_p
>>> vectors_in_basis(R2_r.e_x, R2_p)
-y*e_theta/(x**2 + y**2) + x*e_rho/sqrt(x**2 + y**2)
>>> vectors_in_basis(R2_p.e_r, R2_r)
sin(theta)*e_y + cos(theta)*e_x
sympy.diffgeom.twoform_to_matrix(expr)[源代码]#

返回表示twoform的矩阵。

为了两个形式 \(w\) 返回矩阵 \(M\) 这样的话 \(M[i,j]=w(e_i, e_j)\) 在哪里 \(e_i\) 是坐标系的第i个基向量场,其中表达式 \(w\) 给出。

实例

>>> from sympy.diffgeom.rn import R2
>>> from sympy.diffgeom import twoform_to_matrix, TensorProduct
>>> TP = TensorProduct
>>> twoform_to_matrix(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
Matrix([
[1, 0],
[0, 1]])
>>> twoform_to_matrix(R2.x*TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
Matrix([
[x, 0],
[0, 1]])
>>> twoform_to_matrix(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy) - TP(R2.dx, R2.dy)/2)
Matrix([
[   1, 0],
[-1/2, 1]])
sympy.diffgeom.metric_to_Christoffel_1st(expr)[源代码]#

返回给定度量的Christoffel符号的嵌套列表。这将返回第一种类型的Christoffel符号,该符号表示给定度量的Levi-Civita连接。

实例

>>> from sympy.diffgeom.rn import R2
>>> from sympy.diffgeom import metric_to_Christoffel_1st, TensorProduct
>>> TP = TensorProduct
>>> metric_to_Christoffel_1st(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
[[[0, 0], [0, 0]], [[0, 0], [0, 0]]]
>>> metric_to_Christoffel_1st(R2.x*TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
[[[1/2, 0], [0, 0]], [[0, 0], [0, 0]]]
sympy.diffgeom.metric_to_Christoffel_2nd(expr)[源代码]#

返回给定度量的Christoffel符号的嵌套列表。这将返回第二种类型的Christoffel符号,该符号表示给定度量的Levi-Civita连接。

实例

>>> from sympy.diffgeom.rn import R2
>>> from sympy.diffgeom import metric_to_Christoffel_2nd, TensorProduct
>>> TP = TensorProduct
>>> metric_to_Christoffel_2nd(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
[[[0, 0], [0, 0]], [[0, 0], [0, 0]]]
>>> metric_to_Christoffel_2nd(R2.x*TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
[[[1/(2*x), 0], [0, 0]], [[0, 0], [0, 0]]]
sympy.diffgeom.metric_to_Riemann_components(expr)[源代码]#

返回以给定基表示的黎曼张量的分量。

给定一个度量,它计算在给出度量表达式的坐标系的正则基中的Riemann张量分量。

实例

>>> from sympy import exp
>>> from sympy.diffgeom.rn import R2
>>> from sympy.diffgeom import metric_to_Riemann_components, TensorProduct
>>> TP = TensorProduct
>>> metric_to_Riemann_components(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
[[[[0, 0], [0, 0]], [[0, 0], [0, 0]]], [[[0, 0], [0, 0]], [[0, 0], [0, 0]]]]
>>> non_trivial_metric = exp(2*R2.r)*TP(R2.dr, R2.dr) +         R2.r**2*TP(R2.dtheta, R2.dtheta)
>>> non_trivial_metric
exp(2*rho)*TensorProduct(drho, drho) + rho**2*TensorProduct(dtheta, dtheta)
>>> riemann = metric_to_Riemann_components(non_trivial_metric)
>>> riemann[0, :, :, :]
[[[0, 0], [0, 0]], [[0, exp(-2*rho)*rho], [-exp(-2*rho)*rho, 0]]]
>>> riemann[1, :, :, :]
[[[0, -1/rho], [1/rho, 0]], [[0, 0], [0, 0]]]
sympy.diffgeom.metric_to_Ricci_components(expr)[源代码]#

返回以给定基础表示的Ricci张量分量。

给定一个度量,它计算Ricci张量在给出度量表达式的坐标系的正则基中的分量。

实例

>>> from sympy import exp
>>> from sympy.diffgeom.rn import R2
>>> from sympy.diffgeom import metric_to_Ricci_components, TensorProduct
>>> TP = TensorProduct
>>> metric_to_Ricci_components(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy))
[[0, 0], [0, 0]]
>>> non_trivial_metric = exp(2*R2.r)*TP(R2.dr, R2.dr) +                              R2.r**2*TP(R2.dtheta, R2.dtheta)
>>> non_trivial_metric
exp(2*rho)*TensorProduct(drho, drho) + rho**2*TensorProduct(dtheta, dtheta)
>>> metric_to_Ricci_components(non_trivial_metric)
[[1/rho, 0], [0, exp(-2*rho)*rho]]