void getEs(double E[],int nmax,double Elower,double V[], double r[],double dr[],int N)Output:
- E[n]: linear array of energies of states with n=0 nodes through n=nmax nodes (inclusive!)
Input:
- nmax: maximum number of nodes sought
- Elower: energy guaranteed to be lower than any valid solutions
- V[]: effective potential on grid
- r[], dr[], N: standard grid information
Write a routine of the above prototype in ``physics.c'' to return the energies of the electronic states with zero through nmax nodes in the potential V[] to a precision of TOL, which you should set at the top of ``physics.c'' with a statement like
The purpose of doing this is that you should never bury ``magic constants'' in your code, but rather define them in a single, centralized location where they are easily identified and changed.#define TOL (1.e-12)
Your routine should use rtbisp480() in conjunction with func_SchrodingerNodes() to first locate appropriate bounding energies, and then use zriddrp480 to find the solution to high precision.
A workable code fragment (but not the most efficient - you should try to do better) is
/* Loop to get states */
for (n=0; n<=nmax; n++) {
/* Get E1 as an energy with n nodes */
E1=rtbisp480(func_SchrodingerNodes,Elower,0.,TOL,n,V,r,dr,N);
/* Get E2 as an energy with n+1 nodes */
E2=rtbisp480(func_SchrodingerNodes,Elower,0.,TOL,n+1,V,r,dr,N);
/* Now, get the solution, which is in between! */
E[n]=zriddrp480(func_Schrodinger,E1,E2,TOL,0,V,r,dr,N);
}
Note: All solutions will have E<0, so using [Elower,0.] as the
bounds for the rtbisp480() searches is guaranteed to work!