Modifying 'cos' to get the angle beween v fluctuations and the magnetic field

This commit is contained in:
Simon
2020-06-24 16:13:53 +02:00
committed by Noe Brucy
parent be67f49d43
commit ffa5c90168
2 changed files with 18 additions and 11 deletions
+17 -10
View File
@@ -8,14 +8,6 @@ vol_func = lambda dset: dset["dx"] ** 3 # Volume function
getter_T = lambda dset: dset["P"] / dset["rho"] # Temperature
def getter_abs_cos_vB(dset):
B_norm = np.sqrt(np.sum(dset["Br"] ** 2, axis=1))
v_norm = np.sqrt(np.sum(dset["vel"] ** 2, axis=1))
# Compute the dot product in each cell
dot_prod = np.einsum("ij,ij->i", dset["vel"], dset["Br"])
return np.abs(dot_prod) / (v_norm * B_norm)
def getter_B_int(dset):
B_norm = np.sqrt(np.sum(dset["Br"] ** 2, axis=1))
return B_norm
@@ -341,6 +333,20 @@ class PostProcessor(HDF5Container):
self.unload_cells()
return ({"rho": centers, "B": B_mean}, {"logbins": logbins})
def cos_vfluct_B(self):
mean_speed = self.save.get_node("/globals/mwa_speed").read()
def getter_cos_vfluct_B(dset):
vel_fluct = dset["vel"] - mean_speed
B_norm = np.sqrt(np.sum(dset["Br"] ** 2, axis=1))
v_norm = np.sqrt(np.sum(vel_fluct ** 2, axis=1))
# Compute the dot product in each cell
dot_prod = np.einsum("ij,ij->i", vel_fluct, dset["Br"])
return np.abs(dot_prod) / (v_norm * B_norm)
return self._vol_pdf(getter_cos_vfluct_B)
def _mwa_sigma(self, axes=["x", "y", "z"]):
mw_speed = self.save.get_node("/globals/mwa_speed").read()
@@ -817,9 +823,10 @@ class PostProcessor(HDF5Container):
),
"cos_pdf": Rule(
self,
partial(self._vol_pdf, getter_abs_cos_vB, logbins=False),
"Global cos-PDF",
partial(self.cos_vfluct_B),
"Global cos fluctuation-PDF",
"/hist",
dependencies=["mwa_speed"],
unit=cst.none,
),
"Brho": Rule(