Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simulating inter-connected springs/beams

  1. Jul 6, 2007 #1


    User Avatar
    Science Advisor
    Homework Helper

    I've been writing a simple program to simulate what is essentially a bunch of springs connected together at nodes. However, I'm having trouble.

    Currently I just calculate instantaneous force for every spring/node, step ahead a fixed amount, and repeat. The problem is this tends to overestimate and I end up with a the whole system gaining a ton of energy unless I dampen the springs by a large factor.

    What is the next step up for this type of thing?
  2. jcsd
  3. Jul 7, 2007 #2
    It sounds like stepwise recalculations (possibly coupled with rounding errors on floating point numbers) are causing the problem. One kludge is to add up the total energy after each iteration and, if it has increased from the previous total, do a second pass to reduce all forces proportionately. This will solve the problem of creeping energy increase directly.

    Of course the main problem is the stepwise approach used in the simulation. The errors introduced by these approximations will cause total energy to change and they will also cause the model's behavior to deviate from an actual device's. The simplest solution is to reduce the size of each step to minimize the "staircase approximation" of the curves that are being modeled. Another solution is to find a better, more accurate midpoint value at each iteration, but this is not a programmatic problem, it takes some analysis of your model to find out what is best.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook