Member-only story

Modeling a Wave on a String With the Finite Difference Method in Python

Rhett Allain
11 min readMar 16, 2022

--

Photo: Rhett Allain. A plucked guitar string is a perfect example of a wave on a string.

There’s a very good chance that you have at least plucked a guitar string. When you do that, you deform the string under tension with some initial state. After that, the “plucked” parts of the string interact with the other parts of the string — and you get a wave.

But how do you model this in python? Assume that you have the initial shape of a string that is fixed at the two ends with some constant tension — how do you model the motion for future times? Yes, this is what we are going to do. Don’t worry, I’m going to start from the very basics.

A String as Finite Elements

Let’s pretend that the string consists of a bunch of individual masses connected by massless strings. It would look something like this.

Each mass is labeled with an index and they are separated by a distance of Δx and they all have the same mass. Note: this is a very small displacement such that we can keep each mass a constant distance Δx from each other. Oh, two more things. First, each mass can ONLY move in the vertical (y) direction and second the tension in the string has a constant…

--

--

Rhett Allain
Rhett Allain

Written by Rhett Allain

Physics faculty, science blogger of all things geek. Technical Consultant for CBS MacGyver and MythBusters. WIRED blogger.

Responses (1)