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):
103 if _HAS_NUMBA
and shamrock.sys.world_rank() == 0:
104 print(
"Using numba for velocity profile in SliceDiffVthetaProfile")
107 vel_profile_jit = njit(velocity_profile)
109 vel_profile_jit = np.vectorize(velocity_profile)
112 size: int, x: np.array, y: np.array, vx: np.array, vy: np.array, vz: np.array
114 r = np.sqrt(x**2 + y**2)
116 v_theta = (-y * vx + x * vy) / r_safe
117 v_relative = v_theta - vel_profile_jit(r)
121 internal = njit(internal)
123 def custom_getter(size: int, dic_out: dict) -> np.array:
126 dic_out[
"xyz"][:, 0],
127 dic_out[
"xyz"][:, 1],
128 dic_out[
"vxyz"][:, 0],
129 dic_out[
"vxyz"][:, 1],
130 dic_out[
"vxyz"][:, 2],
133 arr_v = helper.slice_render(
138 custom_getter=custom_getter,
143 return StandardPlotHelper(
153 compute_function=compute_diff_vtheta_profile,
157def VerticalShearGradient(
167 do_normalization=True,
168 min_normalization=1e-9,
170 def compute_vertical_shear_gradient(helper):
171 if _HAS_NUMBA
and shamrock.sys.world_rank() == 0:
172 print(
"Using numba for custom getter in VerticalShearGradient")
175 size: int, x: np.array, y: np.array, vx: np.array, vy: np.array, vz: np.array
177 r = np.sqrt(x**2 + y**2)
179 v_theta = (-y * vx + x * vy) / r_safe
183 internal = njit(internal)
185 def custom_getter(size: int, dic_out: dict) -> np.array:
188 dic_out[
"xyz"][:, 0],
189 dic_out[
"xyz"][:, 1],
190 dic_out[
"vxyz"][:, 0],
191 dic_out[
"vxyz"][:, 1],
192 dic_out[
"vxyz"][:, 2],
195 arr_v_theta = helper.slice_render(
200 custom_getter=custom_getter,
203 extent = helper.get_extent()
204 dy = (extent[3] - extent[2]) / helper.ny
206 vert_shear_gradient = np.gradient(arr_v_theta, dy, axis=0)
208 return vert_shear_gradient
210 return StandardPlotHelper(
220 compute_function=compute_vertical_shear_gradient,
224def gen_angular_momt_custom_getter(model, velocity_profile):
225 pmass = model.get_particle_mass()
226 hfact = model.get_hfact()
229 if shamrock.sys.world_rank() == 0:
231 "Using numba for velocity profile in SliceAngularMomentumTransportCoefficientPlot"
233 vel_profile_jit = njit(velocity_profile)
235 vel_profile_jit = np.vectorize(velocity_profile)
247 rho = pmass * (hfact / hpart) ** 3
250 r = np.sqrt(x**2 + y**2)
252 v_r = (x * vx + y * vy) / r_safe
253 v_theta = (-y * vx + x * vy) / r_safe
255 delta_vtheta = v_theta - vel_profile_jit(r)
256 alpha = rho * v_r * delta_vtheta / P
261 if shamrock.sys.world_rank() == 0:
262 print(
"Using numba for custom getter in SliceAngularMomentumTransportCoefficientPlot")
263 internal = njit(internal)
265 def custom_getter(size: int, dic_out: dict) -> np.array:
267 dic_out[
"xyz"][:, 0],
268 dic_out[
"xyz"][:, 1],
269 dic_out[
"xyz"][:, 2],
270 dic_out[
"vxyz"][:, 0],
271 dic_out[
"vxyz"][:, 1],
272 dic_out[
"vxyz"][:, 2],
274 dic_out[
"soundspeed"],
280def SliceAngularMomentumTransportCoefficientPlot(
290 do_normalization=True,
291 min_normalization=1e-9,
292 velocity_profile=None,
294 def compute_angular_momentum_transport_coefficient(helper):
295 custom_getter = gen_angular_momt_custom_getter(model, velocity_profile)
297 arr_v = helper.slice_render(
302 custom_getter=custom_getter,
307 return StandardPlotHelper(
317 compute_function=compute_angular_momentum_transport_coefficient,
321def ColumnAverageAngularMomentumTransportCoefficientPlot(
331 min_normalization=1e-9,
332 velocity_profile=None,
334 def compute_angular_momentum_transport_coefficient(helper):
335 custom_getter = gen_angular_momt_custom_getter(model, velocity_profile)
337 arr_v = helper.column_average_render(
341 custom_getter=custom_getter,
345 return StandardPlotHelper(
355 compute_function=compute_angular_momentum_transport_coefficient,