Wave on string: How can I create a traveling triangle pulse?

In summary, the conversation discusses a program that simulates a wave on a string with fixed ends. The program is written in Python and solves the wave equation, starting with an initial condition of a triangle wave splitting into two pulses. The code also includes a plot of the wave. The person wants to modify the program to have only one triangle wave pulse that moves to the right and gets reflected instead of splitting into two pulses. It is suggested to specify the initial speed or move one of the ends to achieve this. Additionally, the conversation touches on using arrays to store positions and velocities, and how to implement an initial velocity in the program.
  • #1
Omsin
18
0
I have the following program that moves a wave on a string with fixed ends. The program solves the wave equation given a initial condition wave. The initial condition is a triangle wave splitting into two pulses.

Here is the code written in Python:

Python:
from numpy import *
from  matplotlib.pyplot import *

N = 201 # Number of mass points
nT = 1200 # Number of time points
mi = 0.02
m = [mi]*(N) # mass array of points on string
m[-1] = 0.02
m[0] = 0.02
ki = 10.
k = [ki]*(N) # Spring constant
k[-1] = 0
k[0] = 0
dx = 0.295
kappa = ki*dx
my = mi/dx
c = sqrt(kappa/my) # velocity
print c
dt = 0.9*dx/c # Courierx = arange( N )*dx
t = arange( N )*dty = zeros( [N, nT ] )

#Initial condition with t= 0
for i in range(N-1):
    if (70 <= i <= 99):
        y[i,0] = (i - 69.)/30
    elif (100 <= i <= 128):
        y[i,0] = ((129 - i)/30.)
    else:
        y[i,0] = 0.#Wave equation
for j in range(nT-1):
 
    for i in range(N-1):
        if j == 0:
            y[i,j+1] = 2*y[i,j] - y[i,j] + (dt**2/m[i])*(k[i-1]*y[i+1,j] - 2*k[i-1]*y[i,j] + k[i]*y[i-1,j] )
        else:
            y[i,j+1] = 2*y[i,j] - y[i,j-1] + (dt**2/m[i])*( k[i-1]*y[i+1,j] - 2*k[i-1]*y[i,j] + k[i]*y[i-1,j] )

    cla()
  
    ylim(-1,1)
    plot(x,y[:,j-2])
    pause(0.001)

Here is the plot:

figure_55.png

I want to make changes to my program so the one triangle wave pulse moves to the right and gets reflected instead of splitting up in two opposite moving pulses. How can I change my initial conditions to make this possible? I want something like this:
Wave_equation_1D_fixed_endpoints (1).gif
EDIT:I am not sure if the pictures was correctly added!
 
Last edited:
Technology news on Phys.org
  • #3
The pictures have been Uploaded now. Thanks @jedishrfu :smile:
 
  • #4
Omsin said:
I want to make changes to my program so the one triangle wave pulse moves to the right and gets reflected instead of splitting up in two opposite moving pulses. How can I change my initial conditions to make this possible? I want something like this:
View attachment 200293
You need to specify the initial speed of the triangle wave as well. Or you could move one of the ends. That's what you would do with a real string.
 
  • #5
willem2 said:
You need to specify the initial speed of the triangle wave as well. Or you could move one of the ends. That's what you would do with a real string.
But how can I implement this initial velocity?
 
  • #6
Omsin said:
But how can I implement this initial velocity?

It's more usual, to use 2 arrays, one of them with the positions and one of the with the velocities, and then use y[x][t] += v[x][t] * dt and v[x][t] += dt * acceleration,
What you have done is to store the complete history of the positions of the string. You then use the difference between the two last values of the position to add to the last postion to get the next position.
your y[i,j+1] = 2*y[i,j] - y[i,j-1] + ... does this. But this doesn't work if j is 0, so you use y[i,j+1] = y[i,j] + ... . The effect of this is to make the initial velocity 0.
If you want to set a nonzero initial velocity you must initializie both y[i,0] and y[i,1] to different values
 
  • Like
Likes Omsin

1. What is a traveling triangle pulse?

A traveling triangle pulse is a type of wave that travels along a string, with a triangular shape that moves forward in a periodic motion. It is created by a sudden displacement of the string at one end, causing the wave to propagate along the string.

2. How can I create a traveling triangle pulse?

To create a traveling triangle pulse, you will need a string, such as a rope or a rubber band, and a fixed point to anchor one end of the string. Then, with your hand, quickly pull and release the string at the anchored end to create a sharp triangular wave that travels along the string.

3. What factors affect the speed of a traveling triangle pulse?

The speed of a traveling triangle pulse is affected by the tension of the string, the density of the string, and the length of the string. A higher tension and lower density will result in a faster pulse, while a longer string will result in a slower pulse.

4. How does the amplitude of a traveling triangle pulse change as it travels?

The amplitude of a traveling triangle pulse does not change as it travels along the string. It remains constant until it reaches the end of the string or encounters an obstacle that causes it to reflect or diffract.

5. Can I create a traveling triangle pulse in other mediums besides a string?

Yes, traveling triangle pulses can be created in other mediums, such as water or air. However, the properties of the medium, such as density and viscosity, will affect the speed and shape of the pulse. Additionally, the method of creating the pulse may vary depending on the medium.

Similar threads

Replies
1
Views
1K
  • Programming and Computer Science
2
Replies
55
Views
4K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
1
Views
947
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
17
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
4
Views
1K
Back
Top