Sign in to follow this  
The Rug

Spring Damping

Recommended Posts

Hi I'm having some trouble understanding spring damping, in particular, this document. Can anyone help explain where the second part of that equation comes from? I (think) understand the first part (before the + sign,) is Hooke's law, Fs=-kx (where k is spring constant and x is displacement.) With just this, the spring seems to work OK. The problem is the second part. I tried just implementing Fd = -cv for damping, then adding to Fs to get the total force, but everything went totally haywire. I took v to mean the velocity of the spring's current expansion, which is calculated using the velocities of the particles attached to the ends of the spring. So I rewrote the code as per the second part of that equation and now it works, but why? Why didn't the damping force work as calculated before? I really don't like simply taking code for granted... Clearly I am a physics noob and have done something very wrong, so be kind :)

Share this post


Link to post
Share on other sites
For dampening to work you need a very small time step. Otherwise the dampening force will be introduced too abruptly causing the system to be chaotic.

You'll also need to be mindful of the sign, it may be possible that you were adding energy rather than removing it.

Do you have some graphed or tabled results for your calculation? Can you be more specific about how it was not working correctly?

If it works now, it should be possible to see the difference (mistakes) between your coded implementation and your calculations.

Share this post


Link to post
Share on other sites
Quote:
I'm having some trouble understanding spring damping, in particular, this document. Can anyone help explain where the second part of that equation comes from?
Its the same as F=-c*v. The current velocity of one endpoint is (v2-v1) and the direction to which the spring exerts force is given by the two endpoints, forming the unit vector (r1-r2)/|r1-r2|.
Quote:
The problem is the second part. I tried just implementing Fd = -cv for damping, then adding to Fs to get the total force, but everything went totally haywire. I took v to mean the velocity of the spring's current expansion, which is calculated using the velocities of the particles attached to the ends of the spring.

So I rewrote the code as per the second part of that equation and now it works, but why? Why didn't the damping force work as calculated before? I really don't like simply taking code for granted..
Could you have forgotten a minus sign? Or either calculated v wrongly? (I mean, with the wrong sign) That would run the simulation into a big mess very quickly. Note, in the article you posted, that the velocity is calculated as (v2-v1), and is it added to the original force, instead of subtracting.
The article uses:
    F = F_ext + (v2-v1)*...
which is the same as
    F = F_ext - (v1-v2)*...
where you could easily have written
    F = F_ext -(v2-v1)
And if that's the case, havoc introduces itself for you :)

Share this post


Link to post
Share on other sites
Hi there,

I wrote a tutorial on mass-spring-damper systems explaining exactly this in great detail and with several illustrations and easy-to-read code samples (scroll down about halfway to get directly to the spring damping stuff).

http://www.freebasic.net/forum/viewtopic.php?t=9769

Cheers,
Mike

[Edited by - h4tt3n on September 8, 2009 1:03:11 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this