POV-Ray : Newsgroups : povray.off-topic : I think I did something wrong with RK4... : Re: I think I did something wrong with RK4... Server Time
1 Oct 2024 13:22:04 EDT (-0400)
  Re: I think I did something wrong with RK4...  
From: scott
Date: 14 Apr 2008 03:24:17
Message: <480306a1@news.povray.org>
> OK, I "fixed" the timestep at 1/200th of a second, and removed all 
> particle collisions - now the only force is that of gravity.
>
> Using the two integrators, the particles follow roughly the same path, but 
> using RK4 they appear to have an increased velocity - they follow the same 
> path much more quickly.
>
> Which means I've got an error somewhere in my code...

It should be very easy to debug, simply print out (to a file?) the "state" 
and "derivative of state" information at each step of RK4 for one particle 
(that starts at zero velocity would make things simpler).  eg Just print out 
position and velocity in the gravity direciton.

Attached is a spreadsheet I made that matches up with the code I posted 
before, it shows you the values at each step for a constant acceleration, 
and compares the results with the Euler method and the exact solution. 
Hopefully you can spot the mistake in your code...


Post a reply to this message


Attachments:
Download 'rk4.xls.dat' (44 KB)

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