Code PDF
Code PDF
Code PDF
t_steps=21;
figure;
for j=1:t_steps
subplot(3,7,j);
% Plotting
plot(x,abs(propagated_psi(:,j)).^2,'linewidth',2); grid on; ylim([0 6e-3]);
title(['t = ' num2str(ts(j)/Delta_t) '\Delta t']);
end
% For the 2nd method: define the X and X^2 operator matrix:
Xmat=x.*eye(length(x));
Xsqmat=x.^2.*eye(length(x));
for j=1:t_steps2
% Propagating psi by operating on it with the propagation matrix
propagated_psi(:,j)=propagation(ts2(j))*psi_init;
mean_xsq(j)=trapz(x.^2.*abs(propagated_psi(:,j))'.^2);
mean_xsq2(j)=propagated_psi(:,j)'*Xsqmat*propagated_psi(:,j);
sigma(j)=sqrt(mean_xsq(j)-mean_x(j)^2);
end
figure; plot(ts2/Delta_t,mean_x,'linewidth',1.5);
xlabel('t/\Delta t'); ylabel('<x>'); grid on;
figure; plot(ts2/Delta_t,mean_xsq,'linewidth',1.5);
xlabel('t/\Delta t'); ylabel('<x^2>'); grid on; ylim([0 25]);
figure; plot(ts2/Delta_t,sigma,'linewidth',1.5);
xlabel('t/\Delta t'); ylabel('\sigma_X'); grid on;
figure; plot(ts2/Delta_t,mean_H,'linewidth',1.5);
xlabel('t/\Delta t'); ylabel('<H>'); grid on; ylim([0 0.3]);
for i=1:length(Bump_height)
end