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 such that the spring bears a tension .
In terms of the string parameters and , and the tension , what is ? (That is, how far must you stretch your string to achieve the desired tension?)
In terms of and your number of segments , what initial conditions for the ’s and ’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 for all the masses, and the potential energy is the sum of for all the springs. Verify that your simulation approximately conserves energy.