Physics 307 Homework 7
Due Tuesday, 12 November, at 5 PM
Progress report due 6 November before class
This homework assignment is the first of several parts. I encourage you to try to finish
this assignment ahead of time and begin the next one before the deadline of this one. This
assignment requires you to write some code; the next assignment will involve using that code
to study some physics.
Your “report” for this assignment will just consist of keeping us up-to-date on your progress;
next Thursday we’d like to see where you are, and will come around and check on you.
Please start early. I am giving you two weeks to do this assignment in order to accommo-
date anyone who may have some difficulty. This will be a bit more challenging to code than
your previous one; please don’t put it off until a few days before it’s due. We’ll be doing a
check-in in a week for a grade; you’ll be given a grade based on how well your code works
at that point. We don’t expect it to be perfect, only that you’re making good progress.
In this assignment, you will model a stretched string (as in a guitar or violin) using a lattice
elasticity model, in which point masses (“nodes”) are connected by Hooke’s-law springs. Fo
eference, the force law on any given node i (given in more detail in class) is:
kr̂i,i−1x(ri,i−1 − r0) + kr̂i,i+1(ri,i+1 − r0)
kr̂i,i−1y(ri,i−1 − r0) + kr̂i,i+1(ri,i+1 − r0)
~ri,j is a vector pointing from the i’th node to the j’th one, and is thus equal to (xj − xi)̂i+
(yj − yi)ĵ, k is the spring constant of a single spring, r0 is its unstretched length, and m is
the mass of each node.
A lattice simulation of a stretched string has the following parameters:
• The number of nodes in the simulation N + 1 (or the number of springs N)
• The linear mass density of the unstretched string µ
• The unstretched length of the string L0
• The tension T applied to it to stretch it, which gives you the stretched length L
• The stiffness α (Young’s modulus times cross-sectional area)
1. Determine values of m, k, and r0 (the “microscopic” quantities of interest to you
simulation) as a function of N,µ, L0 and α (the “macroscopic” quantities).
2. Write a program that simulates the vi
ations of a stretched string of uniform density
and elasticity, as we will discuss in class. (Notes will be posted on the website, too.)
You should be able to easily change (by setting variables) some crucial parameters of
your simulation: N,µ, L0, and α.
You should use the leapfrog solver for your simulation, although it might be useful to
code it using Euler-Cromer first as a learning exercise.
3. Determine the initial conditions (all of the xi’s; all the y-coordinates and velocities will
e zero) for a stretched but unexcited string with tension T applied to it. You will
first need to determine the stretched length L′, then put your N masses at equidistant
points between x = 0 and x = L′. Implement these initial conditions, and verify that
the string doesn’t move.
4. Now stretch your string with sufficient tension to stretch it by 25-100% of its un-
stretched length, and excite it somehow. You can do this by applying some external
force to it at some instant in time, or by choosing initial values for the yi’s. Verify
that it moves realistically. A simple initial condition that you can use is a Gaussian
deformation, in which
y(x) = exp
where xc is the center of the excitation, σ is its width, A is its amplitude, and σ and
xc are chosen so that the Gaussian dies down before you get to the ends of the string.
You may use any other initial conditions you like for testing.
5. Play around with your initial conditions, along with N , the stretch amount, µ, L, and
so on. Discuss anything interesting that you find. Note that your behavior ought to
e relatively independent of N . Your report should contain descriptions of all the stuff
you did and what happened.
6. Modify your program to track conservation of energy (recall that the elastic potential
energy in each spring is U = 1
k(r − r0)2) and verify that energy is approximately
Physics 307 Homework 8
First two parts due the Thursday after Thanksgiving; the final part is due
at the end of the term.
In this project you will study the properties of your vi
ating string. You have nothing
(much) to code this time, but you have quite a few things to simulate, study, and discuss.
A common exercise in physics is to study a simplified model of a vi
ating string where we
assume that the amplitude is small and the tension is large; this gives rise to the familia
ehavior we will discuss in class. For your project, you will examine this behavior, and
discover the limits of its validity.
As a reminder, some properties of the vi
ating string in this limit:
• Oscillations are a superposition of normal modes: y(x, t = 0) = A sin
, where L
is the stretched length
• Waves propagate along the string at a rate v =
• The n’th normal mode has a wavelength λn = 2Ln , giving it a period Tn =
• These properties don’t depend on the amplitude, in the limit of small amplitude.
Part 1: Verifying your code and testing the ideal behavior (due Tuesday, Novem-
1. Modify your initial conditions to simulate any normal mode of your choice. Then
modify your code to print out the period of your string; you can determine the half-
period by looking for points at which the velocity at an antinode changes sign. (“If it
was going up before, and now it’s going down, then we’re at a half-period” – you did a
similar thing for the pendulum.) Note that this is only valid if you have behavior that’s
elatively close to the vi
ation of a normal mode; otherwise, the idea of “period” is
2. Recall that our goal was to simulate a vi
ating string using only N and the macro-
scopic quantities T , α, µ, and L0. All microscopic quantities (the node mass m, the
individual spring constant k′, and the equili
ium radius r0 should be determined from
You need to verify that you are co
ectly implementing the relationship between the
macroscopic quantities and the microscopic quantities. You can do this by simulating
something well-behaved and verifying that the period doesn’t depend on N . Use
enough tension to stretch your string to XXXXXXXXXX× its starting length, and then simulate
the fundamental mode (n = 1) at a small amplitude. Verify that the period doesn’t
depend (much) on N . This is one check that everything is working properly.
3. Now, adjust the tension, linear density, unstretched length, and verify that the period
has the expected dependence on them. Remember, this expected dependence is only
valid in the “well-behaved” realm, where T is large and the amplitude is small.
IMPORTANT NOTE: The linear mass density µ that appears in the expression fo
the wave speed, and the quantity L that you use to compute the wave speed, are the
values after you stretch the string. You may handle this in any way you choose; one
is to compute a stretched density µ′ after you determine the stretch length that gives
the specified tension.
Part 2: Superpositions of normal modes (also due Tuesday, November 27
As you know, the vi
ations of a string (in the ideal case) can be characterized by a
superposition of normal modes.
4. You can also excite the string in more physical ways and study its behavior. Modify
your initial conditions so that you give the string a Gaussian “bump” in either velocity
or position in the beginning. Specifically,
yi = Ae
where xc is the center of the bump, and σ is its width; A is an amplitude. (Make sure
σ, or you’ll be moving one of the endpoints significantly.) You will probably
want to use a small amplitude to avoid blatantly nonlinear behavior.
If your small amplitude makes the vi
ations too small to see easily, you can always
multiply the y-coordinates by some factor when you display them, just to exaggerate
the motions to make them more visible.
This lets you excite the string with either a “soft” impulse, like a fingertip, or a “sharp”
impulse, like a guitar pick. You can also do this at different points on the string, from
the center to near the edge.
Try different sorts of excitation and qualitatively examine the character of the vi
tions produced. Mathematically, you would use a Fourier transform to determine the
amplitudes of the different normal modes, but you don’t need to do that here; it’s
enough to look at the overall character: “little fast wiggles” means that there is lots
of energy in the higher normal modes, while “slow big waves” means that there is lots
of energy in the lower modes.
5. Acoustically, an excitation that involves mostly lower normal modes sounds “darker”
or more “mellow”; an excitation that involves significant energy in the higher normal
modes sounds “
ight” or “tinny”. Consider the difference between exciting a guita
string with a pick (which applies a force to a very small region of the string) and
a finger (which applies a force to a larger region of the string). Simulate something
esponding to each of these and look at the oscillation of your string. Does the
observed behavior match the expected sound?
Part 3: Testing the nonlinear behavior you can’t do with pen and pape
(due Friday, December 7, or shortly thereafter)
Note: This part may be modified in the next few weeks.
6. Now we’re going to deviate from the limit of small amplitude (i.e. “what you learned
in pencil-and-paper physics class”) and look at the non-ideal behavior. Simulate a few
different normal modes at a range of amplitudes (ranging up to A ' L), and also vary
the tension. Discuss the validity of the “normal mode” idea outside of the limit of
small amplitude: does your simulation now exhibit independent normal modes, each
with a definite frequency?
Plot amplitude vs. period for several different values of the amplitude at moderate
tension (L/L0 ≈ 1.1), going roughly from small A to A = 0.4L. (Include enough points
that the character is clear.) Does your period give you the expected