5from .StandardPlotHelper
import StandardPlotHelper
25 do_normalization=True,
26 min_normalization=1e-9,
28 def compute_v_z_slice(helper):
29 def keep_only_v_z(arr_v):
32 arr_v = helper.slice_render(
33 "vxyz",
"f64_3", do_normalization, min_normalization, keep_only_v_z
38 return StandardPlotHelper(
48 compute_function=compute_v_z_slice,
52def ColumnAverageVzPlot(
62 min_normalization=1e-9,
64 def compute_v_z_slice(helper):
65 def custom_getter(size: int, dic_out: dict) -> np.array:
66 return dic_out[
"vxyz"][:, 2]
68 arr_v = helper.column_average_render(
69 "custom",
"f64", min_normalization, custom_getter=custom_getter
74 return StandardPlotHelper(
84 compute_function=compute_v_z_slice,
88def SliceDiffVthetaProfile(
99 do_normalization=True,
100 min_normalization=1e-9,
102 def compute_diff_vtheta_profile(helper):
104 if shamrock.sys.world_rank() == 0:
105 print(
"Using numba for velocity profile in SliceDiffVthetaProfile")
108 vel_profile_jit = njit(velocity_profile)
110 vel_profile_jit = np.vectorize(velocity_profile)
113 size: int, x: np.array, y: np.array, vx: np.array, vy: np.array, vz: np.array
115 r = np.sqrt(x**2 + y**2)
117 v_theta = (-y * vx + x * vy) / r_safe
118 v_relative = v_theta - vel_profile_jit(r)
122 internal = njit(internal)
124 def custom_getter(size: int, dic_out: dict) -> np.array:
127 dic_out[
"xyz"][:, 0],
128 dic_out[
"xyz"][:, 1],
129 dic_out[
"vxyz"][:, 0],
130 dic_out[
"vxyz"][:, 1],
131 dic_out[
"vxyz"][:, 2],
134 arr_v = helper.slice_render(
139 custom_getter=custom_getter,
144 return StandardPlotHelper(
154 compute_function=compute_diff_vtheta_profile,
158def VerticalShearGradient(
168 do_normalization=True,
169 min_normalization=1e-9,
171 def compute_vertical_shear_gradient(helper):
173 if shamrock.sys.world_rank() == 0:
174 print(
"Using numba for custom getter in VerticalShearGradient")
177 size: int, x: np.array, y: np.array, vx: np.array, vy: np.array, vz: np.array
179 r = np.sqrt(x**2 + y**2)
181 v_theta = (-y * vx + x * vy) / r_safe
185 internal = njit(internal)
187 def custom_getter(size: int, dic_out: dict) -> np.array:
190 dic_out[
"xyz"][:, 0],
191 dic_out[
"xyz"][:, 1],
192 dic_out[
"vxyz"][:, 0],
193 dic_out[
"vxyz"][:, 1],
194 dic_out[
"vxyz"][:, 2],
197 arr_v_theta = helper.slice_render(
202 custom_getter=custom_getter,
205 extent = helper.get_extent()
206 dy = (extent[3] - extent[2]) / helper.ny
208 vert_shear_gradient = np.gradient(arr_v_theta, dy, axis=0)
210 return vert_shear_gradient
212 return StandardPlotHelper(
222 compute_function=compute_vertical_shear_gradient,
226def gen_angular_momt_custom_getter(model, velocity_profile):
227 pmass = model.get_particle_mass()
228 hfact = model.get_hfact()
231 if shamrock.sys.world_rank() == 0:
233 "Using numba for velocity profile in SliceAngularMomentumTransportCoefficientPlot"
235 vel_profile_jit = njit(velocity_profile)
237 vel_profile_jit = np.vectorize(velocity_profile)
249 rho = pmass * (hfact / hpart) ** 3
252 r = np.sqrt(x**2 + y**2)
254 v_r = (x * vx + y * vy) / r_safe
255 v_theta = (-y * vx + x * vy) / r_safe
257 delta_vtheta = v_theta - vel_profile_jit(r)
258 alpha = rho * v_r * delta_vtheta / P
263 if shamrock.sys.world_rank() == 0:
264 print(
"Using numba for custom getter in SliceAngularMomentumTransportCoefficientPlot")
265 internal = njit(internal)
267 def custom_getter(size: int, dic_out: dict) -> np.array:
269 dic_out[
"xyz"][:, 0],
270 dic_out[
"xyz"][:, 1],
271 dic_out[
"xyz"][:, 2],
272 dic_out[
"vxyz"][:, 0],
273 dic_out[
"vxyz"][:, 1],
274 dic_out[
"vxyz"][:, 2],
276 dic_out[
"soundspeed"],
282def SliceAngularMomentumTransportCoefficientPlot(
292 do_normalization=True,
293 min_normalization=1e-9,
294 velocity_profile=None,
296 def compute_angular_momentum_transport_coefficient(helper):
297 custom_getter = gen_angular_momt_custom_getter(model, velocity_profile)
299 arr_v = helper.slice_render(
304 custom_getter=custom_getter,
309 return StandardPlotHelper(
319 compute_function=compute_angular_momentum_transport_coefficient,
323def ColumnAverageAngularMomentumTransportCoefficientPlot(
333 min_normalization=1e-9,
334 velocity_profile=None,
336 def compute_angular_momentum_transport_coefficient(helper):
337 custom_getter = gen_angular_momt_custom_getter(model, velocity_profile)
339 arr_v = helper.column_average_render(
343 custom_getter=custom_getter,
347 return StandardPlotHelper(
357 compute_function=compute_angular_momentum_transport_coefficient,