Mechanics Lab 6. Planetoids with a Spring

Instructions

Please take this pre-survey before beginning this exercise!

Think back to the momentum exercise. The little ship can collide with a "blob" and stick to it. Now imagine that this blob is attached to a spring. Wouldn't it be interesting if the ship could collide with the blob and then the spring would push and pull both around? This is what we will do in this exercise.

This spring will be attached to the blob and do the left-hand side of the screen as shown below.

Step 0. Read/think about spring forces.

Thus far the only force we have considered is $F_{\rm thrust}$ which is a constant force in whatever direction the ship is pointing. (We also considered gravity in the lunar descent exercise, but for simplicity this was treated as a constant acceleration instead of a constant force.) The force from a spring is a very different kind of force. The more the spring is compressed, the more it pushes back and the more the spring is stretched out the larger the force to try and pull it back into the rest position. The formula that corresponds to this is given here:

$$F_{\rm spring} = -k (x - L_{\rm relaxed})$$

The idea is that if $x = L_{\rm relaxed}$ then the force is zero. When $x < L_{\rm relaxed}$ then the spring force is positive so that it pushes the object to a larger $x$ value. And if $x > L_{\rm relaxed}$ then the spring force is negative and the object is pulled to a lower $x$ value.

In the code you will soon develop, you should use Lrelaxed to represent $L_{\rm relaxed}$ and Fspring for $F_{\rm spring}$ and use x_blob for $x$ because it's the blob that is attached to the spring, not the rocket (which has a position x in the code).

Step 1. Open a modified version of the momentum code.

This version will have a spring drawn on it and other minor tweaks. Click here to open the code in an editor

Please note that this exercise will remain 1-Dimensional for simplicity! Sorry!

Step 2. Add the spring force! Let the blob accelerate!

We are going to add a spring force to the blob. If the position of the blob (x_blob) is not equal to the relaxed length (Lrelaxed) the force will cause the blob to accelerate.

To add the spring force, change the code in the following ways:

If you are able to make all these changes your code should behave like this.

Step 3. Get the spring to do this! Think about the motion!

When is the velocity the largest? When is the force the largest? When is the acceleration the largest?

Step 4. Analyze the motion!

Let's modify the code in order to measure how long it takes for the blob to go from the relaxed position to either the fully stretched or fully compressed position and back. The easiest way to do this is to measure the amount of time it takes for the blob to return to $x = L_{\rm relaxed}$. This turns out to be trickier than it sounds. Follow the directions below. If you can think of a different way to do this, please feel free to try it out!

Step 4.a. Somehere after display(); add this:

tcounter += dt; 
drawText('counter time = ',0.7*width,0.8*height);
drawText(tcounter,0.75*width,0.75*height); 

// if the position of the blob is near the relaxed position
if ((abs(x_blob - Lrelaxed) < abs(vx_blob)*dt) & (tcounter > dt)) {
tlasttime = tcounter;
tcounter = 0; //Reset the clock
} 

drawText('half cycle time = ',0.7*width,0.65*height);
drawText(tlasttime,0.75*width,0.6*height);

When x_blob is close to the value of Lrelaxed and tcounter is much larger than a timestep, then the value of tcounter gets copied to tlasttime. Then the "clock" gets reset to zero with tcounter = 0.

If you modify your code correctly your program should behave like this.

Step 4.b. Measure the "half cycle time" when the ship is attached to the blob

Fly the ship into the blob and then without firing the thrusters, watch the ship move back and forth a few times from the force of the spring. Write down what the typical "half cycle time" is.

Step 4.c. Increase the amplitude of the oscillations! See what happens to the half-cycle time!

There are two ways to increase the amplitude of the oscillations: (1) you can fire the thrusters while the ship is attached, or (2) you can give the ship different initial speeds before it slams into the blob (ex.  vx = -10, vx = -20, vx = -30...) Is the half cycle time the same or different? Make sure you watch the oscillations for a few cycles before you decide. Does the answer surprise you?

Step 5. Calculate the expected "half cycle time" from what you know about oscillating springs.

What is the "half cycle time" equivalent to? The angular speed? frequency? period? Use what you know about the period of an object attached to a frictionless spring to calculate what you would expect the "half cycle time" to be based on the mass of the objects and the spring constant. You should be able to estimate this quite accurately. (Hint: the angular speed of a frictionless spring is $\omega = \sqrt{k/m}$.)

Step 6. Does the "half cycle time" depend on whether the ship is attached to the blob? (It should!)

It should be possible to fly your ship into the blob to get it oscillating and then fire your thrusters so that the ship flies away from the blob, but the blob is still oscillating. Another way to get the blob oscillating without the ship attached is to set vx_blob = -10; and just let it move without crashing the ship into it.

What is the "half cycle time" of just the blob? Is it the same as it was when the blob and the ship were oscillating together? The "half cycle time" should be slightly different when the spring is only pushing around the blob because there is less total mass to push around!

Step 6.a. If the half-cycle time is the same with and without the ship, modify your code to treat these cases differently Configure your program so that deltaVx_blob is different depending on whether the ship has collided or not (Fspring will be the same, but the mass is different depending on whether the ship is close to the blob).

If you modify your code in the right way your program should behave like this.

Step 6.b. Measure the "half cycle time" Measure the half cycle time for both when the ship is attached to the blob and when the ship is not attached to the blob. Make sure you can explain both results for the half cycle time from your knowledge of oscillating spring systems (i.e. from Step 5)

(Challenge part 1) Step 7a. Add damping to the spring system!

Add a drag (a.k.a. damping) force to the spring system. There is more than one kind of damping force you could use, but the simplest is $F_{\rm drag} = - b v$ where $b$ is a constant.

Test it out! Roughly how many cycles does it take for the motion to slow to a stop? Underdamped systems go through multiple oscillations before they slow to a stop. Make b much larger until the damping is so large that the system slows to a stop without oscillating. Overdamped systems slow to a stop without going through multiple oscillations. What value of b should you use to simulate a critically damped system?

(Challenge part 2) Step 7b. Calculate and Measure the half-cycle time for the damped system

Use the default values for the mass of the ship, the mass of the blob and the spring constant and set the damping constant b = 2.0. What do you measure for the half-cycle time now? You should be able to do a calculation that explains why you get the number that you get. (Hint: the angular frequency of a damped spring system is $\omega = \sqrt{k/m - (b/2 m)^2}$).

Please take this post-survey after completing the exercise!

Things you need to do to get full credit for this programming lab:

1. Submit your spring.js file after making all the changes asked for in steps 1-4 and (if you decide to) the challenge steps 7a and 7b

2. Measuring and calculating the half-cycle time

In carmen there is a comment box when you submit the code. Make sure to write the half-cycle time you measured in part 4, and describe the calculation you did in part 5 to explain why the half-cycle time turned out to be the number that it did. The number you calculate and the number you measure should be very similar. If the numbers are way off then you probably won't get full credit.

3. State whether the half-cycle time depends on the amplitude

Fly into the blob and then use your thrusters to make the amplitude of motion larger. Then stop firing the thrusters and measure the half-cycle time. Does it change or not?

3. The challenge is optional but if you take the time to do it you will get a few points of extra credit.