[Scientific / technical calculation by Python] Wave "beat" and group velocity, wave superposition, visualization, high school physics

Introduction

The intensity of the sound that normally comes into your ears may fluctuate periodically. This phenomenon is called ** "beat" ** ing.

The origin of this phenomenon is, taking a one-dimensional wave as an example. ** Wave number $ k $ and angular frequency $ \ omega $ are slightly different, and as a result of superimposing two sine waves traveling in the same direction, the wave strength (amplitude) fluctuates slowly and periodically **. is there.

In a medium with dispersion The angular frequency $ \ omega $ is a function of $ k $, and the physical quantity that characterizes the wave is ** group velocity **. It is important to consider 80% 9F% E5% BA% A6) $ v_g = \ frac {\ partial \ omega (k)} {\ partial k} $. This is distinguished from [** phase velocity **](phase velocity) $ v_p = \ frac {\ omega} {k} $, which is the velocity of a normal wave propagating in a uniform medium.

** Although the beat phenomenon is learned in high school physics, it may be difficult for students to grasp the phenomenon because they have to imagine the appearance of time-varying waves. Therefore, in this paper, we will create an animation using the animation method of matplotlib for the purpose of helping to understand the beat phenomenon. ** **

** I think that you can deepen your understanding of the phenomenon and group velocity just by looking at the animation shown in the result. ** </ font>


Contents

(1) Beat phenomenon when there is no dispersibility. At this time, the phase velocity of the wave and the group velocity match.

(2) Beat phenomenon when there is dispersibility. The group velocity does not match the phase velocity.

(3) Combine the animations created in (1) and (2) above.


Code (1): When there is no dispersibility


"""
Beat phenomenon:No dispersibility

"""

%matplotlib nbagg 
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation


fig = plt.figure(figsize = (8, 6))

L, t_max = 6,12
Nx= 240
Nt = 100

delta_x=L/Nx
delta_t=t_max/Nt
xx=list(range(Nx))

a=1
k1= 2*np.pi/(L/10)
omega1=10
phi1=0

k2= (1+0.15)*k1
omega2=(1+0.15)*omega1
phi2=0

u1=np.zeros([Nx,Nt])
u2=np.zeros([Nx,Nt])
utot=np.zeros([Nx,Nt])


xlis=np.zeros([Nx])

for i in range(Nx):
    x = i*delta_x
    xlis[i] = x
    for j in range(Nt):
        t = j*delta_t
        u1[i,j]=a*np.cos(k1*x-omega1*t-phi1)
        u2[i,j]=a*np.cos(k2*x-omega2*t-phi2)
        utot[i,j]= u1[i,j]+u2[i,j]


def update(j,utot,fig_title):
    if j != 0:
        plt.cla()
    plt.ylim(-3, 3)
    plt.xlim(0, L)
    plt.plot( xlis,u1[:,j],  '--', color='red', linewidth = 1)
    plt.plot( xlis,u2[:,j],  '--', color='blue',linewidth = 1)
    plt.plot( xlis,utot[:,j],  '-', color='purple', linewidth =4)

    plt.title(fig_title  + str("{0:.1f}".format(j*delta_t)))

    plt.xlabel('X')
    plt.ylabel('U')
    plt.legend(['u1','u2', 'u1+u2'], loc='upper right')


ani = animation.FuncAnimation(fig,update,fargs = (utot,'Beat: t ='), interval =1, frames = Nt,blit=False)
fig.show()

ani.save("output.gif", writer="imagemagick")


Result (1) No dispersibility

output.gif

A beat phenomenon (a phenomenon in which the amplitude of the composite wave fluctuates periodically) is observed. At this time, the phase velocity and the group velocity match.

Code (2): Distributed

Investigate what happens when heterogeneous waves, that is, dispersed waves, are superimposed.

"""
Dispersion relation ω=f(k)If there is
"""

%matplotlib nbagg 
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure(figsize = (8, 6))


