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', name=None)[source]¶ Bases:
object
Base Class for Tensor manipulation
Constructor and Initializer
- Parameters
- 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’
ValueError – Raised when
config
implies order of Tensor different than that indicated by shape ofarr
-
property
order
¶ Returns the order of the Tensor
-
property
config
¶ Returns the configuration of covariant and contravariant indices
-
tensor
()[source]¶ Returns the sympy Array
- Returns
Sympy Array object
- Return type
ImmutableDenseNDimArray
-
subs
(*args)[source]¶ 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
-
class
einsteinpy.symbolic.tensor.
BaseRelativityTensor
(arr, syms, config='ll', parent_metric=None, variables=[], functions=[], name='GenericTensor')[source]¶ Bases:
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
-
variables
¶ free variables in the tensor expression other than the variables describing space-time axis.
- Type
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 (str or None) – Name of the Tensor. Defaults to “GenericTensor”.
- 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.
ValueError – Raised when argument
syms
does not agree with shape of argumentarr
-
property
parent_metric
¶ Returns the Metric from which Tensor was derived/associated, if available.
-
symbols
()[source]¶ 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
-
tensor_lambdify
(*args)[source]¶ 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 attributessyms
andvariables
(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.
-