import gravipy as gp import numpy as np import matplotlib.pyplot as plt 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,
import gravipy import numpy as np import matplotlib.pyplot import sympy from scipy.integrate import odeint from sympy import lambdify from sympy.abc import a,b,c,d import sys t,r,theta,phi,tau = gravipy.symbols('t r \\theta \phi \\tau') c = gravipy.Coordinates('\chi', [t, r, theta, phi]) m = 5 Metric2D = gravipy.diag(-(1-2*m/r), 1/(1-2*m/r), r**2, r**2) g = gravipy.MetricTensor('g', c, Metric2D) w = gravipy.Geodesic('w', g, tau) d2t = sympy.solve(w(1),sympy.Derivative(t(tau),tau,tau))[0].subs({sympy.Derivative(t(tau),tau):a,sympy.Derivative(r(tau),tau):b,sympy.Derivative(phi(tau),tau):c,sympy.Derivative(theta(tau),tau):d}) d2r = sympy.solve(w(2),sympy.Derivative(r(tau),tau,tau))[0].subs({sympy.Derivative(t(tau),tau):a,sympy.Derivative(r(tau),tau):b,sympy.Derivative(phi(tau),tau):c,sympy.Derivative(theta(tau),tau):d}) d2theta = sympy.solve(w(3),sympy.Derivative(theta(tau),tau,tau))[0].subs({sympy.Derivative(t(tau),tau):a,sympy.Derivative(r(tau),tau):b,sympy.Derivative(phi(tau),tau):c,sympy.Derivative(theta(tau),tau):d}) d2phi = sympy.solve(w(4),sympy.Derivative(phi(tau),tau,tau))[0].subs({sympy.Derivative(t(tau),tau):a,sympy.Derivative(r(tau),tau):b,sympy.Derivative(phi(tau),tau):c,sympy.Derivative(theta(tau),tau):d}) d2tf = lambdify((a,b,c,d,t(tau),r(tau),theta(tau),phi(tau)),d2t,modules="numpy") d2rf = lambdify((a,b,c,d,t(tau),r(tau),theta(tau),phi(tau)),d2r,modules="numpy") d2thetaf = lambdify((a,b,c,d,t(tau),r(tau),theta(tau),phi(tau)),d2theta,modules="numpy") d2phif = lambdify((a,b,c,d,t(tau),r(tau),theta(tau),phi(tau)),d2phi,modules="numpy")