next up previous contents
Next: ``broyden'' Up: Broyden Solver Previous: Debugging

Improved initial guess

The basis of the Broyden algorithm is linearization of the equations, which requires that we start not too far from the initial solution. Presently we begin with the very poor starting point Rho[k]=0. To improve upon this, we will start the Broyden solver with the density Rho after five iterations of our present charge-mixing algorithm. To accomplish this, add the following loop to ``test_it'' just before the main iteration loop (which starts with ``for (it=1; it<=Itmx; it++)''):

  for (it=1; it<=5; it++) {
    Etot=getg(g[1],Rho[1],Z,lmax,nmax,nmaxmax,F,r,dr,N);
    printf("Iter:%4d  Etot:%20.12f  Error:%20.12f\n",
           it,Etot,fabs(Etot-(-74.473076803203738)));

    for (k=0; k<=N; k++)
      Rho[1][k]=Rho[1][k]+alpha*g[1][k];
  }

Rerun your ``test_it'' to again verify that it produces the same output. At this stage, this is a trivial reorganization of the code, but it is important to ensure that everything is working before we implement the modified Broyden algorithm.



Tomas Arias
Mon Mar 25 16:15:06 EST 2002