GTRPy - A python package for General Relativity Related Calculations

In summary: In that case, you cannot put ##F(r)## in the metric tensor, because it would be a constant. But you can put any other symbol in there, as long as it is a constant.
  • #1
Arman777
Insights Author
Gold Member
2,168
192
Hello, everyone

I am now working on this project quite a while now and I just wanted to share it with this forum, which I was a member for a long time. I am working on a python application about GR and I believe I managed to create a very user-friendly layout.

It's called GTRPy, and it allows you to calculate the well-known tensors in General Theory of Relativity without writing a single line of code. Furthermore, you can apply many operations to 6 different type of fields, in both 3D and 4D. It's a GUI application and works in Linux and macOS. If you want to try it out please check my signature or here is the link:

https://github.com/seVenVo1d/GTRPy

If you would like to contribute or make suggestion please feel free to do so.

Thanks,
Arman

PS: If this is not a good place to post this thread moderators can move my post...
 
  • Like
Likes haushofer, vanhees71 and Dale
Technology news on Phys.org
  • #2
Arman777 said:
It's called GTRPy, and it allows you to calculate the well-known tensors in General Theory of Relativity without writing a single line of code. Furthermore, you can apply many operations to 6 different type of fields, in both 3D and 4D. It's a GUI application and works in Linux and macOS. If you want to try it out please check my signature or here is the link:

https://github.com/seVenVo1d/GTRPy
From a quick look at your github page, I'm guessing you use SymPy under the hood? Do you have any examples of how one could specify, say, the generic components of a spherically symmetric metric, and then solve the Einstein equations so that the Schwarzschild solution pops? What about other more complicated metrics?

I ask this because I've previously tried to use SymPy for GR-like tasks. It was ok for simple things, but choked when it encountered a seriously nontrivial expression. The "simplify" capabilities of all the symbolic math packages seem limited in this regard, alas, though I'd love to find one that would prove me wrong. :oldfrown:
 
  • Like
Likes Arman777 and vanhees71
  • #4
strangerep said:
From a quick look at your github page, I'm guessing you use SymPy under the hood?
Yes indeed that is the case.

strangerep said:
Do you have any examples of how one could specify, say, the generic components of a spherically symmetric metric, and then solve the Einstein equations so that the Schwarzschild solution pops? What about other more complicated metrics?
The program sadly cannot perform that operation. The extra variables (variables other than the coordinate system) put in the metric is taken as constants and not as variables. This means that if you put any symbol other than the coordinate system, it will considered as a constant...Maybe I can change that in the future but currently that is the state.

However, if you give me the Schwarzschild Metric or any type of metric, that has constant parameters in it, it will calculate the Einstein Tensor correctly.

strangerep said:
I ask this because I've previously tried to use SymPy for GR-like tasks. It was ok for simple things, but choked when it encountered a seriously nontrivial expression. The "simplify" capabilities of all the symbolic math packages seem limited in this regard, alas, though I'd love to find one that would prove me wrong.
That was also a problem for me at the begining but I think I have managed to solve it by using simplify(nsimplify(xobject))

If you have an example that contains constant variables in the metric, and of course complex enough, I can show you the result and you can determine if the simplification process is good enough or not ?

PS: However, if you know somehow what that function is w.r.t ##(t, r, \theta, \phi)##, then you can put it inside the GTRPy and it will calculate the result correctly.

PS2: I will try to add that functionality to the GTRPy...Thanks for the feedback.
 
Last edited:
  • #5
vanhees71 said:
How about Einsteinpy?
That is also a great tool. However, I think GTRPy is better in some regards w.r.t einsteinpy

1) GTRPy is GUI based and more user-friendly than einsteinpy
2) GTRPy can also perform field operations
 
Last edited:
  • Like
Likes vanhees71
  • #6
