from scipy.integrate import odeint from sympy import lambdify, N, Function, Derivative, solve from sympy.abc import a, b, c, d, e, f, g, h, i, j, k from sympy.utilities.lambdify import lambdify, implemented_function print '\n\n' # m_earth = 6e24 #kilograms # m = m_earth # rs = 8.87e-3 rs = 2.95e3 t, r, theta, phi, tau = gp.symbols('t r \\theta \phi \\tau') coordinates = gp.Coordinates('\chi', [t, r, theta, phi]) # Metric2D = gp.diag(-(1-2*m/r), 1/(1-2*m/r), r**2, gp.sin(theta)*r**2) Metric2D = gp.diag(-(1 - rs / r), 1 / (1 - rs / r), r**2, gp.sin(theta) * r**2) gtensor = gp.MetricTensor('g', coordinates, Metric2D) w = gp.Geodesic('w', gtensor, tau) d2t = lambda a, b, c, d, e, f, g, h: (solve(w(1), Derivative(t(tau), tau, tau)) [0].subs({ t(tau): a, r(tau): b, theta(tau): c, phi(tau): d, Derivative(t(tau), tau): e, Derivative(r(tau), tau): f, Derivative(theta(tau), tau): g, Derivative(phi(tau), tau): h, }))
import gravipy import numpy as np import matplotlib.pyplot import sympy # gravipy.init_printing() t, m,r,theta,phi,tau = gravipy.symbols('t M r \\theta \phi \\tau') x = gravipy.Coordinates('\chi', [t, r, theta, phi]) Metric = gravipy.diag(-(1-2*m/r), 1/(1-2*m/r), r**2, r**2*gravipy.sin(theta)**2) Metric2D = gravipy.diag(-(1-2*m/r), 1/(1-2*m/r), r**2, r**2) Metric_weak = gravipy.diag(-(1+2*m/r), (1+2*m/r), (1+2*m/r), (1+2*m/r)) g = gravipy.MetricTensor('g', x, Metric2D) w = gravipy.Geodesic('w', g, tau) print w(gravipy.All)