Specific angular momentum and SubhaloSpin

Abhinav Kumar
  • 1
  • 28 Jul

I am calculating specific angular momentum of a subhalo based on their particles, but when I compare it with the SubhaloSpin, I get different values. Am I missing something? For reference I have added my code here:

part_stars = il.snapshot.loadSubhalo(basePath_TNG, snapNum, subhalo_no, 'stars')
url = f"http://www.tng-project.org/api/TNG100-1/snapshots/{snapNum}/subhalos/{subhalo}"
sub = get(url)

a = 1/(1 + z)
h = 0.6774

dx = (part_stars["Coordinates"][:,0]  - sub["pos_x"])*a/h 
dy = (part_stars["Coordinates"][:,1]  - sub["pos_y"])*a/h 
dz = (part_stars["Coordinates"][:,2]  - sub["pos_z"])*a/h 

dvx = ( part_stars["Velocities"][:,0]*np.sqrt(a)  - sub["vel_x"])
dvy = ( part_stars["Velocities"][:,1]*np.sqrt(a)  - sub["vel_y"]) 
dvz = ( part_stars["Velocities"][:,2]*np.sqrt(a)  - sub["vel_z"]) 

pos_relative = np.array([dx, dy, dz]).T 
vel_relative = np.array([dvx, dvy, dvz]).T  

mass_part = stars["Masses"]*1e10/h  

am = np.sum((mass_part[:,None]*np.cross(pos_relative, vel_relative)), axis = 0)/np.sum(mass_part)

Now, If I compare it with the "SubhaloSpin", I dont get similar values.
il.groupcat.loadSingle(basePath, snapNum, subhaloID= subhalo_no)["SubhaloSpin"]/h

Dylan Nelson
  • 29 Jul

You are computing the spin only for stars, but the catalog values are for all particle/cell types.

In addition, the catalog values will include a correction for Hubble expansion.

Perhaps these are the only two differences.

Abhinav Kumar
  • 29 Jul

Thank you very much, Dylan!

  • Page 1 of 1