MATLAB_Quantum Well_Finite Difference Method

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
csc
Messages
2
Reaction score
0

Homework Statement


Hi,
I am new to MATLAB and have an assignment where I have to construct a Hamiltonian matrix, apply boundary conditions, then find corresponding eigenvalues and eigenvectors for the electron in a box problem. I am stumped where to start. From our class we learned that you will get to the equation
-h_bar^2/2m[psi_(i+1)-2psi_(i)-psi_(i-1)] by using the definition of a derivative and can use the boundary conditions to manipulate this equation to give you the coefficients to use in the hamiltonian matrix, however, it does not seem like we need this because it will be applied when we set the limits for the Hamiltonian. Any advice on a good start would be greatly appreciated.
Attached is the pdf of the problem.

Homework Equations


HΨ=EΨ

The Attempt at a Solution


I was suggested by my professor to start here:

In your code, you have to create an empty matrix that you will use as a Hamiltonian (let’s call H), and then assign the elements. For example, in MATLAB, you can do something like below.

H(1,1) = -2*t_0;
H(1,2) = t_0;
H(1,3) = 0;
H(1,4) = 0;

I believe you know what t_0 is. Since we don’t want to do all this manually one by one, you can use “for” or “while” syntax to define H more easily. Once you fill up H correctly (remember, when you do this, you would have already applied the boundary condition. Review how different boundary conditions have resulted in different Hamiltonian), you simply perform eig function. To do this, you will need to create two empty matrixes that will contain the calculated eigen vectors and eigen values. In your previous email, you said you learned how to use [V, D] = eig (H). So, for example, V will contain the eigen vectors (eigen functions) and D will contain the eigen values after you execute the line in your code.

You know that you have to define many “constants” in your code. t_0 contains del_x which is the lattice spacing (I think I used del_x in my lecture instead of a, but here I mean del_x by a. N is the number of total lattice points (=100). So the situation is something like this. (see attached picture)
 

Attachments

  • PastedGraphic-1.jpg
    PastedGraphic-1.jpg
    17.1 KB · Views: 466
  • HW_3(1).pdf
    HW_3(1).pdf
    84.1 KB · Views: 353
on Phys.org
Your teacher has given a very nice and quite detailed procedure on how to start the problem. There is not much more to add.
 
DrClaude said:
Your teacher has given a very nice and quite detailed procedure on how to start the problem. There is not much more to add.
How do I do a for loop in MATLAB in order to make the k0 diagonal -2, k-1 diagonal 1, and k+1 diagonal 1? I understand the physics behind it just not how to code a matrix that has different diagonals. The "diag" function only gives you the option of changing one diagonal like if instance diag(-2) makes the k0 diagonal "-2" and diag(1,1) makes the k1 diagonal "1".
 
There is a repeating pattern. Consider an NxN matrix: looping over i from 1 to N allows you to set the values of the matrix row by row.