POV-Ray : Newsgroups : povray.off-topic : RK4 is harder than it seems : Re: RK4 is harder than it seems Server Time
7 Sep 2024 05:08:48 EDT (-0400)
  Re: RK4 is harder than it seems  
From: Invisible
Date: 31 Jul 2008 10:01:29
Message: <4891c5b9$1@news.povray.org>
> The fact that you are even asking that question makes me think you are 
> implementing RK4 incorrectly.

Well, considering I have no clue why RK4 even works in the first place, 
that's hardly surprising. ;-)

> The whole point of RK4 is that it gives 
> more accurate results when the forces depend on positions of other 
> particles (eg springs, collisions etc).

Really? I was under the impression that RK4 works just like other 
methods, but just gives superior numerical accuracy.

> I suspect you are trying to apply the whole RK4 algorithm to one 
> particle, then the next, etc.  This is wrong.

It works fine if you only *have* one particle. ;-)

Actually, the simulation I'm about to run only consists of one particle. 
But in future I'd like to handle more.

Currently my code is structured the way you indicate. (Heck, you can go 
*read* it if you like... it's in the other NG.) But that doesn't allow 
more complex systems.

> You need to store the positions and velocities of all the particles 
> together in one "state" object.  Then you apply each step of RK4 on the 
> whole state at once.  If you need the positions of other particles when 
> calculating the force, then of course you have all the position and 
> velocity information available in the state local to the current RK4 step.

Right. So just make all functions apply to the entire system at once. I 
think I can do that...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.