Put velocity and magnetic field into SI units in Ek_Eb function

This commit is contained in:
Simon
2020-07-24 15:09:47 +02:00
committed by Noe Brucy
parent 11068654a1
commit 2a47693f0e
+11 -9
View File
@@ -314,8 +314,6 @@ class PostProcessor(HDF5Container):
else: else:
rho_bins = np.linspace(np.min(rho), np.max(rho), bins) rho_bins = np.linspace(np.min(rho), np.max(rho), bins)
weights = mass_func(self.cells)
# For each cell, bin_number contains the number of the bins it belongs to # For each cell, bin_number contains the number of the bins it belongs to
bin_number = np.zeros(len(B)) bin_number = np.zeros(len(B))
@@ -344,13 +342,19 @@ class PostProcessor(HDF5Container):
""" """
self.load_cells() self.load_cells()
mean_speed = self.save.get_node("/globals/mwa_speed").read() mean_speed = self.save.get_node("/globals/mwa_speed").read()
vel_fluct = (self.cells)["vel"] - mean_speed mean_speed = mean_speed * self.info["unit_velocity"].express(cst.km_s)
vel_fluct = (self.cells)["vel"] * self.info["unit_velocity"].express(
cst.km_s
) - mean_speed
B_norm = getter_B_int(self.cells) B_norm = getter_B_int(self.cells)
v_norm = np.sqrt(np.sum((vel_fluct * 10 ** (3)) ** 2, axis=1)) # v [km/s] B_norm = B_norm * self.info["unit_mag"].express(cst.T)
print(v_norm) v_norm = np.sqrt(
np.sum((vel_fluct * 10 ** (3)) ** 2, axis=1)
) # v_norm [m/s] et vel_fluct [km/s]
rho = getter_rho(self.cells) rho = getter_rho(self.cells)
rho_kg_m3 = rho * self.info["unit_density"].express(cst.kg_m3)
eb = 0.5 * (B_norm) ** 2 / (4 * np.pi * 10 ** (-7)) # mettre le bon mu eb = 0.5 * (B_norm) ** 2 / (4 * np.pi * 10 ** (-7)) # mettre le bon mu
ek = 0.5 * v_norm ** 2 * rho # mettre la masse de la cellule ek = 0.5 * v_norm ** 2 * rho_kg_m3
rapport = ek / eb rapport = ek / eb
if logbins: if logbins:
@@ -360,8 +364,6 @@ class PostProcessor(HDF5Container):
else: else:
rho_bins = np.linspace(np.min(rho), np.max(rho), bins) rho_bins = np.linspace(np.min(rho), np.max(rho), bins)
weights = mass_func(self.cells)
# For each cell, bin_number contains the number of the bins it belongs to # For each cell, bin_number contains the number of the bins it belongs to
bin_number = np.zeros(len(B_norm)) bin_number = np.zeros(len(B_norm))
@@ -385,7 +387,7 @@ class PostProcessor(HDF5Container):
return ({"rho": centers, "Ek_Eb_rho": ek_eb}, {"logbins": logbins}) return ({"rho": centers, "Ek_Eb_rho": ek_eb}, {"logbins": logbins})
def cos_vfluct_B(self): def cos_vfluct_B(self):
"return the cos of the angle between the magnetic field and the velocity fluctuation field"
mean_speed = self.save.get_node("/globals/mwa_speed").read() mean_speed = self.save.get_node("/globals/mwa_speed").read()
def getter_cos_vfluct_B(dset): def getter_cos_vfluct_B(dset):