780.20: 1094 Session 5

Handouts: New: eigen_basis.cpp printout, harmonic_oscillator.cpp printout, nan_test.cpp printout, and square_well.nb Mathematica notebook.
From session 4: eigen_test.cpp printout and GSL Eigensystems documentation.

Your goals for this session:

Please work in pairs (more or less). The instructors will bounce around 1094 and answer questions.

Leftover Tasks from Session 4

Work on these at most for the first 30 minutes of the period.

  1. Numerical Derivatives and Richardson Extrapolation. The most important thing is to generate and understand the error plot.
  2. Pointer Games. The important part of this exercise is not understanding pointers in detail but to successfully modify a code based on an example.
  3. Linear Algebra with GSL Routines. You'll see the same things in Session 5. If you are running out of time, just go through the discussion in the Session 5 notes.

Nan's and Inf's

Just a quickie: Take a look at nan_test.cpp, use make_nan_test to create nan_test and then run it.

Bound States from Diagonalizing the Hamiltonian

The program in eigen_basis.cpp uses the GSL library routines you explored in eigen_test.cpp (session 4) to diagonalize a Hamiltonian matrix in a basis of harmonic oscillator wave functions. You may want to refer to the GSL handout on eigensystems (there is also a printout of eigen_basis.cpp).

The eigen_basis program uses units in which the particle mass is 1 and hbar=1. The program asks you to choose

The parameters of the potentials are fixed in the code. The eigenvalues for the Hamiltonian matrix are written to the terminal sorted in numerical order (as opposed to absolute-value sorting, which was used in eigen_test.cpp). The corresponding eigenvectors are generated but are not printed out (that is, the print statements are commented out).

The Coulomb potential is defined with Ze2=1, which means that the Bohr radius is also unity. This means that the bound energy levels are given by En = -1/2n2, with n=1,2,...
The square well potential is defined with radius R=1 and depth V0 = 50. You should find that there are three bound states.

Here are some subgoals. There won't be time for everything (as usual) but you'll have a chance to finish them as part of a future assignment.

  1. Run the Mathematica notebook square_well.nb (make sure you understand what it is doing; e.g, look up FindRoot in the Help Browser). Find the bound-state energies for the square well parameters used here (you need to change the notebook parameters!).

  2. Compile and link the code eigen_basis using make_eigen_basis. This also compiles harmonic_oscillator.cpp. Run it a few times with each of the potentials to get familiar with it. If you try too large a basis size, the run time may be too long (so start small!). Look through the printout to see the basic idea of how the code works and find where the equation for the matrix element is implemented.
  3. Based on the "exact" results from Mathematica, which predicted eigenvalue(s) do you think are most reliable? Which eigenvalues are calculated most effectively, those of the Coulomb potential or the square well potential? Why do you think this is?

  4. You have under your control the size of the basis (i.e., the dimension of the matrix) and the harmonic oscillator parameter b (see harmonic_oscillator.cpp for the definition). For a fixed basis size (pick one that reproduces the ground state reasonably), how do you find the optimum b? (Hint: think gnuplot!) Can you qualitatively (or semi-quantitatively) account for your result? (Think about the potentials and guess what the lowest wave functions will look like and what changes about the basis when the harmonic oscillator parameter b is changed.)

  5. If you now fix b (if you have time you can consider two or three different values in turn), how can you find how the accuracy of the ground state energy scales with the basis size? Make an appropriate plot.

  6. Look at the code. How could you make it more efficient? (What do you think is the limiting factor based on the scaling of the time with the size of the basis?) For example, could you speed it up by almost a factor of two? (Hint, hint!)

  7. How would you find the wave function that corresponds to a given state (e.g., the ground state)? Add code to generate the lowest wave function for the lowest bound state (hint: it involves the eigenvector).

780.20: 1094 Session 5. Last modified: 10:00 am, January 22, 2006.