L, t_max = 6,12
Nx= 240
Nt = 100

delta_x=L/Nx
delta_t=t_max/Nt
xx=list(range(Nx))
#X,T = np.meshgrid(x,t)

omega=10
omega0=30

a=1
k1= 2*np.pi/(L/10)

V0= omega/k1

omega1=np.sqrt((V0*k1)**2+omega0**2)
phi1=0

k2= (1+0.15)*k1
omega2=np.sqrt((V0*k2)**2+omega0**2)
phi2=0

u1=np.zeros([Nx,Nt])
u2=np.zeros([Nx,Nt])
utot=np.zeros([Nx,Nt])


xlis=np.zeros([Nx])
for i in range(Nx):
    x = i*delta_x
    xlis[i] = x
    for j in range(Nt):
        t = j*delta_t
        u1[i,j]=a*np.cos(k1*x-omega1*t-phi1)
        u2[i,j]=a*np.cos(k2*x-omega2*t-phi2)
        utot[i,j]= u1[i,j]+u2[i,j]



def update(j,utot,fig_title):
    if j != 0:
        plt.cla()
    plt.ylim(-3, 3)
    plt.xlim(0, L)
    plt.plot( xlis,u1[:,j],  '--', color='red', linewidth = 1)
    plt.plot( xlis,u2[:,j],  '--', color='blue',linewidth = 1)
    plt.plot( xlis,utot[:,j],  '-', color='green', linewidth =4)

    plt.title(fig_title  + str("{0:.1f}".format(j*delta_t)))

    plt.xlabel('X')
    plt.ylabel('U')
    plt.legend(['u1','u2', 'u1+u2'], loc='upper right')


ani = animation.FuncAnimation(fig,update,fargs = (utot,'Beat: t ='), interval =1, frames = Nt,blit=False)
fig.show()

ani.save("output2.gif", writer="imagemagick")


Result (2) Dispersive

output2.gif

** In this case, there is a difference between the group velocity (the velocity at which the envelope ("beat waveform") moves) and the phase velocity (the velocity at which the wave itself moves). The "beat waveform" moves at group velocity, and the wave itself moves at phase velocity. ** **


Result (3): Dispersive and non-dispersive animation: Comparison

output3.gif

The difference in motion between dispersive (green line) and non-dispersive (purple line) is clear.


Addendum

(1) Dispersion relation used in this paper

One-dimensional string wave equation, $\frac{\partial^2 u(x,t)}{\partial t^2} = v^2 \frac{\partial^2 u(x,t)}{\partial x^2} \tag{1} $ When the restoring force $-\ omega_0 ^ 2 u (x, t) \ tag {2} $ is added to hold the constituent particles of the string at each position, the wave equation becomes

\frac{\partial^2 u(x,t)}{\partial t^2} = v^2 \frac{\partial^2 u(x,t)}{\partial x^2} -\omega_0^2 u(x,t) \tag{3} Will be. Some vibrations that occur in actual matter follow a similar equation (such as the vibration of intraatomic electrons).

The solution of this wave equation is

As $ \ omega (k) = (v ^ 2k ^ 2 + \ omega_0 ^ 2) ^ \ frac {1} {2} \ tag {4} $

