Changeset 1645
- Timestamp:
- 02/25/10 15:03:17 (5 months ago)
- Files:
-
- 1 modified
-
trunk/yt/lagos/HaloFinding.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/yt/lagos/HaloFinding.py
r1641 r1645 125 125 def rms_velocity(self): 126 126 """ 127 Returns the RMS velocity for the halo particles in code units. 127 Returns the mass-weighted RMS velocity for the halo 128 particles in code units. 128 129 """ 129 130 bv = self.bulk_velocity() 130 vx = self["particle_velocity_x"] - bv[0] 131 vy = self["particle_velocity_y"] - bv[1] 132 vz = self["particle_velocity_z"] - bv[2] 133 s = vx**2 + vy**2 + vz**2 131 pm = self["ParticleMassMsun"] 132 sm = pm.sum() 133 vx = (self["particle_velocity_x"] - bv[0]) * pm/sm 134 vy = (self["particle_velocity_y"] - bv[1]) * pm/sm 135 vz = (self["particle_velocity_z"] - bv[2]) * pm/sm 136 s = vx**2. + vy**2. + vz**2. 134 137 ms = na.mean(s) 135 return na.sqrt(ms) 138 return na.sqrt(ms) * pm.size 136 139 137 140 def maximum_radius(self, center_of_mass=True): … … 385 388 return self.rms_vel 386 389 bv = self.bulk_velocity() 390 pm = self["ParticleMassMsun"] 391 sm = pm.sum() 387 392 if self.indices is not None: 388 vx = self["particle_velocity_x"] - bv[0]389 vy = self["particle_velocity_y"] - bv[1]390 vz = self["particle_velocity_z"] - bv[2]393 vx = (self["particle_velocity_x"] - bv[0]) * pm/sm 394 vy = (self["particle_velocity_y"] - bv[1]) * pm/sm 395 vz = (self["particle_velocity_z"] - bv[2]) * pm/sm 391 396 s = vx**2 + vy**2 + vz**2 392 397 s = na.sum(s) … … 397 402 global_ss = self._mpi_allsum(ss) 398 403 ms = global_ss[0] / global_ss[1] 399 return na.sqrt(ms) 404 return na.sqrt(ms) * global_ss[1] 400 405 401 406 def maximum_radius(self, center_of_mass=True): … … 915 920 for i, u in enumerate(uniq_subchain): 916 921 self.bulk_vel[u] = na.sum(vel[marks[i]:marks[i+1]], axis=0) 917 del vel, ms,subchain, sort_subchain922 del vel, subchain, sort_subchain 918 923 del diff_subchain 919 924 # Bring it together, and divide by the previously computed total mass … … 929 934 if calc: 930 935 vel = na.empty((calc, 3), dtype='float64') 931 vel[:,0] = xv[select] 932 vel[:,1] = yv[select] 933 vel[:,2] = zv[select] 936 vel[:,0] = xv[select] * ms 937 vel[:,1] = yv[select] * ms 938 vel[:,2] = zv[select] * ms 934 939 vel = vel[sort] 935 vel = vel**2 # Squared936 940 for i, u in enumerate(uniq_subchain): 937 # This finds the Mean 938 rms_vel_temp[u][0] = na.sum(vel[marks[i]:marks[i+1]] - self.bulk_vel[u]) 941 # This finds the sum locally. 942 rms_vel_temp[u][0] = na.sum(((vel[marks[i]:marks[i+1]] - \ 943 self.bulk_vel[u]) / self.Tot_M[u])**2.) 944 # I could use self.group_sizes... 939 945 rms_vel_temp[u][1] = marks[i+1] - marks[i] 940 946 del vel, marks, uniq_subchain … … 943 949 self.rms_vel = na.empty(self.group_count, dtype='float64') 944 950 for groupID in xrange(self.group_count): 945 # Here we do the Root.951 # Here we do the Mean and the Root. 946 952 self.rms_vel[groupID] = \ 947 na.sqrt(rms_vel_temp[groupID][0] / rms_vel_temp[groupID][1]) 948 del rms_vel_temp 953 na.sqrt(rms_vel_temp[groupID][0] / rms_vel_temp[groupID][1]) * \ 954 self.group_sizes[groupID] 955 del rms_vel_temp, ms 949 956 yt_counters("rms vel computing") 950 957 self.taskID = obj.mine
