``getphi''

Package your previous Poisson solver program into a routine of the prototype below in ``physics.c''. Note that the return value is the actual electrostatic potential, phi(r)$\equiv$Phi(r)/r, whereas the input is Rho(r)$\equiv$$4\pi$r$^2$n(r). Be sure to use ``interpolate'' to find the values on the odd grid points after you have done the Runge-Kutta integration, but before dividing Phi[k] by r[k] to get phi[k].

void getphi(double phi[], double Rho[], double r[], double dr[], int N)

Output:

Input:

Finally, because your input is now Rho[k]$\equiv$4*pi*r[k]*r[k]*rho[k] instead of just rho[k], you must modify derivs_Poisson() (be sure to include this in ``physics.c'' before getphi()!) so that it now contains a code fragment of the form

            .
            .
  dydx[1]=y[2]*dr[k];
  dydx[2]=-Rho[k]/r[k]*dr[k];
            .
            .



Subsections

Tomas Arias 2006-02-22