+
Lattice Elasticity, the Vibrating String, and Nonlinearity
Developed by W. Freeman  Published January 12, 2019
The standard description of the behavior of the vibrating string is only valid in the lowamplitude limit. In this exercise, students build a latticeelasticity model of a vibrating string and then study its properties, first verifying that the standard properties predicted by $v=\sqrt\frac{T}{\mu}$ hold in the low amplitude limit and then studying the nonlinear properties of the vibrating string as the amplitude increases.
Subject Areas  Waves & Optics, Mathematical/Numerical Methods, and Other 

Levels  Beyond the First Year and Advanced 
Available Implementations  C/C++ and Easy Java Simulations 
Learning Objectives 
* Students will be able to construct a discretized model of a continuum system that reproduces the continuum properties, and understand its limits of validity (**Exercises 1, 4, and 5**)
* Students will be able to code numerical models involving arrays of dynamical variables (**Exercise 2**)
* Students will be able to test a dynamical model using conservation of energy and visualizations to verify its behavior (**Exercise 3**)
* Students will become familiar with the lowamplitude and highamplitude phenomenology of the vibrating string (**Exercises 46**)
* Students will be able to flexibly analyze data from numerical models to determine a powerlaw relationship (**Exercise 6**)
* Students will become familiar with "perturbative thinking" and the characteristics of the onset of nonideal behavior (**Exercises 56**).

Time to Complete  90360 min 
These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).
# Part 1: Modeling
The goal of this project is to numerically calculate the vibrations of a stretched string of total mass $M$, unstretched length $L$, Young's modulus $Y$, and crosssectional area $A$.You will do this by modeling it as a series of $N+1$ point masses of mass $m$ connected by $N$ Hooke'slaw springs, each of equilibrium length $r_0$ and spring constant $k$.
Recall that the spring constant $K$ of the overall spring is given by $K=AY/L$. The variables $A$ and $Y$ only appear in the combination $AY$; it is useful to define this as the "stiffness", $\gamma \equiv AY$.
 What mass $m$ should the point masses have, and what equilibrium length $r_0$ and spring constant $k$ should the springs have, in order for the properties of the model to match the properties of the string itself?
# Part 2: Coding
Now you will use a computer program to calculate numerically the behavior of this model of the vibrating string, since it is just a collection of $N+1$ objects (two of which are held
fixed, at either end) moving under the influence of calculable forces (from the Hooke'slaw springs).
 How many dynamical variables will you need to update during each integration step? What are they?
 Each mass feels forces from the two springs that connect it to the two adjacent masses. Write an expression for the net force on mass $i$ in terms of the model parameters and the positions of the other masses. (It may be cleaner if you do this in several steps, defining intermediate variables for the separation magnitudes involved. It may also make your code cleaner to introduce such an intermediate variable; remember, memory is cheap!)
As a reminder: Hooke's law says that a spring with endpoints at $\vec r_A$ and $\vec r_B$ exerts a force on the endpoint at $\vec r_A$ equal to
$$\vec F_{BA} = k(r_{AB}  r_0) \hat r_{AB}$$
where $\vec r_{AB}$ is a vector pointing from A to B.
![](images/vibratingstring/stringdiagram.png)
 Once you understand how to calculate the force on all the masses, write code to numerically integrate Newton's law of motion for the system. At first, do this with the EulerCromer integrator. Some hints:
1) You'll need to store the dynamical variables in arrays. If you are using C, remember that arrays are passed to and "returned from" functions in a different way than single numbers. However, it may be quite helpful to write functions with names like `get_forces()` and `evolve_euler_cromer()`.
2) Remember that the EulerCromer prescription is to update the positions based on the velocities, then compute the acceleration from the new positions and update the velocities. However, you need to update *all* the positions first, then *all* the velocities. Otherwise you'll be in a situation where a given update uses old data for the left neighbor and new data for the right neighbor, or viceversa, and you'll get results that depend on which way you run your `for` loop (which is clearly not right).
3) There is a famous riddle: "A farmer wants to build a hundredfootlong fence with fenceposts every ten feet. How many fenceposts does she need?" The answer is not ten, but eleven; answering "ten" here is called a "fencepost error" in computing. Note that you have $N$ springs and $N+1$ masses, but that the first and last of these do not move. This, combined with the fact that your programming language probably uses zeroindexed arrays (so an array of 100 things is numbered 0 to 99) means that you will need to think clearly about the bounds of your `for` loops.
# Part 3: Testing
Once you have your numerical solver coded, you will need to supply initial conditions. At first, consider a stretched but unexcited string, where the two endpoints are held fixed at some distance $L' > L$ such that the spring bears a tension $T$.
 In terms of the string parameters $L$ and $\gamma$, and the tension
$T$, what is $L'$? (That is, how far must you stretch your string to achieve the desired tension?)
 In terms of $L'$ and your number of segments $N$, what initial conditions for the $x_i$'s and $y_i$'s correspond to this stretched but unexcited string?
 Code these initial conditions and verify that your string doesn't move. If you haven't already, make your program animate your vibrating string using your favorite visualization tool.
 Now, excite your string by displacing it in some fashion and verify qualitatively that it moves realistically. Note that if you choose the simplest thing and displace only one point mass, this corresponds to "whacking a guitar string with a knife"; you will get rather violent oscillations in this case.
 Modify your program to track conservation of energy. The kinetic energy is just the sum of $\frac{1}{2}mv^2$ for all the masses, and the potential energy is the sum of $\frac{1}{2}k(rr_0)^2$ for all the springs. Verify that your simulation approximately conserves energy.
# Part 4: The lowamplitude limit, qualitatively
If the vibrational amplitude is sufficiently small, the trigonometric functions involved in the geometry here can be replaced with the first nontrivial term in their Taylor series. (These are often called the "smallangle approximations.) When this is done, the system becomes perfectly linear and can be shown to obey the classical wave equation. This leads to the behavior you are probably familiar with, characterized by three main properties:
1) The "normal modes", oscillatory patterns of definite frequency, are sine waves with a node at either end (and possibly other nodes in the middle). Specifically, the $n$th normal mode is given by $$y(x,t) = A \sin \frac{n \pi x}{L'} \cos \omega_n t,$$ where $A$ is some arbitrary amplitude.
2) The frequencies $\omega_n$ are given by $$\omega_n = \frac{\pi v n}{L'}$$ where $v$ is the wavespeed, given by $$v=\sqrt{T/\mu'}.$$ (Recall that primed quantities correspond to their values *after* the string has been stretched.)
3) Since the system (in the ideal, lowamplitude case!  which is all you can solve easily without the computer) is perfecty linear, any number of normal modes, with any amplitudes, can coexist on the string without interfering. Any arbitrary excitation  like a plucked guitar string  is a superposition of many different normal modes with different amplitudes.
Let's now see how well your string model reproduces these ideal properties.
 Write initialcondition code to excite your string in any given normal mode with any given amplitude. Using a tension sufficient to stretch your string by at least twenty percent of its original length, try different normal modes at various amplitudes (ranging from "barely visible" to "large"). Does your model reproduce the expected qualitative behavior of the ideal vibrating string? In which regimes?
 How does the behavior depend on the number of masses $N$ you have chosen? Should this affect the behavior at all? Is using a large $N$ more critical for modeling the low$n$ normal modes, or the high ones? Why?
 Now, write initialcondition code to excite your string with a Gaussian bump with any given width and location. Excite your string with narrow and wide Gaussians of modest amplitude, located both near the endpoints and near the center of the string. By observing the animation, comment on whether you have excited mostly the lower normal modes, or the higher ones.
 If you have access to a stringed instrument (guitar, violin, ukelele, etc.), excite your *real* string in these ways (by plucking it with both your thumb and the edge of your fingernail, both near the center of the string and near the endpoint). How does the timbre of the sound produced correspond to the answers to your previous question?
# Part 5: The lowamplitude limit, quantitatively
Now, let's study the string's vibrations precisely, and determine how well and under what conditions they align with the analytic predictions.
The quantitative thing that we can measure is the string's period. To measure the period of any given normal mode $n$, select a mass near an antinode of that mode, and watch it move up and down. If your initial conditions displace the string in the +y direction, then the string has completed one full period when the string moves "down, then back up, then starts to go down again". To have our program tell us when that is, we want to watch for the time when the velocity changes from positive to negative.
In order to detect this, you'll need to introduce a variable that keeps track of the *previous* value of $v_y$ at that position, so you can monitor it for sign changes.
 Modify your code to track the period, and measure the period of a normal mode of your choice. How does your result correspond to the analytic prediction in the lowamplitude regime for different normal modes? Vary the tension, mass, Young's modulus, and length, and see if your simulation behaves as expected.
