MATLAB_Quantum Well_Finite Difference Method

AI Thread Summary
The discussion focuses on constructing a Hamiltonian matrix in MATLAB for the electron in a box problem, emphasizing the importance of applying boundary conditions and understanding the finite difference method. Users are guided to create an empty Hamiltonian matrix and fill it using loops to automate the process, particularly for setting specific diagonal values. The eig function is highlighted as a means to obtain eigenvalues and eigenvectors after constructing the Hamiltonian. Participants seek clarification on coding techniques, specifically how to set different diagonals in a matrix efficiently. Overall, the thread provides practical advice for beginners tackling this quantum mechanics assignment 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: 433
  • HW_3(1).pdf
    HW_3(1).pdf
    84.1 KB · Views: 315
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.
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...
Back
Top