u(x,t) = a cos(k x-\omega(k)t-\phi \tag{5}

It turns out that In the content (2) of this paper, the above dispersion relation (Equation .4) was used.

(2) Various dispersion relations are known in various media. Let me give you an example.

  • ** Dispersion formula of waves propagating on the surface of deep water **: $ \ omega (k) = \ sqrt (gk + T k ^ 3 / \ rho) \ tag {6} $ (g is gravitational acceleration, T is Surface tension, $ \ rho $ is the density.

  • ** Diatomic system (each ion mass is $ m_1 $ and $ m_2 $) ** ** lattice vibration ** considering only closest interaction Dispersion relation of wiki /% E6% A0% BC% E5% AD% 90% E6% 8C% AF% E5% 8B% 95): \omega^2(k)= \frac{f}{m_\mu} \left ( 1 \pm \sqrt{1-\frac{4m_\mu^{\, 2}}{m_1m_2} \sin^2{ka} } \right ), \quad \frac{1}{m_\mu}=\frac{1}{m_1} + \frac{1}{m_2}\tag{7}


References

[1] For animation creation, Qiita article by AnchorBlues: Flexible animation creation using animation.FuncAnimation of matplotlib was helpful and easy to understand. ..

[2] Regarding group velocity, for example, by Yosuke Nagaoka ["Vibration and Waves"](https://www.amazon.co.jp/%E6%8C%AF%E5%8B%95%E3%81% A8% E6% B3% A2-% E9% 95% B7% E5% B2% A1-% E6% B4% 8B% E4% BB% 8B / dp / 4785320451) has an elementary and easy-to-understand explanation.

Recommended Posts

[Scientific / technical calculation by Python] Wave "beat" and group velocity, wave superposition, visualization, high school physics
[Scientific / technical calculation by Python] Histogram, visualization, matplotlib
[Scientific / technical calculation by Python] Logarithmic graph, visualization, matplotlib
[Scientific / technical calculation by Python] Polar graph, visualization, matplotlib
[Scientific / technical calculation by Python] Vector field visualization example, electrostatic field, matplotlib
[Scientific / technical calculation by Python] Sum calculation, numerical calculation
Scientific / technical calculation by Python] Drawing and visualization of 3D isosurface and its cross section using mayavi
[Scientific / technical calculation by Python] Inverse matrix calculation, numpy
[Scientific / technical calculation by Python] Drawing of 3D curved surface, surface, wireframe, visualization, matplotlib
[Scientific / technical calculation by Python] Plot, visualization, matplotlib of 2D data read from file
[Scientific / technical calculation by Python] Drawing, visualization, matplotlib of 2D (color) contour lines, etc.
[Scientific / technical calculation by Python] Numerical solution of one-dimensional and two-dimensional wave equations by FTCS method (explicit method), hyperbolic partial differential equations
[Scientific / technical calculation by Python] 3rd order spline interpolation, scipy
[Scientific / technical calculation by Python] Basic operation of arrays, numpy
[Scientific / technical calculation by Python] Monte Carlo integration, numerical calculation, numpy
[Scientific / technical calculation by Python] List of usage of (special) functions used in physics by using scipy
[Scientific and technical calculation by Python] Drawing of fractal figures [Sierpinski triangle, Bernsley fern, fractal tree]
[Scientific / technical calculation by Python] Numerical solution of one-dimensional harmonic oscillator problem by velocity Verlet method
[Scientific / technical calculation by Python] Numerical integration, trapezoidal / Simpson law, numerical calculation, scipy
[Scientific / technical calculation by Python] Solving simultaneous linear equations, numerical calculation, numpy
[Scientific / technical calculation by Python] 2D random walk (drunk walk problem), numerical calculation
[Scientific / technical calculation by Python] Derivation of analytical solutions for quadratic and cubic equations, mathematical formulas, sympy
[Scientific / technical calculation by Python] Fitting by nonlinear function, equation of state, scipy
[Scientific / technical calculation by Python] Calculation of matrix product by @ operator, python3.5 or later, numpy
[Scientific / technical calculation by Python] Solving ordinary differential equations, mathematical formulas, sympy
[Scientific / technical calculation by Python] Solving (generalized) eigenvalue problem using numpy / scipy, using library
[Scientific / technical calculation by Python] Drawing animation of parabolic motion with locus, matplotlib
[Scientific / technical calculation by Python] Solving second-order ordinary differential equations by Numerov method, numerical calculation
[Scientific / technical calculation by Python] Plot, visualize, matplotlib 2D data with error bars
[Scientific / technical calculation by Python] Solving one-dimensional Newton equation by the 4th-order Runge-Kutta method
Calculation of technical indicators by TA-Lib and pandas