Closed vcristiani closed 3 years ago
Here I send a first approach to the problem
def angular_momentum(self):
self.x_s_c = x_s - x_dm[p_dm.index(max(p_dm))] #To put the center on the particle with the lowest potential
self.y_s_c = y_s - y_dm[p_dm.index(max(p_dm))] #p_dm represent the list with the dm potentials
self.z_s_c = z_s - z_dm[p_dm.index(max(p_dm))]
self.x_dm_c = x_dm - x_dm[p_dm.index(max(p_dm))]
self.y_dm_c = y_dm - y_dm[p_dm.index(max(p_dm))]
self.z_dm_c = z_dm - z_dm[p_dm.index(max(p_dm))]
self.x_g_c = x_g - x_dm[p_dm.index(max(p_dm))]
self.y_g_c = y_g - y_dm[p_dm.index(max(p_dm))]
self.z_g_c = z_g - z_dm[p_dm.index(max(p_dm))]
pos_star_rot, vel_star_rot, A = aling(self.m_s, [self.x_s_c, self.y_s_c, self.z_s_c],
[self.vx_s, self.vy_s, self.vz_s], 3 .R[j])
pos_dark_rot = rot([self.x_dm_c, self.y_dm_c, self.z_dm_c], A)
vel_dark_rot = rot([self.vx_dm, self.vy_dm, self.vz_dm], A)
pos_gas_rot = rot([self.x_g_c, self.y_g_c, self.z_g_c], A)
vel_gas_rot = rot([self.vx_g, self.vy_g, self.vz_g], A)
J_dark = np.asarray((pos_dark_rot[:, 1] * vel_dark_rot[:, 2] -
pos_dark_rot[:, 2] * vel_dark_rot[:, 1],
pos_dark_rot[:, 2] * vel_dark_rot[:, 0] -
pos_dark_rot[:, 0] * vel_dark_rot[:, 2],
pos_dark_rot[:, 0] * vel_dark_rot[:, 1] -
pos_dark_rot[:, 1] * vel_dark_rot[:, 0]))
J_star = np.asarray((pos_star_rot[:, 1] * vel_star_rot[:, 2] -
pos_star_rot[:, 2] * vel_star_rot[:, 1],
pos_star_rot[:, 2] * vel_star_rot[:, 0] -
pos_star_rot[:, 0] * vel_star_rot[:, 2],
pos_star_rot[:, 0] * vel_star_rot[:, 1] -
pos_star_rot[:, 1] * vel_star_rot[:, 0]))
J_gas = np.asarray((pos_gas_rot[:, 1] * vel_gas_rot[:, 2] -
pos_gas_rot[:, 2] * vel_gas_rot[:, 1],
pos_gas_rot[:, 2] * vel_gas_rot[:, 0] -
pos_gas_rot[:, 0] * vel_gas_rot[:, 2],
pos_gas_rot[:, 0] * vel_gas_rot[:, 1] -
pos_gas_rot[:, 1] * vel_gas_rot[:, 0]))
J_part = np.concatenate((J_gas, J_dark, J_star), axis=1)
Jr_star = np.sqrt(J_star[0, :]**2 + J_star[1, :]**2)
Jr = np.sqrt(J_part[0, :]**2 + J_part[1, :]**2)
return J_part, J_star, Jr
@ValeCristiani @RafaelPignata622 suggestions?
x_s_c, y_s_c,.... are not class attributes, so we should define what to do with that: we can redefine the positions and velocities that were already there (in that case the method should have another name) or save them as new attributes. Perhaps the best is the first, but either way, you can modify it later.
6 - Calculates J and defines the axis of the coordinate system: take: masses, positions, and velocities return: J and its components Jx, Jy, Jz