Place the following code block at the end of your ``sch.m'' and run.
(Note: if you wish to regain control before all of the
iterations are complete, you have the option of hitting Ctrl-C once
(and then
enter
if there is no immediate response. Be patient:
if you hit Ctrl-C more than once, octave will likely crash,
destroying your octave session and creating a large octave-core file.)
The code block below starts from random functions, performs a finite
difference test, orthonormalizes the starting functions, runs 400
iterations of your sd(), and computes the final results with your
getPsi(). Finally, the code displays the energy of each state along
with grey-scale density plots of the values of
on
planes cutting through the center of your cell. For the graphics to
function, be sure to copy ``smooth.m'' and ``ppm.m'' from
Appendices C and D into your octave
directory.
%# Allow for more digits in printouts
format long
%# Converge using steepest descents
W=sd(W,400);
%# Extract and display final results
[Psi, epsilon]=getPsi(W);
for st=1:Ns
printf('=== State # %d, Energy = %f ===\n',st,epsilon(st));
dat=abs(cI(Psi(:,st))).^2;
for k=1:3
sl=slice(dat,S,S(k)/2,k);
name=sprintf("psi%d_m%d.ppm",st,k);
ppm(name,sl*0.3,sl,sl); system(["display " name "&"]);
end
end
For your reference, with an angular frequency of the oscillator of