def test_correct_arguments(): raises(ValueError, lambda: R2.e_x(R2.e_x)) raises(ValueError, lambda: R2.e_x(R2.dx)) raises(ValueError, lambda: Commutator(R2.e_x, R2.x)) raises(ValueError, lambda: Commutator(R2.dx, R2.e_x)) raises(ValueError, lambda: Differential(Differential(R2.e_x))) raises(ValueError, lambda: R2.dx(R2.x)) raises(ValueError, lambda: LieDerivative(R2.dx, R2.dx)) raises(ValueError, lambda: LieDerivative(R2.x, R2.dx)) raises(ValueError, lambda: CovarDerivativeOp(R2.dx, [])) raises(ValueError, lambda: CovarDerivativeOp(R2.x, [])) a = Symbol('a') raises(ValueError, lambda: intcurve_series(R2.dx, a, R2_r.point([1, 2]))) raises(ValueError, lambda: intcurve_series(R2.x, a, R2_r.point([1, 2]))) raises(ValueError, lambda: intcurve_diffequ(R2.dx, a, R2_r.point([1, 2]))) raises(ValueError, lambda: intcurve_diffequ(R2.x, a, R2_r.point([1, 2]))) raises(ValueError, lambda: contravariant_order(R2.e_x + R2.dx)) raises(ValueError, lambda: covariant_order(R2.e_x + R2.dx)) raises(ValueError, lambda: contravariant_order(R2.e_x * R2.e_y)) raises(ValueError, lambda: covariant_order(R2.dx * R2.dy))
def test_lie_derivative(): assert LieDerivative(R2.e_x, R2.y) == R2.e_x(R2.y) == 0 assert LieDerivative(R2.e_x, R2.x) == R2.e_x(R2.x) == 1 assert LieDerivative(R2.e_x, R2.e_x) == Commutator(R2.e_x, R2.e_x) == 0 assert LieDerivative(R2.e_x, R2.e_r) == Commutator(R2.e_x, R2.e_r) assert LieDerivative(R2.e_x+R2.e_y, R2.x) == 1 assert LieDerivative(R2.e_x, TensorProduct(R2.dx, R2.dy))(R2.e_x, R2.e_y) == 0
def test_issue_17917(): X = R2.x*R2.e_x - R2.y*R2.e_y Y = (R2.x**2 + R2.y**2)*R2.e_x - R2.x*R2.y*R2.e_y assert LieDerivative(X, Y).expand() == ( R2.x**2*R2.e_x - 3*R2.y**2*R2.e_x - R2.x*R2.y*R2.e_y)
# WedgeProduct Examples from sympy import Function from sympy.diffgeom.rn import R2 from sympy.diffgeom import WedgeProduct from sympy import pprint WedgeProduct(R2.dx, R2.dy)(R2.e_x, R2.e_y) WedgeProduct(R2.dx, R2.dy)(R2.e_y, R2.e_x) WedgeProduct(R2.dx, R2.x*R2.dy)(R2.x*R2.e_x, R2.e_y) #You can nest wedge products wp1 = WedgeProduct(R2.dx, R2.dy) WedgeProduct(wp1, R2.dx)(R2.e_x, R2.e_y, R2.e_x) # LieDerivative Examples from sympy.diffgeom import (LieDerivative, TensorProduct) from sympy.diffgeom.rn import R2 LieDerivative(R2.e_x, R2.y) LieDerivative(R2.e_x, R2.x) LieDerivative(R2.e_x, R2.e_x) # The Lie derivative of a tensor field by another tensor field is equal to their commutator: LieDerivative(R2.e_x, R2.e_r) LieDerivative(R2.e_x + R2.e_y, R2.x) tp = TensorProduct(R2.dx, R2.dy) LieDerivative(R2.e_x, tp) LieDerivative(R2.e_x, tp).doit() #BaseCovarDerivativeOp from sympy.diffgeom.rn import R2, R2_r from sympy.diffgeom import BaseCovarDerivativeOp from sympy.diffgeom import metric_to_Christoffel_2nd, TensorProduct TP = TensorProduct ch = metric_to_Christoffel_2nd(TP(R2.dx, R2.dx) + TP(R2.dy, R2.dy)) ch