next up previous contents
Next: Solving Schrödinger's equation Up: No Title Previous: Packaging a new subroutine

Debugging ``schint''

To debug your Schrödinger integrator routine, write a main program which calls ``schint'' with k1=0, Psi=0, Psip=1, tex2html_wrap_inline152 and E=-0.5. To check that your routine is working have ``schint'' print out its solution for each k along with r[k]*exp(-r[k]), which is the exact 1s wave function. With N=100 points, your results should agree to about 4-5 decimal places (except for k>80).

Finally, once you are sure that schint it working, turn off the print statements!

Hint: Because tex2html_wrap_inline158 and r[0]=0, you may have numerical trouble at the origin. However, if you use the map tex2html_wrap_inline160 , then near the origin tex2html_wrap_inline162 , tex2html_wrap_inline164 and tex2html_wrap_inline166 . Thus, it is mathematically correct to regard the offending term tex2html_wrap_inline168 as zero at the origin. You can get the same effect in your code, but without the division by zero and the NaN's, by simply setting Veff[0]=0 when you initialize the array Veff[].



Tomas Arias
Wed Feb 16 12:12:49 EST 2000