Skip to content

Commit

Permalink
adding pip support and many changes
Browse files Browse the repository at this point in the history
  • Loading branch information
seVenVo1d committed Jan 18, 2023
1 parent f23e269 commit 5c78fdb
Show file tree
Hide file tree
Showing 157 changed files with 330 additions and 295 deletions.
54 changes: 29 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,35 @@

GRPy is a python package that allows you to calculate the well-known tensors in general relativity, without *writing a single line of code*. In addition, you can apply many operations to 6 different type of fields, *in both 4D and 3D*.

> It's tested for GNU/Linux, however it should also work in Windows and Mac. If you ever encounter with a problem, feel free to create an issue.
> It's tested for GNU/Linux, however it should also work in MacOS. If you ever encounter with a problem, feel free to create an issue.
## Installation

You can easily install GRPy via

python3 -m pip install grpy

Later on, run

python3 -m pip install nump Pillow pysimplegui sympy

to install the requirements. If you want to you can also just clone the repository via

git clone https://github.com/seVenVo1d/GRPy.git

and install the requirements via

python3 -m pip install -r requirements.txt

## User Guide

To start *GRPy*, simply run

python3 -m grpy.run

This will create `logs` directory, which will contain the outputs of the performed operations.

Please take a look at the `docs/user_guide.md` for a summary of the GRPy. To see more detailed examples, you can look at the `demos` directory.

## Current Features

