Ask Your Question

How to convert a list to components of a PseudoRiemannian metric

asked 2022-05-20 17:34:14 +0200

Lucchini gravatar image

Good afternoon. I work with theoretical physics, and I build Einstein's Tensor from an extensive metric. So I decided to use list comprehension in order to make the construction of curvature tensors simpler. However, after finding the Einstein tensor, I need to work with some components separately, but I am not able to return the list in components of a PseudoRiemannian metric. Is there any possibility to do this conversion?

Thank you in advance for your attention.

edit retag flag offensive close merge delete



Please give us some implementation details, else there is no chance to give a pointed answer. If the issue is just an issue of using a list comprehension, then please try to isolate the issue in a minimal framework, then give the related details only. Also a bigger example is welcome, but please arrange that it comes best with minimal code, possibly with simplified geometric data (making everything "flat and boring" in the physical world), if sage special libraries and/or classes and/or function are used, especially when the results are rather involved in the typed used. Best, provide some lines of code, this makes it simpler for potential answerers to react.

dan_fulea gravatar imagedan_fulea ( 2022-05-22 19:36:40 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2022-05-23 08:17:32 +0200

eric_g gravatar image

I am not sure to fully understand what you are looking for (as @dan_fulea pointed out, you should provide some simple example), but could it be the operator [:]? The later can be used either to initialize the components of a tensor field from a given list or to get all the components as a list. Here is some example:

sage: M = Manifold(2, 'M', structure='Riemannian')
sage: X.<x,y> = M.chart()
sage: g = M.metric()
sage: g[:] = [[1+x^2, x*y], [x*y, 1+y^2]]  # set components to the values in the r.h.s. list
sage: g.display()
g = (x^2 + 1) dx⊗dx + x*y dx⊗dy + x*y dy⊗dx + (y^2 + 1) dy⊗dy
sage: g[:]  # returns all components as a matrix
[x^2 + 1     x*y]
[    x*y y^2 + 1]
sage: list(g[:])  # returns all components as a list
[(x^2 + 1, x*y), (x*y, y^2 + 1)]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-05-20 17:34:14 +0200

Seen: 216 times

Last updated: May 23 '22