## Behavior of a line of compressed springs

Official forum for the Chipmunk2D Physics Library.

### Behavior of a line of compressed springs

Hola Chipmunkers:

I am trying to simulate a top-walled, vertical line of back-to-back compressed-spring objects, which all want to expand to their rest lengths. Once I start simulation, I expect the objects to each "relatively expand" (ie, rel. to their local frame) and thus for the whole end-to-end line of them to show a gradient of velocity towards the bottom, non-capped end: as each expands it is in turn being moved downwards by its upper neighbors' expansion (since they are in contact), and so on... But I only see the free-end object expand and the inner objects are completely stuck and not expanding. Does anyone understand why this is so?

Here is the detail of the objects' construction if it helps explain:
Each logical object is a pill-shaped "cell" (actually an EColi cell) and consists of 2 symmetric cpBodies constrained to each other by symmetric pairs of groove joints. I want each cell to "grow" lengthwise, so I attach a spring joint to its two ends (the outer edge of each body) and set a larger rest length and appropriate spring constant to setup an expansion force. The cells' cpShape-ends are all in contact end-to-end in a vertical column and I have a narrow (just larger than single cell-width), closed-top, static-body channel (static segments that make an upside-down 'U' shape, fully elastic and frictionless) that constrains them to move single-file, vertically downwards, where they will disappear past an edge of the space (no damping). Thus, the topmost cell end is butted against a static-body "wall" and the bottom-most cell end is free of any contact.

It appears all the inner cell-to-cell contact forces are cancelling each other, thus only the bottom-most cell expands. I do not understand the behavior, but perhaps the question reduces to that of a single spring joint:

If a spring joint connects two cpBodies A and B, let's call F+ the force on body A and F- the force on body B (assumed equal and opposite for free expansion) that results from the spring force to expand the bodies. If body A is against a static "wall", does the force on body B become 2*F+, or does it stay F+?

Thanks for any help, or if anyone has any other ideas on how to solve this! --jw
winkle

Posts: 6
Joined: Tue Dec 22, 2015 11:21 am

### Re: Behavior of a line of compressed springs

Hmm. That should be working. My only offhand thought is that you have sleeping enabled and they are falling asleep before they have a chance to expand?

If a spring joint connects two cpBodies A and B, let's call F+ the force on body A and F- the force on body B (assumed equal and opposite for free expansion) that results from the spring force to expand the bodies. If body A is against a static "wall", does the force on body B become 2*F+, or does it stay F+?

Not quite. The spring always pushes on both objects with the same (but opposite) force, like described by Newton's laws. The catch is that since the static body has infinite mass, it doesn't move. In a realistic setting, a spring pushing a weight away from the earth is also going to push the earth away from the weight. The forces are the same, but the earth is so much more massive that it's motion is so minuscule that it's not worth noting.

Your intuition is very close to another concept called "effective mass", which confusingly, more commonly refers to properties of semiconductors. The idea is that if you push an object at it's center of mass, it will feel like it's heavy, but if you push on a corner it will feel lighter. That's what effective mass is. A similar thing happens when a constraint acts between two objects. It's hard to push two cars apart, but easy to push a leaf and a car apart despite their total mass being being high. This is used when solving constraints where you want a certain response in the velocity, and you need to know the effective mass of the system to know how much force to apply. A good example would be a motor, since their speed is based on how much force they need to output. Springs are different since it's their position (length) that affects their force and not their velocity. (If you are scratching your head, this wasn't at all obvious to me when I started learning all of this.)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/

slembcke

Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

### Re: Behavior of a line of compressed springs

Yes, I see now the force will be identical on either side. I was intuitively thinking of the spring energy (eventually completely) being converted to kinetic only on one side, but the force is the same whether or not the other side is against a static (massive) body.

Re: the expansion problem, it seems I had a residual high spring damping set for my expansion springs and that seems to solve the issue. Thanks for your response, sometimes explaining it helps search for the right code that is the culprit.

I am having some other issues getting the correct damping regime settled to model observed behavior, but I will save that for another post if it does not get resolved. We have looked at the velocity update function and changing the way damping is implemented on an body to include the body's mass, but this has not yet solved anything.

Thanks again for the response. Chipmunk has been great to work with.... JW
winkle

Posts: 6
Joined: Tue Dec 22, 2015 11:21 am