help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## [Help-gsl] a basic question concerning RK4

 From: cigdem ozkan Subject: [Help-gsl] a basic question concerning RK4 Date: Fri, 4 May 2007 02:48:22 -0700 (PDT)

```Hey there,
I have a technical question but one has to go through the story to understand
what I am tyring to achieve. I hope you can find the time to do so. It is very
basic physics so it only requires patience to read through the rest of my email
:) Thank you already.
I am trying to simulate the Coulomb repulsion between charged particles. I am
using RK4 to do this which requires a function. The physics formula of the
function is:
dx/dt = k*qi*(xi-xj)/sqrt((xi-xj)^2+(yi-yj)^2+(zi-zj)^2)
where qi is the charge of the i-th particle, xi, yi, zi are the coordinates of
the i-th particle and xj, yj,zj are the coordinates of the j-th particle.
As an input for the initial values of the positions and charge for each
particle, I am using arrays (currently only for 4 particles):
q =  { 1.0, 1.0, -1.0, 1.0 } charge
x0 = { 1.0, 2.3, 3.2, 4.0 } init posn x
y0 = { 1.0, 2.4, 3.0, 4.0 } init posn y
z0 = { 1.0, 2.5, 3.3, 4.2 } init posn z
and by using two "for" loops I can loop through each particle and compute the
value of the total effect of all the particles on eachother.
My question is: since there are two values for each coordinate (i and j), how
can I write the function in an acceptable form for RK4?
I did try the following:
int func (double t, const double y[], double f[], void *params){
double mu = *(double *)params;
double dx = (y-y)/r;
double dy = (y-y)/r;
double dz = (y-y)/r;
f = mu*y*dx/(r*r);
f = mu*y*dy/(r*r);
f = mu*y*dz/(r*r);
return GSL_SUCCESS;
}
however, I am not convinced this is correct (at all) and as it is I have to
specify too many initial values for y (ie, y, y,...y) and it fails
miserably.
I would appreciate any feedback especially if someone has HAD to do something
similar.
Cheers.
Best,
C.

---------------------------------
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]
• [Help-gsl] a basic question concerning RK4, cigdem ozkan <=