Finish method and results, and add script for including all colormaps in one figure.

This commit is contained in:
Janita Willumsen 2023-12-31 18:49:06 +01:00
parent 36b91e5206
commit e9ad99210a
19 changed files with 180 additions and 41 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -122,14 +122,14 @@
\end{document}
% Abstract: OK
% Introduction:
% Methods: Wave packet, Heisenberg, Hyugen
% Results:
% Conclusion: OK
% Abstract: OK!
% Introduction: Hyugen, Heisenberg
% Methods: OK!
% Results: OK
% Conclusion: OK!
% Appendices:
% Results
% P7: OK
% P8:
% P9:
% P7: OK!
% P8: OK!
% P9: OK

View File

@ -46,7 +46,14 @@ As a result of working in position space, the Born rule is given by
p(x, y \ | \ t) &= |u(x, y, t)|^{2} = u^{*}(x, y, t) u(x, y, t) \ ,
\label{eq:born_rule_scaled}
\end{align}
where we assume a normalized wave function $u(x, y, t)$.
where we assume a normalized wave function $u(x, y, t)$. We will initialize the wave
function, using a Gaussian wavepacket, given by
\begin{align*}
u(x, y, t=0) &= e^{- \frac{(x-x_{c})^{2}}{2 \sigma_{x}^{2}} - \frac{(y-y_{c})^{2}}{2 \sigma_{y}^{2}} + ip_{x}x + ip_{y}y} \ .
\end{align*}
$x_{c}$ and $y_{c}$ are the coordinates of the center of the wavepacket, $\sigma_{x}$
and $\sigma_{y}$ are the width of the wavepacket. The wave packet momenta are
given by $p_{x}$ and $p_{y}$.
\subsection{The Crank-Nicolson scheme}\label{ssec:crank_nicolson} %
@ -101,9 +108,10 @@ of Thomas Young's setup can be found in Figure \ref{fig:youngs_double_slit}.
After the wave passes through the barrier, the pattern observed is determined by
the path difference given by
\begin{align*}
\begin{align}
\delta = d \sin (\theta) = m \lambda \ ,
\end{align*}
\label{eq:interference}
\end{align}
where $\lambda$ is the wavelength and $m$ is called the order number. $d$ is the
distance between the center of the two slits, while assuming that the distance between
the wall and the detector screen $L >> \delta$ \cite[p. 6]{mit:2004:physics}. In
@ -216,13 +224,6 @@ An example of filled matrices can be found in Appendix \ref{ap:matrix_structure}
For the general setup of the barrier, we used the values in Table \ref{tab:barrier_setup},
and for the simulations, we used the parameter settings in Table \ref{tab:sim_settings}.
In addition, we initialized the wave function using a Gaussian wavepacket, given by
\begin{align*}
u(x, y, t=0) &= e^{- \frac{(x-x_{c})^{2}}{2 \sigma_{x}^{2}} - \frac{(y-y_{c})^{2}}{2 \sigma_{y}^{2}} + ip_{x}x + ip_{y}y} \ .
\end{align*}
$x_{c}$ and $y_{c}$ are the coordinates of the center of the wavepacket, $\sigma_{x}$
and $\sigma_{y}$ are the width of the wavepacket, when it is initialized. The wave
packet momenta are given by $p_{x}$ and $p_{y}$.
% Insert Heisenberg uncertainty here? Or refer to it?
\begin{table}[H]
\centering

View File

