Created
January 18, 2018 03:21
-
-
Save miguelgondu/2fb6d97291a1478d8522ad7b9410748c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Importing the library " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import generalrepytivity as gr\n", | |
"import sympy" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"sympy.init_printing(use_latex=True)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Creating tensors " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"t, x, y, z = sympy.symbols('t x y z')\n", | |
"values = {\n", | |
" ((0,1), (1, 3)): x**2 + y**2,\n", | |
" ((1,2), (0, 0)): sympy.sin(t)\n", | |
"}\n", | |
"\n", | |
"Gamma = gr.Tensor([t, x, y, z], (2,2), values)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$(x^{2} + y^{2})\\partial/\\partial t \\otimes \\partial/\\partial x \\otimes dx \\otimes dz + (\\sin{\\left (t \\right )})\\partial/\\partial x \\otimes \\partial/\\partial y \\otimes dt \\otimes dt$" | |
], | |
"text/plain": [ | |
"(x**2 + y**2)t \\otimes x \\otimes x* \\otimes z* + (sin(t))x \\otimes y \\otimes t* \\otimes t*" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"Gamma" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"Gamma[(0,1), (1,3)] == x**2 + y**2" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Metrics " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Gödel " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$(e^{x_{1}})dx_0 \\otimes dx_2 + (1)dx_0 \\otimes dx_0 + (-1)dx_1 \\otimes dx_1 + (\\frac{e^{2 x_{1}}}{2})dx_2 \\otimes dx_2 + (e^{x_{1}})dx_2 \\otimes dx_0 + (-1)dx_3 \\otimes dx_3$" | |
], | |
"text/plain": [ | |
"(exp(x_1))x_0* \\otimes x_2* + (1)x_0* \\otimes x_0* + (-1)x_1* \\otimes x_1* + (exp(2*x_1)/2)x_2* \\otimes x_2* + (exp(x_1))x_2* \\otimes x_0* + (-1)x_3* \\otimes x_3*" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"x0, x1, x2, x3 = sympy.symbols('x_0 x_1 x_2 x_3')\n", | |
"a = sympy.Symbol('a')\n", | |
"A = sympy.Matrix([\n", | |
" [1, 0, sympy.exp(x1), 0],\n", | |
" [0, -1, 0, 0],\n", | |
" [sympy.exp(x1), 0, sympy.exp(2*x1)/2, 0],\n", | |
" [0,0,0,-1]])\n", | |
"\n", | |
"g_godel = gr.get_tensor_from_matrix(A, [x0, x1, x2, x3])\n", | |
"g_godel" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Schwarzschild " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$(r^{2})d\\theta \\otimes d\\theta + (\\frac{1}{- \\frac{2 m}{r} + 1})dr \\otimes dr + (\\frac{2 m}{r} - 1)dt \\otimes dt + (r^{2} \\sin^{2}{\\left (\\theta \\right )})d\\phi \\otimes d\\phi$" | |
], | |
"text/plain": [ | |
"(r**2)\\theta* \\otimes \\theta* + (1/(-2*m/r + 1))r* \\otimes r* + (2*m/r - 1)t* \\otimes t* + (r**2*sin(\\theta)**2)\\phi* \\otimes \\phi*" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"t, r, theta, phi = sympy.symbols('t r \\\\theta \\\\phi')\n", | |
"m = sympy.Symbol('m')\n", | |
"values = {\n", | |
" ((), (0,0)): -(1-2*m/r),\n", | |
" ((), (1,1)): 1/(1-2*m/r),\n", | |
" ((), (2,2)): r**2,\n", | |
" ((), (3,3)): r**2*sympy.sin(theta)**2\n", | |
"}\n", | |
"g_sch = gr.Tensor([t, r, theta, phi], (0, 2), values)\n", | |
"g_sch" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## FRLW " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$(\\epsilon^{2} x_{0}^{2 q})dx_2 \\otimes dx_2 + (\\epsilon^{2} x_{0}^{2 q})dx_1 \\otimes dx_1 + (-1)dx_0 \\otimes dx_0 + (\\epsilon^{2} x_{0}^{2 q})dx_3 \\otimes dx_3$" | |
], | |
"text/plain": [ | |
"(\\epsilon**2*x_0**(2*q))x_2* \\otimes x_2* + (\\epsilon**2*x_0**(2*q))x_1* \\otimes x_1* + (-1)x_0* \\otimes x_0* + (\\epsilon**2*x_0**(2*q))x_3* \\otimes x_3*" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"x0, x1, x2, x3 = sympy.symbols('x_0 x_1 x_2 x_3')\n", | |
"epsilon, q = sympy.symbols('\\\\epsilon q')\n", | |
"A = epsilon * (x0 ** q)\n", | |
"g_matrix = sympy.diag(-1, A**2, A**2, A**2)\n", | |
"g_FRLW = gr.get_tensor_from_matrix(g_matrix, [x0, x1, x2, x3])\n", | |
"g_FRLW" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# `Spacetime` objects " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"Godel_spacetime = gr.Spacetime(g_godel)\n", | |
"Sch_spacetime = gr.Spacetime(g_sch)\n", | |
"FRLW_spacetime = gr.Spacetime(g_FRLW)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"Sch_spacetime.Ric == 0" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Printing a summary in LaTeX" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"Godel_spacetime.print_summary('godel.tex', _format='tex')" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment