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
4 Nov 2024 13:12:24 EST (-0500)
  Re: I think I did something wrong with RK4...  
From: Chambers
Date: 7 Apr 2008 14:10:01
Message: <web.47fa61df5da3d86b261d9700@news.povray.org>
"scott" <sco### [at] laptopcom> wrote:
> If I am guessing correctly, "particles_stepped" includes velocity
> information?  Well you need to keep 4 separate copies of the velocity
> information just like you did with the force information.
>
> >  for (int i=0; i<size; i++) {
> >   forces_final[i] =
> >    (forces_now[i]+2*forces_A[i]+2*forces_B[i]+forces_C[i])/6.0f;
>
> Then you need to calculate the weighted sum of the velocities in this manner
> too here, and use the weighted velocity in the final step call.

Sorry, but I have trouble believing that without seeing a proof.  Intuitively,
if I am tracking the velocity information, then why do I need the force
information separate?  But if I integrate the forces, why should the velocity
information be separate?  What I want is a final force value that I can use to
modify my velocity value.

Anyway, looking for other sources on RK4, the Wikipedia article at
http://en.wikipedia.org/wiki/RK4 mentions something that was left out here...
that the weighted average of the forces should be multiplied by the timestep.

That would change the above line to
(forces_now[i]+2*forces_A[i]+2*forces_B[i]+forces_C[i])*dt/6.0f;

This would account for the strange scaling effect I saw.  When I get home
tonight, I'll try it out.

......Chambers
www.pacificwebguy.com


Post a reply to this message

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