Vector class.
Setup is done by defining a set of basis vectors in static function ‘Bases’. The linear combination of scalar (commutative) sympy quatities and the basis vectors form the vector space. If the number of basis vectors is ‘n’ the metric tensor is formed as an n by n sympy matrix of scalar symbols and represents the dot products of pairs of basis vectors.
Dot product of two basis vectors returns a Symbol
Generate basis of vector space as tuple of vectors and associated metric tensor as Matrix. See str_array(base,n) for usage of base and n and str_array(metric) for usage of metric.
To overide elements in the default metric use the character ‘#’ in the metric string. For example if one wishes the diagonal elements of the metric tensor to be zero enter metric = ‘0 #,# 0’.
If the basis vectors are e1 and e2 then the default metric -
Vector.metric = ((dot(e1,e1),dot(e1,e2)),dot(e2,e1),dot(e2,e2))
becomes -
Vector.metric = ((0,dot(e1,e2)),(dot(e2,e1),0)).
The function dot returns a Symbol and is symmetric.
The functions ‘Bases’ calculates the global quantities: -
- Vector.basis
- tuple of basis vectors
- Vector.base_to_index
- dictionary to convert base to base inded
- Vector.metric
- metric tensor represented as a matrix of symbols and numbers