We need to make sympy.diffgeom and sympy.tensor.tensor work together.
Unfortunately the way is still long.
Basically, sympy.tensor.tensor is meant to represent tensors by a symbol.
It currently supports tensor polynomials in the abstract index notation,
but I am (slowly) working on expressing every kind of expression and in the
future I also plan to add the standard Einstein index notation.
A tensor is represented by a tensor head (say, A) and its indices (say, i0,
i1, i2)
A(i0) is a contravariant vector, A(-i0) is a covariant vector, A(i0)*A(-i0)
is a contraction.
I added the possibility of injecting components data by a command such as
A(i0).data = [E, px, py, pz], unfortunately that module does not handle the
change of coordinates nor binds that components to a particular basis. That
should eventually be rewritten.
If you are interested to contribute, feel free to join!
On Thursday, September 11, 2014 1:42:46 PM UTC, Simon Hirscher wrote:
>
> Hi,
>
> I'm working on an extension for sympy.diffgeom. Since expressions
> often get very complicated in differential geometry, it sometimes
> makes sense to e.g. simply keep a tensor as the indexed symbol it
> is, sometimes one inserts its actual components' values (and
> tries to simplify further). Put differently, my mathematical
> objects (mostly tensors) carry names but also have values and I'd
> like to let the user decide when he wants use what and enable him
> to replace names by their values later on (without the need for
> him to use replace()/subs() because this requires way too much
> manual effort).
>
> Basically, this is the analogy of the famous pitfall:
>
> >>> x, y = symbols('x, y')
> >>> y = x + 2
> >>> x = 2
> >>> y
> x + 2
>
> whereas I would actually like to provide a way to do exactly
> this: Replace the symbol 'x' by its value later on.
>
> (Obviously, this would allow lazy calculation of tensor
> components. Hence, the user could build expressions involving
> tensors without needing to calculate all of their components
> first – after all, he might only need some of them.)
>
> So: Are there any best practices in this regard or is there even
> a general function in SymPy to expand/evaluate such abstract
> symbols in terms of their (still abstract/non-numerical) values?
>
> I imagine something like this:
>
> >>> R[0, 1, 0, 1]
> R_{0101}
> >>> R[0, 1, 0, 1].expand() (or .eval()/.doit()/.compute() or something)
> <some complicated expression in terms of coordinate functions>
>
> Thank you for your time!
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/1daa636c-9d92-4785-b555-f0451faec8a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.