Scatterer: Acoustic velocity plots with arrows#

This example shows how to plot the acoustic velocity and also add arrows within the plot showcasing the magnitude and direction of the acoustic fluid velocity.

This example is very similiar to the example of quiver plots in a fluid. Therefore, we will keep the text very short here. If you want to have more explanations, check out the linked example.

15 from matplotlib import pyplot as plt
16
17 import osaft
18
19 # --------
20 # Geometry
21 # --------
22 # Radius
23 R_0 = 30e-6  # [m]
24
25 # ---------------------------
26 # Properties of the Scatterer
27 # ---------------------------
28 # Speed of sound
29 c_sc = 350  # [m/s]
30 # Density
31 rho_sc = 1_020  # [kg/m^3]
32
33 # ---------------------------
34 # Properties of Water
35 # ---------------------------
36 # Speed of sound
37 c_water = 1_500  # [m/s]
38 # Density
39 rho_water = 997  # [kg/m^3]
40
41 # --------------------------------
42 # Properties of the Acoustic Field
43 # --------------------------------
44 # Frequency
45 f = 1e7  # [Hz]
46 # Pressure
47 p_0 = 1e5  # [Pa]
48 # Wave type
49 wave_type = osaft.WaveType.TRAVELLING
50 # Position of the particle in the field
51 position = osaft.pi / 4  # [rad]
52
53 # ----------------
54 # Truncation Limit
55 # ----------------
56 # Number of scattering modes that are considered
57 N_max = 5

Initialization of the ScatteringField class of the yosioka1955 solution

63 sol = osaft.yosioka1955.ScatteringField(
64     f=f,
65     R_0=R_0,
66     rho_s=rho_sc,
67     c_s=c_sc,
68     rho_f=rho_water,
69     c_f=c_water,
70     p_0=p_0,
71     wave_type=wave_type,
72     position=position,
73     N_max=N_max,
74 )

Initialization of plotter object

Acoustic velocity and quiver arrows

84 fig, ax = plotter.plot_velocity(
85     symmetric=True,
86     inst=True,
87     quiver_color="white",
88 )
89 ax.set_title("Acoustic Velocity Magnitude + Quiver")
90 fig.tight_layout()
91 plt.show()
Acoustic Velocity Magnitude + Quiver

Evolution plot

 96 fig, _ = plotter.plot_velocity_evolution(
 97     quiver_color="white",
 98     tripcolor=True,
 99     figsize=(12, 12),
100 )
101 plt.show()
0.00$\pi$, 0.25$\pi$, 0.50$\pi$, 0.75$\pi$, 1.00$\pi$, 1.25$\pi$, 1.50$\pi$, 1.75$\pi$, 2.00$\pi$

Animated velocity arrows for second mode only

106 anim = plotter.animate_velocity(quiver_color="white", mode=2)
107 anim.resume()
108 plt.show()

Animated velocity arrows for all modes

113 anim = plotter.animate_velocity(quiver_color="white")
114 anim.resume()
115 plt.show()

Total running time of the script: ( 1 minutes 7.326 seconds)

Estimated memory usage: 58 MB

Gallery generated by Sphinx-Gallery