You are not logged in.

  • Index
  •  » Mechanics
  •  » Hooks Law Simulation gains energy (I don't know why)?

#1 2011-10-26 23:27:16

blaine
Member
Registered: 2011-10-26
Posts: 1

Hooks Law Simulation gains energy (I don't know why)?

f = -kX = ma, this is an ideal spring (K = 1, mass = 0, no heat loss) with a mass on the end, suspended in vacum at constant temperature.
'So, it should osc with fixed amplitude forever.
'But it gains energy for some reason?

pseudo code:
  v = 0
  a = 0
  p = 0
  mass = 1000000
  p = 1 'pre-tense the system
  k = 1 'hooks law constant
Do
    cv = v 'capture v,a,p for real life operation (blocked operation)
    ca = a
    cp = p
   
    v = v + ca 'Newton Mech velocity integration
    p = p + cv 'Newton Mech position integration
    a = -k * cp / mass 'acceleration, (Hook and Newton)
Loop

Why does this system gain energy when I simulate it?

It takes about 10 seconds for the amplitude to go from +/- 1 to +/- 1.01

My best guess is floating point impressionism (when cp is divided by mass) depending apon the value of cp?

Or a small positive vs negative floating point non symetry?

I can send a Visual BASIC program if interested, e-mail me blainenewman@gmail.com

Offline

 
  • Index
  •  » Mechanics
  •  » Hooks Law Simulation gains energy (I don't know why)?
Your Ad Here

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson