bshoshany / OGRe

An object-oriented general relativity package for Mathematica.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Up and Down indexes

NailGit opened this issue · comments

I read your documentation but did not find operators to down or up index and obtain an object of OGRe. For example, to obtain a contravariant metric as the OGRe object I use TNewTensor["svu", "sv", "co", {1, 1}, TGetComponents["sv", {1, 1}, "co"], "svu"], where "sv" is the metric {-1,-1}, which was defined at the beginning, "co" is my coordinates. After this operation, the OGRe object {1,1} appears with the name svu. But this is rather long and inconvenient. If I use TGetComponents["sv", {1, 1}, "co"], this is not an object of OGRe, but a simple List of Mathematica. Maybe possible to make an operator with more simple syntax than I showed above? Something like TDown and TUp with marking the number of indexes that have to be down or up.

Thank you for the suggestion. However, I think you misunderstand how OGRe works. A tensor in OGRe is an abstract object with no particular index configuration. There is only a number of indices, without indicating which indices are up and which are down. Since a tensor doesn't have a specific index configuration, it doesn't make sense to have an "index up" or "index down" operation on a tensor - such an operation will have no effect.

Instead, the way OGRe works is that when you either display the tensor (with TShow[] or TList[]) or get its components (with TGetComponents[]) you choose which index configuration to use at that time. So for example, if your tensor is named "MyTensor" and has 2 indices, you can run

TShow["MyTensor", {1, 1}]
TShow["MyTensor", {1, -1}]
TShow["MyTensor", {-1, 1}]
TShow["MyTensor", {1, -1}]

and in each case you will get a different index configuration. Similarly for TList[] and TGetComponents[].

If you do not specify an index configuration, a default one will be used, but the default configuration only exists for convenience so you can omit the index configuration when you call these functions; the tensor itself has no index configuration. You can change the default configuration using TChangeDefaultIndices[].

Please see the documentation under "raising and lowering indices" for more information.

Hope this helps!

Thank you for your comments. I understood well about indexes from your documentation. Maybe I made the question not so clear. I'd like to ask once more with an example. I defined metric TNewMetric["sv", "co", {{a, 0}, {0, -1/a}}, "g"]. TInfo["sv"] gives Default Indices: {-1, -1}}, - it is tensor g_{\mu\nu}. By using TCalc I can calculate contraction TCalc["ff"["\mu\rho]"], "sv"["\mu\nu"] . "sv"["\nu\rho"], "gg"] I obtain object gg_{\mu\rho} which is tensor {-1,-1}: gg_{\mu\rho} = g_{\mu\nu} g_{\phi\rho}g^{\nu\phi} = g_{\mu\rho}. The tensor g^{\nu\phi} appears automatically as you wrote in the documentation.

But I'd like to calculate tensor h^\mu_\rho = g^{\mu \nu} g_{\nu\rho} which has to be the object of OGRe {1,-1}. But I have defined so g_{\mu\nu}. For this reason I defined tensor svu TNewTensor["svu", "sv", "co", {1, 1}, TGetComponents["sv", {1, 1}, "co"], "svu"] which is tensor {1,1} and then can calculate contraction which I need TCalc["ss"["\mu\nu"], "sv"["\mu\nu]"] . "svu"["\nu\rho"], "Dd"]. This is tensor {1,-1}, Dd^\mu_\nu and it is the object of OGRe and I can use it in my next calculations.

The hh, defined by relation hh = TShow["sv", {1, 1}] is not an object of OGRe. TInfo["hh"] gives "The tensor "hh" does not exist".

But I'd like to calculate tensor h^\mu_\rho = g^{\mu \nu} g_{\nu\rho} which has to be the object of OGRe {1,-1}.

Again, I'm sorry, but you misunderstand how OGRe works. There's no such thing as "an object with index {1,-1}". Tensor objects do not have a specific index configuration.

What you're trying to do is define two tensor objects which are actually the same tensor. The index configuration you use when you define the tensor is meaningless, the tensor itself is an abstract entity with no index configuration attached to it.

TShow[] is only used to show that abstract tensor with a specific index configuration. It doesn't "convert" it from one index configuration to another because it doesn't have an index configuration in the first place.

For the same tensor, you can run TShow[] with two different index configurations, and in each case you will get a different representation of that tensor.

The output of TShow[] is visual, it is not an expression that can be manipulated, so something like hh = TShow["sv", {1, 1}] doesn't make any sense.

The default index configuration is just for convenience. The contraction you are trying to calculate will work regardless of what the default index configuration of the tensor is. The default index configuration is only used for displaying the tensor, not for calculations of any sort.

So if you want to do this contraction, just go ahead and do it, and then display the result in whatever index configuration you want using TShow[]. You don't need to redefine tensors in order to calculate this contraction. TCalc[] chooses which indices to use on its own, based on what works best for the particular tensor expression you wrote.

Mathematically, $h^\mu_\rho = g^{\mu \nu} g_{\nu\rho}$ can also be calculated as $h^\mu_\rho = g^\mu_\nu g^\nu_\rho$. The contracted indices can be either upper-lower or lower-upper, in both cases you will get the same result. When you use TCalc[] it will use one of these two options based on what the algorithm dictates, but it doesn't matter which one it uses, since the final result does not depend on the index configuration used.

The final tensor you will get from TCalc[] will again be an abstract tensor with no specific index configuration. So later you can display it as either h $h^\mu_\rho$ or $h_\mu^\rho$ or $h_{\mu\rho}$ or $h^{\mu\rho}$ by choosing a different index configuration when you call TShow[]. But all 4 are just different representations of the same tensor object.

Hope this clarifies things!

Thank you. I understand now the ideology of your package more clear. Indeed, all info about objects is encoded in the first definition. In fact, you realized in the package the main basis of the tensors - the tensor does not depend on the system of coordinates. Thank you once more.

The last question is out of the discussion. Could you explain to me how can I use the TeX language here in github? I used TeX code but it was not compiled, but in your reply, TeX symbols have been compiled.

Great! I'm glad I was able to help :)

To use TeX on GitHub, you need to put the TeX code inside dollar signs: $g_{\mu\nu}$ will be shown as $g_{\mu\nu}$.

But to be honest, TeX support on GitHub is pretty bad. You can see that in my reply, some TeX codes were compiled and other were not. For example, if I write the same code from above: $g_{\mu\nu}$ a second time, now it doesn't compile. I have no idea why...

Thank you. It is so simple, as in usual TeX :).
Thank you for your job, it is really helpful in calculations.

No problem! Please feel free to let me know if you have any more questions, either by opening a GitHub issue or by email.