@ -20,24 +20,28 @@ from $1.0$.
\caption{Deviation of total probability, for time $t \in [0, T]$ where $T=0.008$.}
\label{fig:deviation}
\end{figure}
In Figure \ref{fig:deviation}, we observe a larger deviation of total probability
for a barrier with double slits compared to no barrier. Interaction with the
barrier result in a change ... of values, as the light passes through,
The result is more prone to computational errors. Using no barrier, the light is not
affected by obstacles resulting in a more stable deviation from the total probability.
We simulated the wave equation with the barrier switched off, using setting 1 in
Table \ref{tab:sim_settings} found in Section \ref{ssec:implementation}. When the
barrier was switched on, we used setting 2 in \ref{tab:sim_settings}. We observed
a larger deviation of total probability for a barrier with double slits compared
to no barrier, the result is showed in Figure \ref{fig:deviation}. The wave interacts
with the barrier resulting in a change in kinetic energy. The result is more prone
to computational errors, than if the wave propagates without interacting with a
barrier. No interaction results in a more stable deviation from the total probability.
In addition, we have to consider the limitation of a computer, some computational
error is to be expected.
\subsection{Time evolution}\label{ssec:time_evolution}
% Problem 8: Colormap, include plot of both Re and Im for different time steps
% Account for color scale
We ran the simulation using the values in column 2 of Table \ref{tab:sim_setup}, found
in Section \ref{ssec:implementation}. To study the time evolution of the probability
function, we created colormap plots for different time steps. Figure \ref{fig:colormap_0_prob},
We studied the time evolution of the probability function, using setting 2 in
Table \ref{tab:sim_settings}, found in Section \ref{ssec:implementation}. To visualize
the time evolution, we created colormap plots for different time steps. Figure \ref{fig:colormap_0_prob},
Figure \ref{fig:colormap_1_prob}, and Figure \ref{fig:colormap_2_prob} show the
result for time steps $t=[0, 0.001, 0.002]$, respectively. In addition, we created
results for time steps $t=[0, 0.001, 0.002]$, respectively. In addition, we created
separate plots for the real and imaginary part of $u_{\ivec, \jvec}$, for the same
time steps. The result can be found in Appendix \ref{ap:figures}, in Figure \ref{fig:colormap}.
time steps. The results can be found in Appendix \ref{ap:figures}, in Figure \ref{fig:colormap}.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{images/color_map_0_prob.pdf}
@ -56,17 +60,30 @@ time steps. The result can be found in Appendix \ref{ap:figures}, in Figure \ref
\caption{The probability function $p_{\ivec, \jvec}^{n}$, at time $t=0.002$.}
\label{fig:colormap_2_prob}
\end{figure}
In Figure \ref{fig:colormap_1_prob}, the ... interacts with the double
slitted barrier, which result in a wavelike pattern. However, the waves are more
visible when we observe the real and imaginary part separately in Figure \ref{fig:colormap}.
At time step $t=0.001$, Figure \ref{fig:colormap_1_prob}, when the wave interacts
with the double slit barrier, we observe a clear diffraction pattern in the
probability function. At time step $t=0$ (Figure \ref{fig:colormap_0_prob}) and
$t=0.002$ (Figure \ref{fig:colormap_2_prob}), the diffraction pattern is not as
clear. It is, however, more visible when we observe the real and imaginary part
separately in Figure \ref{fig:colormap}, found in Appendix \ref{ap:figures}. Since
the probability function is a product of $u_{\ivec, \jvec}$ and its conjugate $u_{\ivec, \jvec}^{*}$,
initialized by a Gaussian wavepacket, the result is a sum of the real and imaginary part.
% This can be found using Euler's formula, and the diffraction pattern is determined by interference given by \eqref{eq:interference}
In Figure \ref{fig:colormap_2_prob}, the probability function result in positive
areas at both sides of the barries. Some of the probability function is reflected
by the barrier, while the the rest spread out after passing the barrier. This is
a consequence of the wave-particle duality.
\subsection{Particle detection}\label{ssec:particle_detection}
% Problem 9: Plot detection probability for single-, double- and triple-slit
We used the simulation from the previous section, assumed a detector screen
located at $x=0.8$, and plotted the detection probability along the screen at time
$t=0.002$. We adjusted the parameters to include single-, double-, and triple-slitted
barrier. The results is found in Figure \ref{}, Figure \ref{}, and Figure \ref{fig:}.
We simulation the wave equation using setting 2 in Table \ref{tab:sim_settings},
and assumed a detector screen located at $x=0.8$. To visualize the pattern of constructive
and destructive interference, we plotted the probability of particle detection,
along the screen, at time $t=0.002$. We adjusted the parameters to include single-, double-, and triple-slit
barriers. The results is found in Figure \ref{fig:particle_detection_single},
Figure \ref{fig:particle_detection_double}, and Figure \ref{fig:particle_detection_triple},
respectively.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{images/single_slit_detector.pdf}
@ -88,5 +105,10 @@ barrier. The results is found in Figure \ref{}, Figure \ref{}, and Figure \ref{f
when using a triple-slit barrier.}
\label{fig:particle_detection_triple}
\end{figure}
When the barrier has a single slit, there is no destructive interference and we
observe a single peak in the probability of particle detection. Adding another slit
result in more peaks, as there are both constructive and destructive interference.
When we use a triple-slit barrier, we observe an increase in interference which
result in narrow peaks. In addition, the probability of detecting a particle at
the ends of the screen increase with number of slits.
\end{document}

View File

