Numerically Calculating the Infinite Potential Well?

13 visualizaciones (últimos 30 días)
Rachel
Rachel el 23 de Feb. de 2013
Editada: Torsten el 30 de Nov. de 2025
For my quantum mechanics class, we've been asked to write a program which find energy levels for potential energy wells of different shapes. I'm starting with a simple infinite potential well stretching from -10 to 10 angstroms and manually entering the energy just to debug the method we're expected to use, but I can't seem to get it to work. We're supposed to have the program loop through these three equations to find the value of the wavefunction: http://i45.tinypic.com/u9bvn.gif
My wavefunction should look like this when I put in the second energy level (0.376 eV), with it staying near zero for a while before the program goes too far into the infinite potential: http://i46.tinypic.com/2m2c9cw.gif
Instead, my wavefunction hits zero-ish and immediately skyrockets to infinity, which is supposed to show that the energy value is incorrect. http://i50.tinypic.com/jv6glt.gif
What is wrong with my code? Here is what I have:
%Symmetric_Well.m
%This program is an attempt to find the energy values for a wavefunction in
%a symmetric well which stretches from -10 to 10.
clear;
%Define variables
step = 0.1;
value = 1:101;
slope = 1:101;
curve = 1:101;
x = 1:101;
value(1) = 1;
slope(1) = 0;
beta = 0.26246;
%Zero the arrays
for j=1:101;
value(j)=0;
slope(j)=0;
curve(j)=0;
x(j)=0;
end
%Initial conditions
value(1) = 0;
slope(1)= 1;
x(1)=0.1;
%Receive guess from user
Energy = input('Please enter an energy value in electron volts.');
%Set up loop
for i=2:102;
x(i) = i*step;
k = i-1;
%Draw potential
if abs(x(i))<10, V=0;
else V=100000000000;
end
curve(i) = beta*(V-Energy)*value(k);
slope(i) = slope(k)+curve(k)*step;
value(i) = value(k)+slope(k)*step+(curve(k)*step^2)/2;
end
%Make a plot
plot(x, value);
axis([0 15 -5 5]);
xlabel('Distance in angstroms');
ylabel('Energy in electron volts');

Respuestas (1)

Kiran
Kiran el 29 de Nov. de 2025
Editada: Torsten el 30 de Nov. de 2025
%Symmetric_Well.m
%This program is an attempt to find the energy values for a wavefunction in
%a symmetric well which stretches from -10 to 10.
clear;
%Define variables
step = 0.1;
value = 1:101;
slope = 1:101;
curve = 1:101;
x = 1:101;
value(1) = 1;
slope(1) = 0;
beta = 0.26246;
%Zero the arrays
for j=1:101;
value(j)=0;
slope(j)=0;
curve(j)=0;
x(j)=0;
end
%Initial conditions
value(1) = 0;
slope(1)= 1;
x(1)=0.1;
%Receive guess from user
Energy = input('Please enter an energy value in electron volts.');
%Set up loop
for i=2:102;
x(i) = i*step;
k = i-1;
%Draw potential
if abs(x(i))<10, V=0;
else V=100000000000;
end
curve(i) = beta*(V-Energy)*value(k);
slope(i) = slope(k)+curve(k)*step;
value(i) = value(k)+slope(k)*step+(curve(k)*step^2)/2;
end
%Make a plot
plot(x, value);
axis([0 15 -5 5]);
xlabel('Distance in angstroms');
ylabel('Energy in electron volts');

Categorías

Más información sobre Quantum Mechanics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by