Arman777 said:
The program sadly cannot perform that operation. The extra variables (variables other than the coordinate system) put in the metric is taken as constants and not as variables. This means that if you put any symbol other than the coordinate system, it will considered as a constant...Maybe I can change that in the future but currently that is the state.

However, if you give me the Schwarzschild Metric or any type of metric, that has constant parameters in it, it will calculate the Einstein Tensor correctly.
Let me clarify this statement a bit more...

The one important point in GTRPy is that the variables defined in the metric tensor **must be constant**. For example, you can write the Schwarzschild Coordinates System as


g = diag[-(1-r_s/r), (1-r_s/r)**(-1), r^2, r^2sin^2(theta)]

and that is totally fine for GTRPy, since ##r_s = 2GM/c^2## and that is a constant.
Let us suppose you have another variable called ##F(r)## which is a function of ##r##. And the metric is given as

g = diag[-1, F, r^2, r^2sin^2(theta)]

Sadly, the GTRPy will interpret this ##F## as a constant and not as a function of ##r##. So the result will be wrong. On the other hand, if you know what that function is, for instance if ##F(r) = r^3##, then you should write ##r^3## instead of ##F## and use the GTRPy in that way. So you should write the metric as


g = diag[-1, r^3, r^2, r^2sin^2(theta)]

and now, the GTRPy will work perfectly fine.
 
  • #7
Arman777 said:
Sadly, the GTRPy will interpret this ##F## as a constant and not as a function of ##r##. So the result will be wrong. On the other hand, if you know what that function is, for instance if ##F(r) = r^3##, then you should write ##r^3## instead of ##F## and use the GTRPy in that way. So you should write the metric as
g = diag[-1, r^3, r^2, r^2sin^2(theta)]
and now, the GTRPy will work perfectly fine.
This is not much good if one wants to find solutions. I.e., write the function as ##F(r)## and have the system do the symbolic (partial!) derivatives correctly, then solve the coupled PDEs...
 
  • Like
Likes vanhees71, Arman777 and PeterDonis
  • #8
strangerep said:
This is not much good if one wants to find solutions. I.e., write the function as ##F(r)## and have the system do the symbolic (partial!) derivatives correctly, then solve the coupled PDEs...
Fair enough :approve:

Indeed that Is the case. However, the program is still in the development process. I can probably implement a custom function support but I am not sure I can add solving coupled PDE’s. Maybe I can…

Feedback is very important for me and thanks for your sharing your thoughts.

PS: If I add such feature(s) I‘ll post an update.
 

1. What is GTRPy and what does it do?

GTRPy is a python package that allows for General Relativity related calculations to be performed efficiently and accurately. It provides a variety of functions and tools for working with tensors, metrics, and other mathematical objects commonly used in General Relativity.

2. Is GTRPy suitable for beginners in General Relativity?

Yes, GTRPy is designed to be user-friendly and accessible for beginners in General Relativity. It includes detailed documentation and examples to help users understand the functions and how to use them in their calculations.

3. Can GTRPy handle calculations for both curved and flat spacetimes?

Yes, GTRPy can handle calculations for both curved and flat spacetimes. It has built-in functions for creating and manipulating metrics for both types of spacetimes, as well as tools for computing geodesics and solving Einstein's field equations.

4. Are there any specific requirements for using GTRPy?

GTRPy requires Python 3.6 or higher and the NumPy and SymPy libraries to be installed. It is also recommended to have a basic understanding of General Relativity concepts and equations in order to effectively use the package.

5. Can GTRPy be used for research purposes?

Yes, GTRPy can be used for research purposes. It is designed to be a versatile tool for performing various calculations and analyses in General Relativity, making it suitable for use in research projects and studies.

Similar threads

  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
3
Views
307
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
11
Views
2K
  • STEM Academic Advising
Replies
6
Views
1K
  • Special and General Relativity
Replies
11
Views
135
  • STEM Academic Advising
2
Replies
41
Views
7K
Back
Top