Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Physics 307 Project 7, Parts 1 and 2

Part 1 due before class Wednesday, 8 November

Part 2 due before class Friday, 17 November

The capstone project for this course is to create a computer model of a guitar string, then use it to study phenomena that real strings demonstrate but that aren’t typically studied in PHY360 or any other physics class.

We’re going to model the guitar string as a series of point masses (called “nodes”) that are connected by springs that follow Hooke’s law, holding the two point masses on the ends fixed. By increasing the number of these masses, we can simulate a flexible, elastic object like a guitar string and then study its properties.

We’re going to build up to this in several parts. I’m going to post the whole project as soon as possible so you can work at your own pace, but am a bit behind on posting this because of a family emergency.

1 Part 1: Hooke’s Law Forces (due before class 8 Novem-ber)

1.1 Background

Ultimately we will have many masses, but this week you can start with two fixed masses and one in the middle that can move, then increase this to two fixed and two movable masses.

(Then you will extend things to N masses.)

Your simulation will have the following properties:

• Each node has a mass m

• Each spring has a spring constant k

• Each spring has an unstretched (equilibrium) length r0

Hooke’s law says that if a spring runs between two points  and , then the force it applies to the point ri has a magnitude

F = k(rij − r0)

where rij is the magnitude of the separation vector given by

We also need the distance of this force. If rij is greater than r0 (the spring is being stretched), then the force on point  points from  to . We can describe its direction with a unit vector:

We can put these pieces together to write the force vector as a proper vector:

1.2 Assignment

1. Write code to simulate a system with three nodes: two masses that are fixed in place (perhaps at locations (0,0) and (2,0)) and one movable mass that’s free to move con-nected by springs to the two fixed masses. Your code should allow you to easily change k and r0 and to put the movable mass anywhere you like as an initial condition.

2. Play with your code and verify that it works as expected. Submit a screenshot of the animation with your report. (Note that shift-P takes a screenshot in anim – this won’t work on Macs, though.)

3. Now, extend your code to use arrays for the positions and velocities of the three masses. In Python, this will entail using a two-dimensional array; in C, this will be an array of vectors. We will talk about how to do this Friday.

4. Extend your code to two movable masses (four total). This means, for instance:

• Mass 0 is fixed and doesn’t move

• Mass 1 feels forces from mass 0 on its left and mass 2 on its right

• Mass 2 feels forces from mass 1 on its left and mass 3 on its right

• Mass 3 is fixed and doesn’t move

Submit a screenshot of this in your report.

5. In your report, discuss how you might extend this system to N total masses, where N might be dozens or hundreds. (This is the next thing you’ll do.)

2 Part 2: Generalizing to Many Masses (due before class 17 November)

In this part, you’ll extend your simulation to use arrays and for loops to simulate a large number of masses, and then play around with various initial conditions.

1. Modify your code to simulate N + 1 masses with N links between them. Note that you’ll need to be careful about the bounds on the for loops you use to iterate over them:

• If you have N links and N + 1 masses, the indices for those masses will be (0 ... N)

• Since the masses on the ends don’t move, the moving masses will be (1 ... N-1)

• Since range() in Python chops off the last entry in the range, doing range(1, N) will produce a set from 1 to N − 1

2. “Stretch” your string by generating initial conditions for your masses that are equally spaced horizontally, but whose spacing is somewhat greater than the equilibrium length r0

3. Then play around with various initial conditions. Suppose that the stretched length is L′. You should try:

(a) A very simple initial condition where you displace a single mass vertically (this will produce some “interesting” behavior)

(b) A sinusoidal initial condition

where A is the amplitude and n is a small integer. Describe in your report how this behaves for different values of n and for values of A that are both much smaller than L′ and comparable to L′.

(c) A Gaussian initial condition

A Gaussian is a “bell curve” or “bump”; in this case, you’re creating a bump in the middle of your string with amplitude A, centered at xc, with width σ.

Describe how this behaves in your report for different values of σ.