# Part 6: Getting away from the lowamplitude limit
All of the things you've learned about the vibrating string  noninterfering superpositions of normal modes whose frequency is independent of amplitude  relate to solutions of the ideal wave equation. But deriving this equation from our model requires making the smallangle approximation to trigonometric functions, and this is only valid in the limit $A \rightarrow 0$. Now it's time to do something the penandpaper crowd can't do (without a great deal of pain): get away from that limit.
* Try running your simulation at higher amplitudes using a variety of initial conditions. Play with this for a while. Do you still see welldefined normal modes with a constant frequency that "stay put"? Look carefully at the motion of each point; do they still move only up and down? Describe your observations.
***
## A digression (and an important one for your future)
The single most powerful tool in quantum mechanics, and one that is useful in many other fields of physics and engineering, is something called *perturbation theory*. The idea is that many physical situations are *close to*, but *not quite like*, an idealized situation with an analyticallytractable solution. For instance, in quantum mechanics, a hydrogen atom in a weak electric field behaves mostly like a hydrogen atom in no field, but with small corrections from the electric force. The hydrogen atom is one of the few quantum systems whose behavior can be calculated exactly.
As you might expect, if the system consists of "thing we know how to solve + small corrections", its behavior consists of "solution to the thing we know how to solve + small corrections". *Perturbation theory* is the technique of computing a Taylor expansion of the system around the thing we know how to solve, then solving this Taylor expansion term by term to arrive at a solution which is also a Taylor series around the known behavior.
So, to calculate the behavior of a hydrogen atom in an electric field, we write the solution as a power series expansion around the behavior with $\vec E = 0$, and then analytically calculate the expansion coefficients. This technique is tremendously powerful throughout physics.
We will not be doing these power series by hand here. However, you should be aware that this is a system that behaves *perturbatively*; there is a known ideal behavior (the zeroamplitude limit), and your system departs from it as the amplitude is increased away from zero. It is in principle possible to describe the solution to the physical vibrating string as a power series expansion around the ideal behavior, and analytically calculate the expansion coefficients to as high of an order as you want.
Some of you may recall that power series have a limited regime of convergence. In the example given above with the hydrogen atom placed inside an electric field, for sufficiently strong electric fields perturbation theory will fail: the system will no longer act like a hydrogen atom with small corrections. Likewise, at very high amplitudes or very low tensions, the behavior of your vibrating string will no longer retain the character of "an ideal linear vibrating string with small corrections", and will instead behave in a totally different way. This behavior is called *nonperturbative*, since it can no longer be described with perturbation theory.
This progression  from ideal behavior to the perturbative regime to the nonperturbative regime, as the amplitude (in this case) is increased  is echoed across physics.
***
Define $\Delta(n,A)$ as the relative deviation from the analytic period $\mathcal T = 2\pi\sqrt{\frac{\mu}{T}}$ and the observed period, defined as $$\Delta(n,A) = \frac{\mathcal T_{\rm {obs}}\mathcal T_{\rm{an}}}{\mathcal T_{\rm{an}}}$$. This will depend on the normal mode you're looking at and the amplitude. Modify your program to print out $\Delta$ as it measures the period. Conduct the following tests with a timestep small enough to ensure precise results and a value of $N$ high enough that you are essentially in the continuum limit. (In other words, we are trying to measure things about real strings here, and don't want simulation artifacts interfering.)
 For your favorite values of $T$, $L$, and $\gamma$, measure $\Delta(A)$ for $n=1$ and another normal mode on the same graph. Start with amplitudes small enough that you expect perfectly ideal behavior, and increase the amplitude until you are unable to reliably measure the period. (What goes wrong with your period measurement at this point?)
 At leading order, we expect $$\Delta \propto A^m$$. Plot $\Delta(A)$ vs. $A$ and determine the power $m$.
 Now examine $\Delta$ vs. $A$ for both the $n=1$ mode and the $n=4$ mode. Which mode shows more severe departures from linearity? Does this align with your expectations?
 If you ask someone to imitate the sound of a plucked double bass (such as is used in jazz or bluegrass music), they will likely make a "doon, doon" sound, with *each note sliding downward*; that is, the frequency is highest right after the string is plucked, and decreases slightly as the note decays. Does this correspond to the behavior of your model?
 (For the musicians) Look up the physical parameters (length, density or mass, crosssectional area, Young's modulus, and playing tension) of a string of your choice on your favorite stringed instrument. (If you choose a wound string, make sure you use only the inner crosssectional area in computing the stiffness $\gamma$.)
A value of $\Delta=0.01$ (a deviation of about 16 cents, for the musicians) corresponds to a note being significantly out of tune, while a pickier person might perceive $\Delta=0.003$ as audibly detuned.
Using your numerical model, what vibrational amplitude (measured in inches or cm) will throw the instrument significantly out of tune? Do you expect the nolianlinearity we are studying here to impact musical performance practice?
A value of $\Delta=0.01$ (a deviation of about 16 cents, for the musicians) corresponds to a note being significantly out of tune, while a pickier person might perceive $\Delta=0.003$ as audibly detuned.
Using your numerical model, what vibrational amplitude (measured in inches or cm) will throw the instrument significantly out of tune? Do you expect the nolianlinearity we are studying here to impact musical performance practice?
Download Options
Share a Variation
Did you have to edit this material to fit your needs? Share your changes by
Creating a Variation
Credits and Licensing
W. Freeman, "Lattice Elasticity, the Vibrating String, and Nonlinearity," Published in the PICUP Collection, January 2019.
The instructor materials are ©2019 W. Freeman.
The exercises are released under a Creative Commons AttributionNonCommercialShareAlike 4.0 license