Tensor Module

This module contains Tensor class which serves as the base class for more specific Tensors in General Relativity:

class einsteinpy.symbolic.tensor.Tensor(arr, config='ll')

Base Class for Tensor manipulation

Constructor and Initializer

Parameters
  • arr (ImmutableDenseNDimArray or list) – Sympy Array, multi-dimensional list containing Sympy Expressions, or Sympy Expressions or int or float scalar

  • config (str) – Configuration of contravariant and covariant indices in tensor. ‘u’ for upper and ‘l’ for lower indices. Defaults to ‘ll’.

Raises
  • TypeError – Raised when arr is not a list or sympy array

  • TypeError – Raised when config is not of type str or contains characters other than ‘l’ or ‘u’

property order

Returns the order of the Tensor

property config

Returns the configuration of covariant and contravariant indices

tensor()

Returns the sympy Array

Returns

Sympy Array object

Return type

ImmutableDenseNDimArray

subs(*args)

Substitute the variables/expressions in a Tensor with other sympy variables/expressions.

Parameters

args (one argument or two argument) –

  • two arguments, e.g foo.subs(old, new)

  • one iterable argument, e.g foo.subs([(old1, new1), (old2, new2)]) for multiple substitutions at once.

Returns

Tensor with substituted values

Return type

Tensor

simplify()

Returns a simplified Tensor

Returns

Simplified Tensor

Return type

Tensor

class einsteinpy.symbolic.tensor.BaseRelativityTensor(arr, syms, config='ll', parent_metric=None, variables=[], functions=[], name=None)

Inherits from ~einsteinpy.symbolic.tensor.Tensor . Generic class for defining tensors in General Relativity. This would act as a base class for other Tensorial quantities in GR.

arr

Raw Tensor in sympy array

Type

ImmutableDenseNDimArray

syms

List of symbols denoting space and time axis

Type

list or tuple

dims

dimension of the space-time.

Type

int

variables

free variables in the tensor expression other than the variables describing space-time axis.

Type

list

functions

Undefined functions in the tensor expression.

Type

list

name

Name of the tensor.

Type

string or None

Constructor and Initializer

Parameters
  • arr (ImmutableDenseNDimArray or list) – Sympy Array or multi-dimensional list containing Sympy Expressions

  • syms (tuple or list) – List of crucial symbols dentoting time-axis and/or spacial axis. For example, in case of 4D space-time, the arrangement would look like [t, x1, x2, x3].

  • config (str) – Configuration of contravariant and covariant indices in tensor. ‘u’ for upper and ‘l’ for lower indices. Defaults to ‘ll’.

  • parent_metric (MetricTensor or None) – Metric Tensor for some particular space-time which is associated with this Tensor.

  • variables (tuple or list or set) – List of symbols used in expressing the tensor other than symbols associated with denoting the space-time axis. Calculates in real-time if left blank.

  • functions (tuple or list or set) – List of symbolic functions used in epressing the tensor. Calculates in real-time if left blank.

  • name (string) – Name of the Tensor. Defaults to None.

Raises
  • TypeError – Raised when arr is not a list, sympy array or numpy array.

  • TypeError – Raised when config is not of type str or contains characters other than ‘l’ or ‘u’

  • TypeError – Raised when arguments syms, variables, functions have data type other than list, tuple or set.

  • TypeError – Raised when argument parent_metric does not belong to MetricTensor class and isn’t None.

property parent_metric

Returns the Metric from which Tensor was derived/associated, if available.

symbols()

Returns the symbols used for defining the time & spacial axis

Returns

tuple containing (t,x1,x2,x3) in case of 4D space-time

Return type

tuple

tensor_lambdify(*args)

Returns lambdified function of symbolic tensors. This means that the returned functions can accept numerical values and return numerical quantities.

Parameters

*args – The variable number of arguments accept sympy symbols. The returned function accepts arguments in same order as initially defined in *args. Uses sympy symbols from class attributes syms and variables (in the same order) if no *args is passed Leaving *args empty is recommended.

Returns

  • tuple – arguments to be passed in the returned function in exact order.

  • function – Lambdified function which accepts and returns numerical quantities.