@ -19,6 +19,7 @@ plt.rcParams.update(params)
def plot():
ticks = [0, 0.25, 0.5, 0.75, 1.0]
with open("data/color_map.txt") as f:
lines = f.readlines()
size = int(lines[0])
@ -38,16 +39,19 @@ def plot():
np.multiply(arr, arr.conj()).real,
interpolation="nearest",
cmap=sns.color_palette("mako", as_cmap=True),
extent=[0, 1.0, 0, 1.0]
)
color_map2 = ax2.imshow(
arr.real,
interpolation="nearest",
cmap=sns.color_palette("mako", as_cmap=True),
extent=[0, 1.0, 0, 1.0]
)
color_map3 = ax3.imshow(
arr.imag,
interpolation="nearest",
cmap=sns.color_palette("mako", as_cmap=True),
extent=[0, 1.0, 0, 1.0]
)
# Create color bar
@ -60,10 +64,26 @@ def plot():
ax2.grid(False)
ax3.grid(False)
# Set custom ticks
ax1.set_xticks(ticks)
ax1.set_yticks(ticks)
ax2.set_xticks(ticks)
ax2.set_yticks(ticks)
ax3.set_xticks(ticks)
ax3.set_yticks(ticks)
# Set labels
ax1.set_xlabel("x-axis")
ax1.set_ylabel("y-axis")
ax2.set_xlabel("x-axis")
ax2.set_ylabel("y-axis")
ax3.set_xlabel("x-axis")
ax3.set_ylabel("y-axis")
# Save the figures
fig1.savefig(f"latex/images/color_map_{i}_prob.pdf")
fig2.savefig(f"latex/images/color_map_{i}_real.pdf")
fig3.savefig(f"latex/images/color_map_{i}_imag.pdf")
fig1.savefig(f"latex/images/color_map_{i}_prob.pdf", bbox_inches="tight")
fig2.savefig(f"latex/images/color_map_{i}_real.pdf", bbox_inches="tight")
fig3.savefig(f"latex/images/color_map_{i}_imag.pdf", bbox_inches="tight")
# Close figures
plt.close(fig1)

View File

@ -0,0 +1,93 @@
import ast
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set_theme()
params = {
"font.family": "Serif",
"font.serif": "Roman",
"text.usetex": True,
"axes.titlesize": "large",
"axes.labelsize": "large",
"xtick.labelsize": "large",
"ytick.labelsize": "large",
"legend.fontsize": "medium",
}
plt.rcParams.update(params)
def plot():
fig, axes = plt.subplots(nrows=3, ncols=3)
with open("data/color_map.txt") as f:
lines = f.readlines()
size = int(lines[0])
for i, line in enumerate(lines[1:]):
# Create figures for each plot
# fig1, ax1 = plt.subplots()
# fig2, ax2 = plt.subplots()
# fig3, ax3 = plt.subplots()
arr = line.strip().split("\t")
arr = np.asarray(list(map(lambda x: complex(*ast.literal_eval(x)), arr)))
# Reshape and transpose array
arr = arr.reshape(size, size).T
# Plot color maps
color_map1 = axes[i,0].imshow(
np.multiply(arr, arr.conj()).real,
interpolation="nearest",
cmap=sns.color_palette("mako", as_cmap=True)
)
color_map2 = axes[i,1].imshow(
arr.real,
interpolation="nearest",
cmap=sns.color_palette("mako", as_cmap=True)
)
color_map3 = axes[i,2].imshow(
arr.imag,
interpolation="nearest",
cmap=sns.color_palette("mako", as_cmap=True)
)
# Create color bar
fig.colorbar(color_map1, ax=axes)
# fig2.colorbar(color_map2, ax=ax2)
# fig3.colorbar(color_map3, ax=ax3)
# # Remove grids
axes.grid(False)
# ax2.grid(False)
# ax3.grid(False)
# # Set custom ticks
# ax1.set_xticks(ticks)
# ax1.set_yticks(ticks)
# ax2.set_xticks(ticks)
# ax2.set_yticks(ticks)
# ax3.set_xticks(ticks)
# ax3.set_yticks(ticks)
# # Set labels
# ax1.set_xlabel("x-axis")
# ax1.set_ylabel("y-axis")
# ax2.set_xlabel("x-axis")
# ax2.set_ylabel("y-axis")
# ax3.set_xlabel("x-axis")
# ax3.set_ylabel("y-axis")
# # Save the figures
fig.savefig(f"latex/images/color_map_all.pdf", bbox_inches="tight")
# fig2.savefig(f"latex/images/color_map_{i}_real.pdf", bbox_inches="tight")
# fig3.savefig(f"latex/images/color_map_{i}_imag.pdf", bbox_inches="tight")
# # Close figures
# plt.close(fig1)
# plt.close(fig2)
# plt.close(fig3)
if __name__ == "__main__":
plot()

View File

@ -27,6 +27,7 @@ def plot():
"latex/images/double_slit_detector.pdf",
"latex/images/triple_slit_detector.pdf",
]
colors = sns.color_palette("mako", n_colors=2)
for file, output in zip(files, outputs):
with open(file) as f:
lines = f.readlines();
@ -43,8 +44,10 @@ def plot():
slice *= norm
slice = np.asarray([i * i.conjugate() for i in slice])
ax.plot(x, slice)
plt.savefig(output)
ax.plot(x, slice, color=colors[0])
ax.set_xlabel("Detector screen (y-axis)")
ax.set_ylabel("Detection probability")
fig.savefig(output, bbox_inches="tight")
plt.close(fig)