runge-kutta fun!
so i put together a pretty simple network of nodes, with arbitrarily chosen connections bridged with springs. each (potentially nD but right now 2d) node is acted upon by the force of each spring connection and a globalforce, which could be gravity, a force field, whatever.
and youre all thinking youve heard this before...dont hate me, i''m just launching into this for the first time. i cant for the life of me get it to work in my framework...it does indeed keep the simulation from blowing up, but it introduces unpredictability the more connected the model is.
most of the implementations ive seen are with two parameters (ie f(t, y)) but i dont quite know what my two parameters are. since i only have each node''s current position and velocity and each node is so dependent on the whole system, the only way i can know what the force is at (t + dt / 2)(and thus the acceleration, which is what im trying to integrate) is to advance the simulation to half the euler approximation (k2) measure that, etc. this defeats the whole purpose of t then, since im really measuring at position (y + k1 / 2)...so i dont know.
my current implementation grows from that:
*cache current system info
*euler approximate t + dt to find out k1 acceleration
*move halfway where i would have gone
*etc, each time moving back to original positions + half the new approximation, caching all the intermediate results
*finally, do the weighted average, move to new position
on a common sense level this seems to make sense, but like i said, its not acting right. im using a basically iterative version of my euler code, but now if four nodes are heavily connected, rather than blowing up they tend to contract tightly together.
is this the right approach? any ideas, based on the behavior, of what could be going wrong?
sorry for the long post.
I wrote something like that,fixed step Runge,
http://dmytrylavrov.narod.ru/sw.htm
(simulating app.)Sorry,that's in Pascal .
EDIT:take a look how it was splitten into separate modules for
Runge (and for Kutta,joking ),i mean simulator is separated from Runge-Kutta method,i could replace the method with Euler or anything if i want.
[edited by - Dmytry on January 24, 2004 5:48:06 AM]
http://dmytrylavrov.narod.ru/sw.htm
(simulating app.)Sorry,that's in Pascal .
EDIT:take a look how it was splitten into separate modules for
Runge (and for Kutta,joking ),i mean simulator is separated from Runge-Kutta method,i could replace the method with Euler or anything if i want.
[edited by - Dmytry on January 24, 2004 5:48:06 AM]
ok, ill have to go over this in the morning (rather, in the afternoon) since its in pascal...too tired to work through it.
but quick question: dow did you feed data back and forth? ie did you tell the rk method what each part''s total force was and it worked from there and how did you feed data back to tell the simulation how far in space to step forward for each part of the approximation.
and (sorry, i''ll look through the source tomorrow), did you evaluate for each node seperately? it seems like i cant, i have to move the whole system together since the "force function" for each node depends on the position of every other connected node.
thanks.
but quick question: dow did you feed data back and forth? ie did you tell the rk method what each part''s total force was and it worked from there and how did you feed data back to tell the simulation how far in space to step forward for each part of the approximation.
and (sorry, i''ll look through the source tomorrow), did you evaluate for each node seperately? it seems like i cant, i have to move the whole system together since the "force function" for each node depends on the position of every other connected node.
thanks.
What you''re basically talking about is a system of differential equations. I don''t know that it''s possible to solve for each node individually, but it is possible to solve the system. You''ll have to study up on second-order systems though.
I''m doing that: there''s function(simulator) that takes time and array of floats,A,that describes state of system,and returns deltas/dt for state,Dn=dAn/dt.
RK calls that function for different states and times,as in RK method description.D are multiplied by dt,half dt,etc,as RK should(search by google for RK method description), and added to A.
How to do acceleration:
A[1]=position;
A[2]=velocity;
so D[1]=A[2] and D[2]=acceleration=force/masse
yeah, ive figured most of this out in the last few days...rewrote my physics code twice.
to anyone else interested in this problem and physics engines in general, this page is a godsend:
http://www.pixar.com/companyinfo/research/pbm2001/index.html
two senior research scientists from pixar did a day long seminar on implementing physical simulations in a real time context and put all their slides and lecture notes online. andrew witkin especially has an amazing gift for conveying the mathematics of this.
working on implicit euler next...
to anyone else interested in this problem and physics engines in general, this page is a godsend:
http://www.pixar.com/companyinfo/research/pbm2001/index.html
two senior research scientists from pixar did a day long seminar on implementing physical simulations in a real time context and put all their slides and lecture notes online. andrew witkin especially has an amazing gift for conveying the mathematics of this.
working on implicit euler next...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement