780.20: 2082 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:
- See some examples of nan's and inf's.
- Find the lowest bound-state eigenvalues of two
familiar potentials using the eigen_basis program.
- Examine (and try to understand)
how the accuracy of your results depends
on the size of the harmonic oscillator basis and the choice of the
basis parameter b.
Please work in pairs (more or less).
Dick and Daniel will bounce around 2082 and answer questions.
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.
- What do you think the result of 0.*(1./0.) will be? Predict
and then modify the code to check it out.
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
You may want to refer to the GSL handout on eigensystems.
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).
- a potential (Coulomb or square well);
- the parameter b for the harmonic oscillator basis
(see harmonic_oscillator.c for the definition);
- the number of basis states to use.
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
- 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.
- Compile and link the code eigen_basis using make_eigen_basis. This also
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.
- 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?
- 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
- 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.
- 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!)
- 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: 2082 Session 5.
Last modified: 08:07 pm, January 23, 2005.