Als ik de gravitatiekracht projecteer op de x, y en z-as dan wordt het ondanks een verlaging van de tolerantie toch heel traag en loopt het geheugen vol (12GB). Het zijn natuurlijk ook complexe integralen.
Code: Selecteer alles
import numpy as np
from scipy.integrate import tplquad
a=6356000 #straal bij pool
b=6378000 #straal bij evenaar
c=6378000 #straal bij evenaar
G=6.6743e-11
r_loc=1 #positie Chimay
phi_loc=0 #positie Chimay
theta_loc=np.radians(40) #positie Chimay
rho = 5515 #massa dichtheid aarde
#gravitatie: x-component
gravx = tplquad(lambda phi, theta, r: rho*r**2 *a*b*c* np.sin(theta)*G*1/((r*a*np.sin(phi)*np.cos(theta) - r_loc*a*np.sin(phi_loc)*np.cos(theta_loc) )**2 +(r*b*np.sin(phi)*np.sin(theta) - r_loc*b*np.sin(phi_loc)*np.sin(theta_loc) )**2+(r*c*np.cos(phi) - r_loc*c*np.cos(phi_loc) )**2 ) \
*(r*a*np.sin(phi)*np.cos(theta) - r_loc*a*np.sin(phi_loc)*np.cos(theta_loc))/((r*a*np.sin(phi)*np.cos(theta) - r_loc*a*np.sin(phi_loc)*np.cos(theta_loc))**2 + (r*b*np.sin(phi)*np.sin(theta) - r_loc*b*np.sin(phi_loc)*np.sin(theta_loc) )**2 + (r*c*np.cos(phi) - r_loc*c*np.cos(phi_loc) )**2 ) ,
0, 1,
lambda theta: 0, np.pi,
lambda theta, phi: 0, 2*np.pi,
epsabs=0.001, epsrel=0.001)
#gravitatie: y-component
gravy = tplquad(lambda phi, theta, r: rho*r**2 *a*b*c* np.sin(theta)*G*1/((r*a*np.sin(phi)*np.cos(theta) - r_loc*a*np.sin(phi_loc)*np.cos(theta_loc) )**2 +(r*b*np.sin(phi)*np.sin(theta) - r_loc*b*np.sin(phi_loc)*np.sin(theta_loc) )**2+(r*c*np.cos(phi) - r_loc*c*np.cos(phi_loc) )**2 ) \
*(r*b*np.sin(phi)*np.sin(theta) - r_loc*b*np.sin(phi_loc)*np.sin(theta_loc))/((r*a*np.sin(phi)*np.cos(theta) - r_loc*a*np.sin(phi_loc)*np.cos(theta_loc))**2 + (r*b*np.sin(phi)*np.sin(theta) - r_loc*b*np.sin(phi_loc)*np.sin(theta_loc) )**2 + (r*c*np.cos(phi) - r_loc*c*np.cos(phi_loc) )**2 ) ,
0, 1,
lambda theta: 0, np.pi,
lambda theta, phi: 0, 2*np.pi,
epsabs=0.001, epsrel=0.001)
#gravitatie: z-component
gravz = tplquad(lambda phi, theta, r: rho*r**2 *a*b*c* np.sin(theta)*G*1/((r*a*np.sin(phi)*np.cos(theta) - r_loc*a*np.sin(phi_loc)*np.cos(theta_loc) )**2 +(r*b*np.sin(phi)*np.sin(theta) - r_loc*b*np.sin(phi_loc)*np.sin(theta_loc) )**2+(r*c*np.cos(phi) - r_loc*c*np.cos(phi_loc) )**2 ) \
*(r*c*np.cos(phi) - r_loc*c*np.cos(phi_loc) )/((r*a*np.sin(phi)*np.cos(theta) - r_loc*a*np.sin(phi_loc)*np.cos(theta_loc))**2 + (r*b*np.sin(phi)*np.sin(theta) - r_loc*b*np.sin(phi_loc)*np.sin(theta_loc) )**2 + (r*c*np.cos(phi) - r_loc*c*np.cos(phi_loc) )**2 ) ,
0, 1,
lambda theta: 0, np.pi,
lambda theta, phi: 0, 2*np.pi,
epsabs=0.001, epsrel=0.001)