You are not logged in.
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