Additional Question 2 Implementation

My first additional question is basically my base question but with my disrupting galaxy having a mass of 3 times that of the main galaxy


In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint

In [2]:
from initial_velocities import velocities_m, velocities_S
from DE_solver import derivs, equationsolver

Defining empty initial condition array:


In [3]:
ic_add2 = np.zeros(484)

Setting values for S,M, and t:


In [4]:
max_time_add2 = 1.5
time_step_add2 = 120
S_add2 = 1e11
M_add2 = S_add2/3

In [5]:
S_y_add2 = 70
S_x_add2 = -.01*S_y_add2**2+25
vxS_add2 = velocities_S(M_add2,S_add2,S_x_add2,S_y_add2)[0]
vyS_add2 = velocities_S(M_add2,S_add2,S_x_add2,S_y_add2)[1]

Setting initial condition array values pertaining to S:


In [6]:
ic_add2[0] = S_x_add2
ic_add2[1] = S_y_add2
ic_add2[2] = vxS_add2
ic_add2[3] = vyS_add2

Loading the positions of my stars:


In [7]:
f = open('star_positions.npz','r')
r = np.load('star_positions.npz')
x_y = r['arr_0']
f.close()

Putting these values into my initial condition array, as well calling the initial velocity function on each position:


In [8]:
for i in range(0,120):
    ic_add2[(i+1)*4] = x_y[0][i]
    ic_add2[((i+1)*4)+1] = x_y[1][i]

In [9]:
for n in range(1,int(len(ic_add2)/4)):
    ic_add2[n*4+2] = velocities_m(M_add2,ic_add2[n*4],ic_add2[n*4+1])[0]
    ic_add2[n*4+3] = velocities_m(M_add2,ic_add2[n*4],ic_add2[n*4+1])[1]

Calling my differential equation solver, and saving the data to disk:


In [10]:
sol_add2 = equationsolver(ic_add2,max_time_add2,time_step_add2,M_add2,S_add2)

In [40]:
np.savez('additional_2_data.npz',sol_add2,ic_add2)

In [ ]: