Numerically Calculating the Infinite Potential Well?
16 ビュー (過去 30 日間)
古いコメントを表示
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');
0 件のコメント
回答 (1 件)
Kiran
2025 年 11 月 29 日 15:10
編集済み: Torsten
2025 年 11 月 30 日 13:26
%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');
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!