Expand Down Expand Up @@ -51,30 +79,6 @@ Currently, there are 6 different field objects that you can carry out operations
:-------------------------:|:-------------------------:|:-------------------------:
![3d_scalar](https://user-images.githubusercontent.com/45866787/212769736-171c0a1f-63a2-44f4-96ab-b86bf6eeef8f.png) |![3d_vector](https://user-images.githubusercontent.com/45866787/212769750-de725b69-0a9f-460f-b451-5e03ecd758c5.png) | ![3d_tensor](https://user-images.githubusercontent.com/45866787/212769770-1679b3c4-1b11-48c8-805e-0e51bb4a177b.png)

## Installation

You can easily install GRPy by either cloning the repository

git clone https://github.com/seVenVo1d/grpy.git

or via downloading as ZIP. Later on, you can simply run

python3 -m pip install -r requirements.txt

to install the requirements.

### pyclean support (optional)

I have added an optional code block in `grpy.py`, that will delete all the `.pyc` files and `__pycache__` directories. These are created after the program starts and can be annoying for some people. If you want to try it, install [pyclean](https://pypi.org/project/pyclean/) via

python3 -m pip install pyclean

and uncomment the lines in the file.

## User Guide

Please take a look at the `docs/user_guide.md` for a summary of the GRPy. To see more detailed examples, you can look at the `demos` directory.

## Upcoming Features

1. Raising and lowering indices for a given tensor field
Expand Down
2 changes: 1 addition & 1 deletion docs/equations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Equations

This is the list of the all equations used in the program. Now, you can easily compare the written equations with the code (under the `src` directory).
This is the list of the all equations used in the program. Now, you can easily compare the written equations with the code (under the `grpy/src` directory).

## Tensors

Expand Down
2 changes: 1 addition & 1 deletion docs/image_size_data.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Image Size Data

Storing the size of the images used in `res` directory. These values are meant to use in `tools/latex_image_producer.py`
Storing the size of the images used in `grpy/res` directory.

## Main Page

Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You can run the program by simply typing

python3 grpy.py
python3 -m grpy.run

![greetings](https://user-images.githubusercontent.com/45866787/212770215-87e7f60e-54cd-4dcd-b625-31a13ab2ded0.png)

Expand Down
Empty file added grpy/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion equations/grtensorsEP.py → grpy/equations/grtensorsEP.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ========== PRODUCING EQUATIONS FOR GR-TENSORS ==========
from sympy import latex

from src.grtensors import *
from grpy.src.grtensors import *


def tensor_ep(metric_tensor, coord_sys, tensor_object, tensor_type=''):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ========== PRODUCING EQUATIONS FOR SCALAR FIELDS ==========
from sympy import latex

from src.fields.scalarfield import ScalarField
from grpy.src.fields.scalarfield import ScalarField


def cd_scalarfield_ep(coord_sys, scalar_field, index_symbol):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ========== PRODUCING EQUATIONS FOR TENSOR FIELDS ==========
from sympy import latex

from src.fields.tensorfield import TensorField
from grpy.src.fields.tensorfield import TensorField


def cd_tensorfield20_ep(metric_tensor, coord_sys, tensor_field, index_symbol):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ========== PRODUCING EQUATIONS FOR VECTOR FIELDS ==========
from sympy import latex

from src.fields.vectorfield import VectorField
from grpy.src.fields.vectorfield import VectorField


def vry_vectorfield10_ep(metric_tensor, coord_sys, vector_field):
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
24 changes: 10 additions & 14 deletions grpy.py → grpy/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# ========== GRPy ==========
import os
import PySimpleGUI as sg

from screen.screen3D.mainpage import grpy_3d
from screen.screen4D.mainpage import grpy_4d
from grpy.screen.screen3D.mainpage import grpy_3d
from grpy.screen.screen4D.mainpage import grpy_4d


# ========== Creating logs directory ==========
current_directory = os.getcwd()
final_directory = os.path.join(current_directory, r'logs')
if not os.path.exists(final_directory):
os.makedirs(final_directory)


# ========== PySimpleGUI Color Theme ==========
Expand Down Expand Up @@ -31,15 +39,3 @@
grpy_4d()
else:
grpy_3d()


# ========== pyclean support ==========
# The code block below will delete all the .pyc files and __pycache__ directories.
# If you want to try it, download the pyclean package, and uncomment the lines below

# try:
# import os
# os.system('pyclean .')
# print('The cleaning successfully ended.')
# except:
# print('Something went wrong during the cleaning process!')
4 changes: 2 additions & 2 deletions screen/grtensorsGUI.py → grpy/screen/grtensorsGUI.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PySimpleGUI as sg
from sympy import preview

from equations.grtensorsEP import *
from tools.image_resizer_grtensor import *
from grpy.equations.grtensorsEP import *
from grpy.tools.image_resizer_grtensor import *


# ========== IMPORTANT VARIABLES ==========
Expand Down
File renamed without changes.
61 changes: 32 additions & 29 deletions screen/screen3D/mainpage.py → grpy/screen/screen3D/mainpage.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import importlib
import PySimpleGUI as sg

from sympy import symbols, sympify

from screen.grtensorsGUI import grtensors_gui
from screen.screen3D.coordinates import coordinates3d
from screen.screen3D.scalarfieldGUI import *
from screen.screen3D.vectorfieldGUI import *
from screen.screen3D.tensorfieldGUI import *
from grpy.screen.grtensorsGUI import grtensors_gui
from grpy.screen.screen3D.coordinates import coordinates3d
from grpy.screen.screen3D.scalarfieldGUI import *
from grpy.screen.screen3D.vectorfieldGUI import *
from grpy.screen.screen3D.tensorfieldGUI import *


# ========== INPUT VARIABLES ==========


# GRTensor objects
GRTensor_objects = [
'Metric Tensor', 'Inverse Metric Tensor', 'Christoffel Symbol',
Expand All @@ -28,9 +29,11 @@
# Available/Predefined Coordinate Systems
available_coord_sys = [ 'Cartesian Coordinates', 'Cylindrical Coordinates', 'Spherical Coordinates']

# Image Path
resPATH = importlib.machinery.PathFinder().find_module("grpy").get_filename()[:-11] + 'res'

# ========== GRPy - MAIN PAGE ==========

# ========== GRPy - MAIN PAGE ==========

def grpy_3d(coordinate_type='Spherical Coordinates'):
"""
Expand All @@ -45,46 +48,46 @@ def grpy_3d(coordinate_type='Spherical Coordinates'):

GRTensors_col1 = [
[sg.Button('Metric Tensor', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/metrictensor.png')],
sg.Image(resPATH + r'/images3D/metrictensor.png')],
[sg.Button('Inverse Metric Tensor', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/inversemetrictensor.png')],
sg.Image(resPATH + r'/images3D/inversemetrictensor.png')],
[sg.Button('Christoffel Symbol', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/chrissymbol.png')],
sg.Image(resPATH + r'/images3D/chrissymbol.png')],
[sg.Button('Riemann Tensor', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/riemanntensor.png')],
sg.Image(resPATH + r'/images3D/riemanntensor.png')],
[sg.Button('Ricci Tensor', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/riccitensor.png')]
sg.Image(resPATH + r'/images3D/riccitensor.png')]
]

GRTensors_col2 = [
[sg.Button('Ricci Scalar', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/ricciscalar.png')],
sg.Image(resPATH + r'/images3D/ricciscalar.png')],
[sg.Button('Weyl Tensor', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/weyltensor.png')],
sg.Image(resPATH + r'/images3D/weyltensor.png')],
[sg.Button('Traceless Ricci Tensor', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/tracelessriccitensor.png')],
sg.Image(resPATH + r'/images3D/tracelessriccitensor.png')],
[sg.Button('Einstein Tensor', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/einsteintensor.png')],
sg.Image(resPATH + r'/images3D/einsteintensor.png')],
[sg.Button('Kretschmann Scalar', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/kretschmannscalar.png')]
sg.Image(resPATH + r'/images3D/kretschmannscalar.png')]
]

Fields_col1 = [
[sg.Button('Scalar Field', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/scalarfield.png')],
sg.Image(resPATH + r'/images3D/scalarfield.png')],
[sg.Button('Type (1,0) Vector Field', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/vectorfield_10.png')],
sg.Image(resPATH + r'/images3D/vectorfield_10.png')],
[sg.Button('Type (0,1) Vector Field', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/vectorfield_01.png')]
sg.Image(resPATH + r'/images3D/vectorfield_01.png')]
]

Fields_col2 = [
[sg.Button('Type (2,0) Tensor Field', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/tensorfield_20.png')],
sg.Image(resPATH + r'/images3D/tensorfield_20.png')],
[sg.Button('Type (1,1) Tensor Field', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/tensorfield_11.png')],
sg.Image(resPATH + r'/images3D/tensorfield_11.png')],
[sg.Button('Type (0,2) Tensor Field', button_color='purple', size=(20, 1)),
sg.Image(r'res/images3D/tensorfield_02.png')]
sg.Image(resPATH + r'/images3D/tensorfield_02.png')]
]

GRTensors_tab = [
Expand All @@ -104,24 +107,24 @@ def grpy_3d(coordinate_type='Spherical Coordinates'):
title='Predefined Coordinates', font=('Georgia', 14), expand_x=True, element_justification='center', title_location='n')],

[sg.Frame(layout=[
[sg.Image(r'res/images3D/x0.png'),
[sg.Image(resPATH + r'/images3D/x0.png'),
sg.InputCombo(coordinate_symbols, size=(6, 1), default_value=new_coord_sys[0], font=('Tahoma', 11)),
sg.Image(r'res/images3D/x1.png'),
sg.Image(resPATH + r'/images3D/x1.png'),
sg.InputCombo(coordinate_symbols, size=(6, 1), default_value=new_coord_sys[1], font=('Tahoma', 11)),
sg.Image(r'res/images3D/x2.png'),
sg.Image(resPATH + r'/images3D/x2.png'),
sg.InputCombo(coordinate_symbols, size=(6, 1), default_value=new_coord_sys[2], font=('Tahoma', 11))]],
title='Coordinate System', font=('Georgia', 14), expand_x=True, element_justification='center', title_location='n')],

[sg.Frame(layout = [
[sg.Image(r'res/images3D/g0b.png'),
[sg.Image(resPATH + r'/images3D/g0b.png'),
sg.InputText(default_text=new_metric_tensor[0][0], size=(15, 1), font=('Tahoma', 11)),
sg.InputText(default_text=new_metric_tensor[0][1], size=(15, 1), font=('Tahoma', 11)),
sg.InputText(default_text=new_metric_tensor[0][2], size=(15, 1), font=('Tahoma', 11))],
[sg.Image(r'res/images3D/g1b.png'),
[sg.Image(resPATH + r'/images3D/g1b.png'),
sg.InputText(default_text=new_metric_tensor[1][0], size=(15, 1), font=('Tahoma', 11)),
sg.InputText(default_text=new_metric_tensor[1][1], size=(15, 1), font=('Tahoma', 11)),
sg.InputText(default_text=new_metric_tensor[1][2], size=(15, 1), font=('Tahoma', 11))],
[sg.Image(r'res/images3D/g2b.png'),
[sg.Image(resPATH + r'/images3D/g2b.png'),
sg.InputText(default_text=new_metric_tensor[2][0], size=(15, 1), font=('Tahoma', 11)),
sg.InputText(default_text=new_metric_tensor[2][1], size=(15, 1), font=('Tahoma', 11)),
sg.InputText(default_text=new_metric_tensor[2][2], size=(15, 1), font=('Tahoma', 11))],],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import importlib
import PySimpleGUI as sg

from sympy import preview, sympify

from equations.scalarfieldEP import *
from tools.image_resizer_fields3D import *
from grpy.equations.scalarfieldEP import *
from grpy.tools.image_resizer_fields3D import *


# Image Path
resPATH = importlib.machinery.PathFinder().find_module("grpy").get_filename()[:-11] + 'res'


def scalarfield_gui3d(coord_sys):
Expand All @@ -14,26 +20,26 @@ def scalarfield_gui3d(coord_sys):
coord_sys [list]: The coordinate system given as a list (e.g., [t,x,y,z])
"""
scalar_field_layout = [
[sg.Image(r'res/images3D/scalarfield.png'),
[sg.Image(resPATH + r'/images3D/scalarfield.png'),
sg.Input('0')],

[sg.Frame(layout=[
[sg.Button('Calculate', button_color='purple'),
sg.Image(r'res/images3D/cov_scalarfield.png'),
sg.Image(resPATH + r'/images3D/cov_scalarfield.png'),
sg.Text('for', font=('Verdana', 11)),
sg.Image(r'res/images3D/e.png'),
sg.Image(resPATH + r'/images3D/e.png'),
sg.InputCombo(coord_sys, default_value=coord_sys[0])]],
title='Covariant Derivative', font=('Verdana', 12), expand_x=True, element_justification='center', title_location='n')],

[sg.Frame(layout=[
[sg.Image(r'res/images3D/LX0.png'),
[sg.Image(resPATH + r'/images3D/LX0.png'),
sg.InputText(default_text='0', font=('Tahoma', 11))],
[sg.Image(r'res/images3D/LX1.png'),
[sg.Image(resPATH + r'/images3D/LX1.png'),
sg.InputText(default_text='0', font=('Tahoma', 11))],
[sg.Image(r'res/images3D/LX2.png'),
[sg.Image(resPATH + r'/images3D/LX2.png'),
sg.InputText(default_text='0', font=('Tahoma', 11))],
[sg.Button('Calculate', button_color='purple'),
sg.Image(r'res/images3D/LX_scalarfield.png')]],
sg.Image(resPATH + r'/images3D/LX_scalarfield.png')]],
title='Lie Derivative', font=('Verdana', 12), expand_x=True, element_justification='center', title_location='n')]
]
windows_scalar_field = sg.Window('Scalar Field', scalar_field_layout)
Expand Down
Loading

0 comments on commit 5c78fdb

Please sign in to comment.