import matplotlib.pyplot as plt from numba import jit import numpy as np #GETTING PLANET POSITIONS FROM PART2 t_planets, x_planets = #load planet positions calculated in part2 masses = #get planet masses from ast2000tools.SolarSystem #MISC VALUES G = #Gravitational Constant sun_mass = #Mass of the Sun def find_planet_pos(t_planets, x_planets, t): interpolated_planet_pos = np_zeros(len(t),2) # interpolate planet positions using t_planet, x_planets position_function = interpolate.interp1d() #blabla return interpolated_planet_pos @jit(nopython = True) def integrate(planet_pos, x0, v0, dt, N, t, masses, m): N = int(N) #Converting N to integer x = np.zeros((N,2)) #Position Array x[0] = x0 #Setting Initial Position v_step = v0 #Velocity for i in range(1, N): F_tot = np.zeros(2) #Total Force from Planet Gravities #Summing up the forces from individual planets ''' To find the sum of the forces influencing our probe, we need to find the sum of the forces from each individual planet – this can be accomplished via a simple for-loop: ''' for j in range(len(x_planets)): #blabla #F_tot += ... #Summing up Each Individual Force ''' Next, sum up the sun's gravitational influence with F_tot to implement the next integration step. ''' v_step = ... #Calculating the Next Velocity x[i] = ... #Calculating next Position return x def integrate_between_boosts(t_planets, x_planets, x0, v0, dt, N, t, masses, m): interpolated_planet_pos = find_planet_pos(t_planets, x_planets, t): x = integrate(interpolated_planet_pos, x0, v0, dt, N, t, masses, m) return x #position after launch: x0 = #Initial Satellite Position v0 = #Initial Satellite Velocity t0 = #Initial Time m = #Satellite Mass xpos = x0 v = v0 curtime = t0 #NB! You may need some loops around or inside the following code, depending on your strategy to reach the planet... #first boost (if you choose to boost at this point, if not jump to integration) deltav = v += deltav #SIMULATION CONSTANTS N = #Number of Steps to Simulate for this part of trajectory T = #duration of this part of trajectory (maybe you need some calculations to find this? or trial and error?) t_end = curtime + T #end time for this part of trajectory dt = float(T)/N #Calculates Time-Step t = np.linspace(curtime, t_end, N) #Array of Times x = integrate_between_boosts(t_planets, x_planets, xpos, v, dt, N, t, masses, m) curtime += T xpos = x[N-1,:] #second boost (if you choose to boost at this point, if not jump to integration) deltav = v += deltav #SIMULATION CONSTANTS N = #Number of Steps to Simulate for this part of trajectory T = #duration of this part of trajectory (maybe you need some calculations to find this? or trial and error?) t_end = curtime + T #end time for this part of trajectory dt = float(T)/N #Calculates Time-Step t = np.linspace(curtime, t_end, N) #Array of Times x = integrate_between_boosts(t_planets, x_planets, xpos, v, dt, N, t, masses, m) curtime += T #third boost #etc #etc