MATLAB_Quantum Well_Finite Difference Method

Click For Summary

Homework Help Overview

The discussion revolves around constructing a Hamiltonian matrix for the electron in a box problem using MATLAB, applying boundary conditions, and finding eigenvalues and eigenvectors. Participants are exploring the finite difference method in quantum mechanics.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning

Approaches and Questions Raised

  • The original poster attempts to understand how to set up the Hamiltonian matrix and apply boundary conditions. Some participants question how to implement the matrix setup in MATLAB, particularly regarding the use of loops to define different diagonals in the matrix.

Discussion Status

Participants are sharing insights on starting the problem and discussing the setup of the Hamiltonian matrix. Some guidance has been provided regarding the structure of the matrix and the use of MATLAB functions, though there is no explicit consensus on the best approach to coding the matrix with varying diagonals.

Contextual Notes

There is mention of specific constants and parameters such as t_0 and del_x, as well as the total number of lattice points, which may influence the setup of the Hamiltonian matrix. The original poster expresses uncertainty about the initial steps and coding techniques in MATLAB.

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: 455
  • HW_3(1).pdf
    HW_3(1).pdf
    84.1 KB · Views: 339
Physics news 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.
 

Similar threads

Replies
2
Views
1K
Replies
8
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K