diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1e7d4f7..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -. !text !filter !merge !diff diff --git a/.gitignore b/.gitignore index 2b0582e..90f5ec8 100644 --- a/.gitignore +++ b/.gitignore @@ -50,5 +50,3 @@ test # Score-p scorep* - -data/animation.txt diff --git a/latex/images/color_map_0_imag.pdf b/latex/images/color_map_0_imag.pdf index fbb00d0..940c97f 100644 Binary files a/latex/images/color_map_0_imag.pdf and b/latex/images/color_map_0_imag.pdf differ diff --git a/latex/images/color_map_0_prob.pdf b/latex/images/color_map_0_prob.pdf index 3662be2..3d0e837 100644 Binary files a/latex/images/color_map_0_prob.pdf and b/latex/images/color_map_0_prob.pdf differ diff --git a/latex/images/color_map_0_real.pdf b/latex/images/color_map_0_real.pdf index a76cfa6..ded6a22 100644 Binary files a/latex/images/color_map_0_real.pdf and b/latex/images/color_map_0_real.pdf differ diff --git a/latex/images/color_map_1_imag.pdf b/latex/images/color_map_1_imag.pdf index ff699f1..64a8bba 100644 Binary files a/latex/images/color_map_1_imag.pdf and b/latex/images/color_map_1_imag.pdf differ diff --git a/latex/images/color_map_1_prob.pdf b/latex/images/color_map_1_prob.pdf index 510d6df..5d031a6 100644 Binary files a/latex/images/color_map_1_prob.pdf and b/latex/images/color_map_1_prob.pdf differ diff --git a/latex/images/color_map_1_real.pdf b/latex/images/color_map_1_real.pdf index 8aa7e60..a051a33 100644 Binary files a/latex/images/color_map_1_real.pdf and b/latex/images/color_map_1_real.pdf differ diff --git a/latex/images/color_map_2_imag.pdf b/latex/images/color_map_2_imag.pdf index e2e5c3e..8417f3b 100644 Binary files a/latex/images/color_map_2_imag.pdf and b/latex/images/color_map_2_imag.pdf differ diff --git a/latex/images/color_map_2_prob.pdf b/latex/images/color_map_2_prob.pdf index 26a0939..88b5f90 100644 Binary files a/latex/images/color_map_2_prob.pdf and b/latex/images/color_map_2_prob.pdf differ diff --git a/latex/images/color_map_2_real.pdf b/latex/images/color_map_2_real.pdf index a198574..9f9b9e6 100644 Binary files a/latex/images/color_map_2_real.pdf and b/latex/images/color_map_2_real.pdf differ diff --git a/latex/images/color_map_all.pdf b/latex/images/color_map_all.pdf deleted file mode 100644 index 0bdd066..0000000 Binary files a/latex/images/color_map_all.pdf and /dev/null differ diff --git a/latex/images/double_slit_detector.pdf b/latex/images/double_slit_detector.pdf index abdcb86..1726800 100644 Binary files a/latex/images/double_slit_detector.pdf and b/latex/images/double_slit_detector.pdf differ diff --git a/latex/images/probability_deviation.pdf b/latex/images/probability_deviation.pdf index 22bff88..d8baea3 100644 Binary files a/latex/images/probability_deviation.pdf and b/latex/images/probability_deviation.pdf differ diff --git a/latex/images/single_slit_detector.pdf b/latex/images/single_slit_detector.pdf index 7bfcf3b..fbdbb97 100644 Binary files a/latex/images/single_slit_detector.pdf and b/latex/images/single_slit_detector.pdf differ diff --git a/latex/images/triple_slit_detector.pdf b/latex/images/triple_slit_detector.pdf index 48c9813..f66949b 100644 Binary files a/latex/images/triple_slit_detector.pdf and b/latex/images/triple_slit_detector.pdf differ diff --git a/latex/references.bib b/latex/references.bib index 572bc39..e7380fa 100644 --- a/latex/references.bib +++ b/latex/references.bib @@ -187,29 +187,6 @@ pages = {3021} } -@article{harris:2020:numpy, - title = {Array programming with {NumPy}}, - author = {Charles R. Harris and K. Jarrod Millman and St{\'{e}}fan J. - van der Walt and Ralf Gommers and Pauli Virtanen and David - Cournapeau and Eric Wieser and Julian Taylor and Sebastian - Berg and Nathaniel J. Smith and Robert Kern and Matti Picus - and Stephan Hoyer and Marten H. van Kerkwijk and Matthew - Brett and Allan Haldane and Jaime Fern{\'{a}}ndez del - R{\'{i}}o and Mark Wiebe and Pearu Peterson and Pierre - G{\'{e}}rard-Marchant and Kevin Sheppard and Tyler Reddy and - Warren Weckesser and Hameer Abbasi and Christoph Gohlke and - Travis E. Oliphant}, - year = {2020}, - month = sep, - journal = {Nature}, - volume = {585}, - number = {7825}, - pages = {357--362}, - doi = {10.1038/s41586-020-2649-2}, - publisher = {Springer Science and Business Media {LLC}}, - url = {https://doi.org/10.1038/s41586-020-2649-2} -} - # C++ libraries @misc{openmp:2018, author = {OpenMP}, diff --git a/latex/schrodinger_simulation.tex b/latex/schrodinger_simulation.tex index aaba4ad..1ace563 100644 --- a/latex/schrodinger_simulation.tex +++ b/latex/schrodinger_simulation.tex @@ -82,8 +82,8 @@ \begin{document} -\title{Simulating the Schrödinger wave equation using the Crank-Nicolson scheme in 2+1 dimensions} % self-explanatory -\author{Cory Alexander Balaton \& Janita Ovidie Sandtrøen Willumsen \\ \faGithub \, \url{https://gitea.balaton.dev/FYS3150/Project-5}} % self-explanatory +\title{Simulating the Schrödinger wave equation using the Crank-Nicolson method in 2+1 dimensions} % self-explanatory +\author{Cory Alexander Balaton \& Janita Ovidie Sandtrøen Willumsen \\ \faGithub \, \url{https://github.uio.no/FYS3150-G2-2023/Project-4}} % self-explanatory \date{\today} % self-explanatory \noaffiliation % ignore this, but keep it. @@ -102,7 +102,7 @@ \subfile{sections/results} % Conclusion -\subfile{sections/conclusion} +% \subfile{sections/conclusion} % Notes % \subfile{draft} @@ -122,14 +122,12 @@ \end{document} -% Abstract: OK! -% Introduction: Hyugen, Heisenberg -% Methods: OK! -% Results: OK -% Conclusion: OK! -% Appendices: +% Methods +% P1: Theory, imag i = i, index i, j = \hat{i}, \hat{j} +% P2: +% % Results -% P7: OK! -% P8: OK! -% P9: OK +% P7: +% P8: +% P9: diff --git a/latex/sections/abstract.tex b/latex/sections/abstract.tex index e0d384c..dc3225b 100644 --- a/latex/sections/abstract.tex +++ b/latex/sections/abstract.tex @@ -3,18 +3,16 @@ \begin{document} \begin{abstract} We have simulated the two-dimensional time-dependent Schrödinger equation, to study -variations of the double-slit experiment. To derive a discretized equation -we applied the Crank-Nicolson scheme in 2+1 dimensions. In addition, we have used -Dirichlet boundary conditions to express the equation in matrix form, and solve -it using the sparse matrix solver \verb|superlu|. Our implementation, and choice -of solver method, resulted in a deviation from conserved total probability on the -scale $10^{-14}$, for both the single and double slit setup. To illustrate the time -evolution of the probability function, we created colormap plots for time steps -$t=\{0, 0.001, 0.002\}$. We also included separate plots for each time step of -Re$(u_{\ivec, \jvec})$ and Im$(u_{\ivec, \jvec})$. In addition, we determined the -normalized particle detection probability $p(y \ | \ x=0.8, t=0.002)$, for single-, -double- and triple-slit. +variations of the double-slit experiment. To solve the partial differential equations +we have applied the Crank-Nicolson scheme in 2+1 dimensions, to derive a discretized +equation. In addition, we have used Dirichlet boundary conditions to express the +equation in matrix form and solve it using the sparse matrix solver \verb|superlu|. +Our implementation, and choice of solver method, resulted in conserved total +probability $\sum_{\ivec, \jvec} p_{\ivec, \jvec}^{n}=1$ for both the single and +double slit setup. To illustrate the time evolution of the probability function, +we created colormap plots at time steps $t = [0, 0.001, 0.002]$. We also included +separate plots for each time step of Re$(u_{\ivec, \jvec})$ and Im$(u_{\ivec, \jvec})$. +In addition, we determined the normalized particle detection probability $p(y \ | \ x=0.8, t=0.002)$, +for single-, double- and triple-slit. \end{abstract} \end{document} - -% $| \sum_{\ivec, \jvec} p_{\ivec, \jvec}^{n} - 1 | \approx $ \ No newline at end of file diff --git a/latex/sections/appendices.tex b/latex/sections/appendices.tex index b4adfe2..ef9a514 100644 --- a/latex/sections/appendices.tex +++ b/latex/sections/appendices.tex @@ -3,8 +3,7 @@ \begin{document} \appendix \section{The Crank-Nicholson method}\label{ap:crank_nicolson} -The Crank-Nicolson (CN) approach consider both the forward difference, an explicit -scheme, +The Crank-Nicolson (CN) approach consider both the forward difference, an explicit scheme, \begin{equation*} \frac{u_{\ivec, \jvec}^{n+1} - u_{\ivec, \jvec}^{n}}{\Delta t} = F_{\ivec, \jvec}^{n} \ , \end{equation*} @@ -21,17 +20,15 @@ The parameter $\theta$ is introduced for a general approach, however, for CN $\t \frac{u_{\ivec, \jvec}^{n+1} - u_{\ivec, \jvec}^{n}}{\Delta t} &= \frac{1}{2} \bigg[ F_{\ivec, \jvec}^{n+1} + F_{\ivec, \jvec}^{n} \bigg] \\ \end{align*} -We need the first derivative in respect to both time and position, as well as the -second derivative in respect to position. Taylor expanding will result in a discretized -version. +We need the first derivative in respect to both time and position, as well as the second derivative in respect to position. Taylor expanding will result in a discretized version, assume this is known... -The Schrödinger equation contains $i$ on the left hand side, we rewrite it as +Schrödinger contain $i$ at the lhs, factor it as \begin{align*} \frac{u_{\ivec, \jvec}^{n+1} - u_{\ivec, \jvec}^{n}}{\Delta t} &= \frac{1}{2i} \bigg[ F_{\ivec, \jvec}^{n+1} + F_{\ivec, \jvec}^{n} \bigg] \\ - &= -\frac{i}{2} \bigg[ F_{\ivec, \jvec}^{n+1} + F_{\ivec, \jvec}^{n} \bigg] \ , + &= -\frac{i}{2} \bigg[ F_{\ivec, \jvec}^{n+1} + F_{\ivec, \jvec}^{n} \bigg] & \text{, where $\frac{1}{i} = -i$} \end{align*} -where $1/i = -i$. Using Equation \eqref{eq:schrodinger_dimensionless}, which is -found in Section \ref{ssec:schrodinger}, we get + +Using Equation \eqref{eq:schrodinger_dimensionless}, we get \begin{align*} u_{\ivec, \jvec}^{n+1} - u_{\ivec, \jvec}^{n} & -\frac{i \Delta t}{2} \bigg[ F_{\ivec, \jvec}^{n+1} + F_{\ivec, \jvec}^{n} \bigg] \\ &= -\frac{i \Delta t}{2} \bigg[ - \frac{u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1}}{2 \Delta x^{2}} \\ @@ -47,7 +44,8 @@ the left hand side, and the terms containing $n$ time step on the right hand sid &= u_{\ivec, \jvec}^{n} + \frac{i \Delta t}{2 \Delta x^{2}} \big[ u_{\ivec+1, \jvec}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec-1, \jvec}^{n} \big] \\ & \quad + \frac{i \Delta t}{2 \Delta y^{2}} \big[ u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n} \big] - \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n} \end{align*} -Since we use an equal step size $h$ in both $x$ and $y$ direction, we can use +In addition, since we will use an equal step size $h$ in both $x$ and $y$ direction, +we can use \begin{align*} \frac{i \Delta t}{2 \Delta h^{2}} = \frac{i \Delta t}{2 \Delta x^{2}} = \frac{i \Delta t}{2 \Delta y^{2}} \ , \end{align*} @@ -55,7 +53,7 @@ and define \begin{align*} r \equiv \frac{i \Delta t}{2 \Delta h^{2}} \end{align*} -Now, the discretized Schrödinger equation can be rewritten as +Now, the discretized Schrödinger equation can be written as \begin{align*} & u_{\ivec, \jvec}^{n+1} - r \big[ u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1} \big] \\ & - r \big[ u_{\ivec, \jvec+1}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec, \jvec-1}^{n+1} \big] + \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n+1} \\ @@ -65,7 +63,7 @@ Now, the discretized Schrödinger equation can be rewritten as \section{Matrix structure}\label{ap:matrix_structure} -For a $u$ vector of length $(M-2) = 3$, the matrices $A$ and $B$ have size +For $u$ vector of length $(M-2) = 3$, the matrices $A$ and $B$ have size $(M-2)^{2} \times (M-2)^{2} = 9 \times 9$ given by \begin{align*} A = @@ -96,65 +94,4 @@ $(M-2)^{2} \times (M-2)^{2} = 9 \times 9$ given by 0 & 0 & 0 & 0 & 0 & r & 0 & r & b_{8} \\ \end{bmatrix} \end{align*} - - -\section{Figures}\label{ap:figures} -We created colormap plots of the real and imaginary part of $u_{\ivec, \jvec}$, -in Figure \ref{fig:colormap_real_imag}. -\begin{figure*} - \centering - \begin{subfigure}[b]{0.3\textwidth} - \centering - \includegraphics[width=\textwidth]{images/color_map_0_real.pdf} - \caption{Re$(u_{\ivec, \jvec})$ at time $t=0$.} - \label{fig:colormap_0_real} - \end{subfigure} - \hfill - \begin{subfigure}[b]{0.3\textwidth} - \centering - \includegraphics[width=\textwidth]{images/color_map_1_real.pdf} - \caption{Re$(u_{\ivec, \jvec})$ at time $t=0.001$.} - \label{fig:colormap_1_real} - \end{subfigure} - \hfill - \begin{subfigure}[b]{0.3\textwidth} - \centering - \includegraphics[width=\textwidth]{images/color_map_2_real.pdf} - \caption{Re$(u_{\ivec, \jvec})$ at time $t=0.002$.} - \label{fig:colormap_2_real} - \end{subfigure} - \newline - \begin{subfigure}[b]{0.3\textwidth} - \centering - \includegraphics[width=\textwidth]{images/color_map_0_imag.pdf} - \caption{Im$(u_{\ivec, \jvec})$ at time $t=0$.} - \label{fig:colormap_0_imag} - \end{subfigure} - \hfill - \begin{subfigure}[b]{0.3\textwidth} - \centering - \includegraphics[width=\textwidth]{images/color_map_1_imag.pdf} - \caption{Im$(u_{\ivec, \jvec})$ at time $t=0.001$.} - \label{fig:colormap_1_imag} - \end{subfigure} - \hfill - \begin{subfigure}[b]{0.3\textwidth} - \centering - \includegraphics[width=\textwidth]{images/color_map_2_imag.pdf} - \caption{Im$(u_{\ivec, \jvec})$ at time $t=0.002$.} - \label{fig:colormap_2_imag} - \end{subfigure} - \caption{The time evolution of Re($u_{\ivec, \jvec}$) and Im($u_{\ivec, \jvec}$), - for time steps $t=[0, 0.001, 0.002]$.} - \label{fig:colormap_real_imag} -\end{figure*} -% \begin{figure*} -% \centering -% \includegraphics[width=0.9\textwidth]{images/color_map_all.pdf} -% \caption{The time evolution of the probability function $p_{\ivec, \jvec}^{n}$ (top row), -% Re($u_{\ivec, \jvec}^{n}$) (middle row), and Im($u_{\ivec, \jvec}^{n}$) (bottom row). -% Time step $t=0$ in the left column, $t=0.001$ in the middle column, and $t=0.002$ -% in the right column.} -% \label{fig:colormap_all} -% \end{figure*} \end{document} diff --git a/latex/sections/conclusion.tex b/latex/sections/conclusion.tex index 4211214..1ed81da 100644 --- a/latex/sections/conclusion.tex +++ b/latex/sections/conclusion.tex @@ -2,23 +2,24 @@ \begin{document} \section{Conclusion}\label{sec:conclusion} -We simulated the two-dimensional time-dependent Schrödinger equation, and studied +% Rewrite this section to differ from the abstract +We have simulated the two-dimensional time-dependent Schrödinger equation, to study variations of the double-slit experiment. To solve the partial differential equations -we applied the Crank-Nicolson scheme in 2+1 dimensions, and derived a discretized -equation. We used Dirichlet boundary conditions to simplify the equation, -expressed the equation in matrix form and solved it using the sparse matrix solver -\verb|superlu|. The total probability $\sum_{\ivec, \jvec} p_{\ivec, \jvec}^{n}$ -deviated from $1.0$ by a factor of $10^{-14}$ for both the single and double slit -setup. % Add something about computational accuracy? +we have applied the Crank-Nicolson scheme in 2+1 dimensions, and derived a discretized +equation. In addition, we have used Dirichlet boundary conditions to express the +equation in matrix form and solve it using the sparse matrix solver \verb|superlu|. +Our implementation, and choice of solver method, resulted in conserved total +probability $\sum_{\ivec, \jvec} p_{\ivec, \jvec}^{n}=1$ for both the single and +double slit setup. -We illustrated the time evolution of the probability function $p_{\ivec, \jvec}^{n} = u_{\ivec, \jvec}^{n*} u_{\ivec, \jvec}^{n}$, -using colormap plots for time steps $t = \{0, 0.001, 0.002\}$. In addition, we included -separate plots for each time step of Re$(u_{\ivec, \jvec})$ and Im$(u_{\ivec, \jvec})$, -to show the components of the complex values. This resulted in visible diffraction -patterns for the double-slit experiment. +To illustrate the time evolution of the probability function $p_{\ivec, \jvec}^{n} = u_{\ivec, \jvec}^{n*} u_{\ivec, \jvec}^{n}$, +we created colormap plots at time steps $t = [0, 0.001, 0.002]$. Since we are working +with complex numbers, we included separate plots for each time step of Re$(u_{\ivec, \jvec})$ +and Im$(u_{\ivec, \jvec})$. +% We observed something... + +In addition, we determined the normalized particle detection probability $p(y \ | \ x=0.8, t=0.002)$, +for single-, double- and triple-slit. +% We observed something here as well... -In addition, we studied the normalized particle detection probability $p(y \ | \ x=0.8, t=0.002)$, -for single-, double- and triple-slit setups. We found that increasing the number of slits -in the barrier, resulted in an increased number of areas of both high and low probability -for particle detection. It also increased the variance of particle detection probability. \end{document} diff --git a/latex/sections/introduction.tex b/latex/sections/introduction.tex index bc58e16..47f43f2 100644 --- a/latex/sections/introduction.tex +++ b/latex/sections/introduction.tex @@ -2,70 +2,42 @@ \begin{document} \section{Introduction}\label{sec:introduction} -% Light: wave particle -The nature of light has long been a subject of interest and discussion. In classical -mechanics, we study the kinematics and dynamics of physical objects, while ignoring -their intrinsic properties for simplicity. Elementary particles, such as photons -and electrons, do not abide by the laws of classical mechanics. A solution was -proposed by Max Planck with the radiation law, which he later derived using Boltzmann's -statistical interpretation of the second law of thermodynamics. Planck's findings -gave rise to the quantum hypothesis, and later Einstein's wave-particle duality \cite{britannica:1998:planck}. - -The particle theory was the leading theory in the beginning of the 1800s, when -Thomas Young demonstrated the interference of light, through his double-slit experiment, -while postulating light as waves \cite{young:1804:double_slit}. The study of -interference of light, and Gustav R. Kirchhoff's study of ideal blackbodies, -showed that light exhibits both wavelike and particle-like characteristics. The -wave-particle duality was later proposed to apply to particles by Louis de Broglie, -which inspired Erwin Schrödinger, who proposed a wave function to describe the quantum -state of particles, resulting in the wave equation. - -We will simulate the time-dependent Schrödinger equation in two dimensions, to -study the light wave interference in the double-slit experiment. In addition, we -will include variations of barriers with single-slit and triple-slits. To solve the equation, -we will apply the Crank-Nicolson method in 2+1 dimensions. - -In Section \ref{sec:methods}, we will present the theoretical background for -this experiment, as well as the methods and tools used in the implementation. -Continuing with Section \ref{sec:results}, we will present our results and -discuss our findings. Lastly, we will conclude our findings in Section \ref{sec:conclusion}. -\end{document} - +The nature of light has long been a subject of interest and discussion. % % Important part of human behavior is observing and understanding our surroundings. % Many big discoveries have been made through observations, verified by mathematical % explanations. Classical physics is based on calculation predicting something we % verify by observation etc. But what happens when we move down to the microscopic % scale, can we still predict the position of a microscopic ball, also called an atom? -% In classical mechanics, we study the kinematics and dynamics of physical objects, -% while ignoring their intrinsic properties for simplicity. Newton's second law can be -% applied to an object to describe its trajectory. It allows us to describe the +In classical mechanics, we study the kinematics and dynamics of physical objects, +while ignoring their intrinsic properties for simplicity. Newton's second law can be +applied to an object to describe its trajectory. % It allows us to describe the % forces acting on an object as well as the motion of the object. We can describe % a planets orbital movement \cite{britannica:2023:kepler}, calculate the ... necessary % to launch satellites into orbit, or simply figure out where a ball is going to land % when you throw it... However, when want to study an object at a microscopic level, % e.g. a single atom, classical mechanics falls short. -% Elementary particles such as electrons, does not abide by the laws of classical mechanics. -% For several years, scientists did not agree on whether light was a particle or a -% wave. Through the study of interference of light, and radiation of ideal blackbodies, -% it has been shown that light has both wavelike and particle-like characteristics. -% This is known as the wave-particle duality, and was showed by Albert Einstein in -% 1905. +Elementary particles such as electrons, does not abide by the laws of classical mechanics. +For several years, scientists did not agree on whether light was a particle or a +wave. Through the study of interference of light, and radiation of ideal blackbodies, +it has been shown that light has both wavelike and particle-like characteristics. +This is known as the wave-particle duality, and was showed by Albert Einstein in +1905. % % Thomas Young studied the interference of light, and found that light to showed % wavelike characteristics \cite{young:1804:double_slit}. This did not agree with % Newtons particle-theory -% Erwin Schrödinger wanted to find a mathematical description of the wave characteristics -% of matter, supporting the wave-particle idea. He postulated a wave function which varies -% with position, where the function squared can be interpreted as the probability -% of finding an electron at a given position. This resulted in the Schrödinger equation, -% a wave eqution of the energy levels for a hydrogen atom. It also shows how a quantum -% state evolves with time \cite[p. 81]{wu:2023:quantum}. +Erwin Schrödinger wanted to find a mathematical description of the wave characteristics +of matter, supporting the wave-particle idea. He postulated a wave function which varies +with position, where the function squared can be interpreted as the probability +of finding an electron at a given position. This resulted in the Schrödinger equation, +a wave eqution of the energy levels for a hydrogen atom. It also shows how a quantum +state evolves with time \cite[p. 81]{wu:2023:quantum}. -% We will simulate the time-dependent Schrödinger equation in two dimensions, to -% study the light wave interference in the double-slit experiment. In addition, we -% will include variations of walls such as single- and triple-slit. To solve the equation, -% we will apply the Crank-Nicolson method in 2+1 dimensions. +We will simulate the time-dependent Schrödinger equation in two dimensions, to +study the light wave interference in the double-slit experiment. In addition, we +will include variations of walls such as single- and triple-slit. To solve the equation, +we will apply the Crank-Nicolson method in 2+1 dimensions. % However, according to the Heisenberg uncertainty principle, we can't find dx and/or % dp = 0. dx = sqrt{Var(x)} "spread in position", dp = hat{\Psi}(p) = sqrt{Var(p)} @@ -83,7 +55,11 @@ discuss our findings. Lastly, we will conclude our findings in Section \ref{sec: % Instead of finding the path of a ball, we find all the possible paths a ball can take. % The world is not one-dimensional, and modelling it require partial diff eqs - +In Section \ref{sec:methods}, we will present the theoretical background for +this experiment, as well as the algorithms and tools used in the implementation. +Continuing with Section \ref{sec:results}, we will present our results and +discuss our findings. Lastly, we will conclude our findings in Section \ref{sec:conclusion}. +\end{document} % crank-nicolson method! % wave equation \ No newline at end of file diff --git a/latex/sections/methods.tex b/latex/sections/methods.tex index 6ec8279..7b81da4 100644 --- a/latex/sections/methods.tex +++ b/latex/sections/methods.tex @@ -3,81 +3,70 @@ \begin{document} \section{Methods}\label{sec:methods} % \subsection{The Schrödinger equation}\label{ssec:schrodinger} % -Erwin Schrödinger wanted to find a mathematical description of the wave characteristics -of matter, which supported the wave-particle idea. He postulated a wave function which varies -with position, where the function squared can be interpreted as the probability -of finding an electron at a given position. This resulted in the Schrödinger equation, -a wave eqution of the energy levels for a hydrogen atom. It also shows how a quantum -state evolves with time \cite[p. 81]{wu:2023:quantum}. The Schrödinger equation -has a general form +% Add something that takes Planck to Schrödinger +% In classical mechanics, we have Newton laws and conservation of energy. In quantum +% mechanics, we have Schrödinger equation. +The Schrödinger equation has a general form \begin{align} i \hbar \frac{\partial}{\partial t} | \Psi \rangle &= \hat{H} | \Psi \rangle \ , \label{eq:schrodinger_general} \end{align} -where $i$ is the imaginary unit, and $\hbar$ is the reduced Planck's constant. $\hat{H}$ is -a Hamiltonian operator, which represents the energy for the system, and $| \Psi \rangle$ +where $i$ is the imaginary number, and $\hbar$ is Plancks constant. $\hat{H}$ is +a Hamiltonian operator, which represent the energy for the system, and $| \Psi \rangle$ is the quantum state. In two-dimensional position space, the quantum state can be expressed using the time-dependent complex-valued wave function $\Psi (x, y, t)$. -Using the Born rule, the square modulus of the wave function is proportional to the -probability density of detecting a particle at position $(x, y)$ at time $t$. The -relation is given by +Using Born rule, the square modulus of the wave function is proportional to the +probability density of finding a particle at position $(x, y)$ at time t. The relation +is given by \begin{align} p(x, y \ | \ t) &= |\Psi(x, y, t)|^{2} = \Psi^{*}(x, y, t) \Psi(x, y, t) \ , \label{eq:born_rule} \end{align} -where $\Psi^{*}$ denotes the complex conjugate of the wave function. When the potential -is time-independent, and the particle is non-relativistic, the Schrödinger equation -can be expressed as +where $\Psi^{*}$ denotes the complex conjugated wave function. +% Add something about kinetic and potential energy, to introduce the potential V +When the potential is time-independent, the Schrödinger equation can be expressed as \begin{align*} i \hbar \frac{\partial}{\partial t} \Psi (x, y, t) &= - \frac{\hbar^{2}}{2m} \bigg( \frac{\partial^{2}}{\partial x^{2}} + \frac{\partial^{2}}{\partial y^{2}} \bigg) \Psi (x, y, t) \\ & \quad + V(x, y, t) \Psi (x, y, t) \numberthis \ . \label{eq:schrodinger_special} \end{align*} -The partial derivatives are expressions of the kinetic energy, and the potental $V$ -encodes the external environment. In this experiment we will only consider the case where -the potential is time-independent, resulting in $V = V(x, y)$. - -When we scale the Schrödinger equation by the dimensionful variables, we are left with -the wave function $u$ and the potential $v$. The dimensionless equation is given by +The partial derivatives (...) gives the kinetic energy, and the potental $V$ is +the external environment. In this experiment we will only consider the case where +the potential is time-independent, resulting in $V = V(x, y)$ +When we scale Schrödinger equation by the dimensionful variables, we are left with +a wave function $u$, potential $v$ and the dimensionless equation \begin{align} i \frac{\partial u}{\partial t} &= - \frac{\partial^{2} u}{\partial x^{2}} - \frac{\partial^{2} u}{\partial y^{2}} + v(x, y) u \ . \label{eq:schrodinger_dimensionless} \end{align} % -As a result of working in position space, the Born rule is given by +This gives us the Born rule \begin{align} - p(x, y \ | \ t) &= |u(x, y, t)|^{2} = u^{*}(x, y, t) u(x, y, t) \ , + 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)$. 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} % -When we evaluate a particle's position, we have to consider partial differential -equations (PDEs). To solve these numerically, we have to discretize Equation \eqref{eq:schrodinger_dimensionless}. -We use the $\theta$-rule \footnote{We can derive Forward Euler using $\theta = 1$, and Backward Euler using $\theta = 0$, in the $\theta$-rule.}, -to combine the forward (explicit) and backward (implicit) finite difference methods. +When we evaluate a particle in position space, we have to consider partial differential +equations (PDE). To solve these numerically, we have to discretize Equation \eqref{eq:schrodinger_dimensionless}. +We use the $\theta$-rule \footnote{Using the $\theta$-rule, we can derive Forward Euler using $\theta = 1$, and Backward Euler using $\theta = 0$}, +to combine the forward (explicit) and backward (implicit) finite difference method. The result is a linear combination of the explicit and implicit scheme, given by \begin{align} \frac{u_{\ivec, \jvec}^{n+1} - u_{\ivec, \jvec}^{n}}{\Delta t} &= \theta F_{\ivec, \jvec}^{n+1} + (1 - \theta) F_{\ivec, \jvec}^{n} \ , \label{eq:theta_rule} \end{align} % where $\theta \in [0, 1]$. -To simplify the notation, and avoid any confusion of the indices with the imaginary unit $i$, +To simplify notation and avoid confusion of indices with the imaginary number $i$, we have used the notation $\ivec, \jvec$ in subscript to indicate the commonly named indices $i, j$ in x- and y-direction. In addition, the superscript $n, n+1$ indicate position in time. -We derive the Crank-Nicolson scheme (CN) by using $\theta = 1/2$, given by +We get the Crank-Nicolson method (CN) when $\theta = 1/2$ gives Crank-Nicolson \begin{align} \frac{u_{\ivec, \jvec}^{n+1} - u_{\ivec, \jvec}^{n}}{\Delta t} &= \frac{1}{2} \bigg[ F_{\ivec, \jvec}^{n+1} + F_{\ivec, \jvec}^{n} \bigg] \ . - \label{eq:crank_nicolson_scheme} + \label{eq:crank_nicolson_method} \end{align} % -Using CN, we derive the discretized Schrödinger equation, given by +Using CN, we derive the discretized Schrödinger equation given by \begin{align*} & u_{\ivec, \jvec}^{n+1} - r \big[ u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1} \big] \\ & - r \big[ u_{\ivec, \jvec+1}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec, \jvec-1}^{n+1} \big] + \frac{i \Delta t}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n+1} \\ @@ -87,35 +76,34 @@ Using CN, we derive the discretized Schrödinger equation, given by \end{align*} % where $r$ is defined as \begin{align*} - r \equiv \frac{i \Delta t}{2 \Delta h^{2}} \ . + r \equiv \frac{i \Delta t}{2 \Delta h^{2}} \end{align*} % -The full derivation of both Equation \eqref{eq:crank_nicolson_scheme} and Equation \eqref{eq:schrodinger_discretized} +The full derivation of both Equation \eqref{eq:crank_nicolson_method} and Equation \eqref{eq:schrodinger_discretized} can be found in Appendix \ref{ap:crank_nicolson}. \subsection{The double-slit experiment}\label{ssec:double_slit} % Thomas Young first performed the double-slit experiment in 1801 to demonstrate the -principle of the interference of light \cite{britannica:2023:young}, while postulating -light as waves rather than particles. The double-slit experiment results in a diffraction +principle of interference of light \cite{britannica:2023:young}, while postulating +light as waves rather than particles. The double-slit experiment result in a diffraction pattern on a detector screen, where constructive interference of light result in -bright spots, and destructive interference result in dark spots. An illustration -of Thomas Young's setup can be found in Figure \ref{fig:youngs_double_slit}. +bright spots, and destructive interference result in dark spots as showed in Figure +\ref{fig:youngs_double_slit}. \begin{figure} \centering \includegraphics[width=\linewidth]{images/youngs_double_slit.pdf} \caption{The setup of Thomas Young's double slit experiment, where $S_{0}$ denotes - the light source, $S_{1}$ and $S_{2}$ denotes the slits in the barrier \cite[p. 4]{mit:2004:physics}.} + the light source, $S_{1}$ and $S_{2}$ denotes the slits in the wall.} \label{fig:youngs_double_slit} \end{figure} -After the wave passes through the barrier, the pattern observed is determined by -the path difference given by -\begin{align} +After the wave passes through the two slits, the pattern observed is determined by +the path difference determined by +\begin{align*} \delta = d \sin (\theta) = m \lambda \ , - \label{eq:interference} -\end{align} +\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 +distance between the center of the two slits, assuming that the distance between the wall and the detector screen $L >> \delta$ \cite[p. 6]{mit:2004:physics}. In this case, we observe constructive interference when \begin{align*} @@ -123,31 +111,23 @@ this case, we observe constructive interference when \end{align*} and destructive interference when \begin{align*} - \delta = (m + \frac{1}{2}) \lambda && m = 0, \pm 1, \pm 2 \dots \ . + \delta = (m + \frac{1}{2}) \lambda && m = 0, \pm 1, \pm 2 \dots \ , \end{align*} + % Something about Heisenberg uncertainty principle - \subsection{Implementation}\label{ssec:implementation} % -In this experiment, we set up the grid with an equal step size in the x- and y-direction $h$, -and step size in the t-direction $\Delta t$, such that -\begin{align*} - x \in [0, 1] && x \rightarrow x_{\ivec} = \ivec h && \ivec = 0, 1, \dots, M-1 \\ - y \in [0, 1] && y \rightarrow y_{\jvec} = \jvec h && \jvec = 0, 1, \dots, M-1 \\ - t \in [0, T] && t \rightarrow t_{n} = n \Delta t && n = 0, 1, \dots, N_{t}-1 \ . -\end{align*} -In addition, we simplify the indices such that -\begin{align*} - u(x, y, t) \rightarrow u(\ivec h, \jvec h, n \Delta t) \equiv u_{\ivec, \jvec}^{n} \\ - v(x, y) \rightarrow u(\ivec h, \jvec h) \equiv v_{\ivec, \jvec} \ , -\end{align*} -which results in a matrix $U^{n}$ that contains elements $u_{\ivec, \jvec}^{n}$, and -a matrix $V$ that contains elements $v_{\ivec, \jvec}$. We used Dirichlet boundary -conditions, given by -\begin{align*} - u(x=0, y, t) &= 0 & u(x=1, y, t) &= 0 \\ - u(x, y=0, t) &= 0 & u(x, y=1, t) &= 0 \ , -\end{align*} +% Add tables of parameters used, initial conditions, notation etc. +A, B are sparse csc matrix +- theory of csc matrix? +% \begin{equation*} +% \begin{pNiceArray}{ccc|ccc} +% \bullet & \bullet & & \bullet & & & & & \\ +% \bullet & \bullet & \bullet & & \bullet & & & & \\ +% & \bullet & \bullet & & & \bullet & & & +% \end{pNiceArray} +% \end{equation*} +We use Dirichlet boundary conditions, as given in Table \ref{tab:boundary_conditions}, which allows us to express Equation \eqref{eq:schrodinger_discretized} as a matrix equation \begin{align} @@ -157,8 +137,8 @@ Here, both $u^{n+1}$ and $u^{n}$ are column vectors containing the internal poin of the $xy$ grid at time step $n+1$ and $n$, respectively. Since we have $M$ points in $x$- and $y$-direction, we have $M-2$ internal points. Both $u$ vectors have length $(M-2)^{2}$, and the matrices $A$ and $B$ have size $(M-2)^{2} \times (M-2)^{2}$. -The matrices are sparse and can be decomposed as submatrices of size $(M-2) \times (M-2)$, -with the following pattern +The matrices can be decomposed as submatrices of size $(M-2) \times (M-2)$, with +the following pattern \begin{align*} A, B = \begin{bmatrix} @@ -215,18 +195,46 @@ with the following pattern \bullet & \bullet & \bullet \\ \phantom{\bullet} & \bullet & \bullet \end{matrix} - \end{bmatrix} \ . + \end{bmatrix} \end{align*} -To fill the matrices $A$ and $B$, we use +To fill the matrices $A$ and $B$, we used \begin{align*} a_{k} &= 1 + 4r + \frac{i \Delta t}{2} v_{\ivec, \jvec} \\ b_{k} &= 1 - 4r - \frac{i \Delta t}{2} v_{\ivec, \jvec} \ . \end{align*} -An example of a pair of filled matrices can be found in Appendix \ref{ap:matrix_structure}. +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}. -% Insert Heisenberg uncertainty here? Or refer to it? +Notations: +In addition, we use an equal step size in x- and y-direction, $h$ such that +\begin{align*} + x \in [0, 1] && x \rightarrow x_{\ivec} = \ivec h && \ivec = 0, 1, \dots, M-1 \\ + y \in [0, 1] && y \rightarrow y_{\jvec} = \jvec h && \jvec = 0, 1, \dots, M-1 \\ + t \in [0, T] && t \rightarrow t_{n} = n \Delta t && n = 0, 1, \dots, N_{t}-1 +\end{align*} +And simplify indices such that +\begin{align*} + u(x, y, t) \rightarrow u(\ivec h, \jvec h, n \Delta t) \equiv u_{\ivec, \jvec}^{n} \\ + v(x, y) \rightarrow u(\ivec h, \jvec h) \equiv v_{\ivec, \jvec} +\end{align*} +which gives a matrix $U^{n}$ that contains elements $u_{\ivec, \jvec}^{n}$, and +a matrix $V$ that contains elements $v_{\ivec, \jvec}$. +\begin{table}[H] + \centering + \begin{tabular}{l r} % @{\extracolsep{\fill}} + \hline + Position & Value \\ + \hline + $u(x=0, y, t)$ & $0$ \\ + $u(x=1, y, t)$ & $0$ \\ + $u(x, y=0, t)$ & $0$ \\ + $u(x, y=1, t)$ & $0$ \\ + \hline + \end{tabular} + \caption{Boundary conditions in the xy-plane, also known as Dirichlet boundary conditions.} + \label{tab:boundary_conditions} +\end{table} + +For the general setup of the wall, we used \begin{table}[H] \centering \begin{tabular}{l r} % @{\extracolsep{\fill}} @@ -239,14 +247,15 @@ and for the simulations, we used the parameter settings in Table \ref{tab:sim_se Slit aperture & $0.05$ \\ \hline \end{tabular} - \caption{Barrier parameters and values.} - \label{tab:barrier_setup} + \caption{Wall setup.} + \label{tab:wall_setup} \end{table} + \begin{table}[H] \centering \begin{tabular}{l r r} % @{\extracolsep{\fill}} \hline - Parameter & Setting 1 & Setting 2 \\ + Simulation & $1$ & $2$ \\ \hline $h$ & $0.005$ & $0.005$ \\ $\Delta t$ & $2.5 \times 10^{-5}$ & $2.5 \times 10^{-5}$ \\ @@ -260,39 +269,12 @@ and for the simulations, we used the parameter settings in Table \ref{tab:sim_se $v_{0}$ & $0$ & $1 \times10^{10}$ \\ \hline \end{tabular} - \caption{Simulation settings used in the double slit experiment. Setting 1 is - applied when the barrier is switched off and setting 2 is applied when the barrier - switched on.} - \label{tab:sim_settings} + \caption{Wall setup.} + \label{tab:sim_setup} \end{table} -To check if the total probability is conserved over time, and that the implementation -was correct, we computed the deviation from $1.0$ given by -\begin{align*} - s^{n} &= |1.0 - \sum_{\ivec , \jvec} p_{\ivec , \jvec}^{n}| \\ - &= |1.0 - \sum_{\ivec , \jvec} u_{\ivec , \jvec}^{n*} u_{\ivec , \jvec}^{n}| \ . -\end{align*} - \subsection{Tools}\label{ssec:tools} % The double-slit experiment is implemented in C++. We use the Python library -\verb|NumPy| \cite{harris:2020:numpy}, \verb|matplotlib| \cite{hunter:2007:matplotlib} to produce all the plots, and +\verb|matplotlib| \cite{hunter:2007:matplotlib} to produce all the plots, and \verb|seaborn| \cite{waskom:2021:seaborn} to set the theme in the figures. \end{document} - - - -% \begin{table}[H] -% \centering -% \begin{tabular}{l r} % @{\extracolsep{\fill}} -% \hline -% Position & Value \\ -% \hline -% $u(x=0, y, t)$ & $0$ \\ -% $u(x=1, y, t)$ & $0$ \\ -% $u(x, y=0, t)$ & $0$ \\ -% $u(x, y=1, t)$ & $0$ \\ -% \hline -% \end{tabular} -% \caption{Boundary conditions in the xy-plane, also known as Dirichlet boundary conditions.} -% \label{tab:boundary_conditions} -% \end{table} \ No newline at end of file diff --git a/latex/sections/results.tex b/latex/sections/results.tex index 13b1388..deeb5ea 100644 --- a/latex/sections/results.tex +++ b/latex/sections/results.tex @@ -4,125 +4,32 @@ \section{Results}\label{sec:results} \subsection{Deviation}\label{ssec:deviation} % Problem 3: Discuss approaches to solve Au^{n+1} = b, dealing with sparse matrix... -We used the \verb|superlu| solver, which is a solver for sparse matrices. It is -generally used to solve nonsymmetric, sparse matrices. However, as the alternative -solver \verb|lapack| converts a sparse matrix to a dense matrix, it will increase -memory usage compared to \verb|superlu|. +We used the superlu solver, which is a dedicated solver for sparse matrices. It is +generally used to solve nonsymmetric, sparse matrices. However, as the lapack solver +converts the sparse matrix to a dense matrix, it will increase memory usage compared +to superlu. % Problem 7: Consequenses of solver choice, in regards to accuracy of probability conserved % Add plot of deviation for both single- and double-slit -Since we used a solver for sparse matrices, we decrease the number of computations performed -compared to the number of computations using a solver for dense matrices. -We checked if the total probability was conserved over time, by plotting the deviation -from $1.0$. +Since we use a solver for sparse matrices, we decrease number of computations performed +compared to solver using dense matrix. We check if the total probability is conserved +over time, by plotting the deviation $s$ as +\begin{align*} + s^{n} = 1 - \sum_{\ivec , \jvec} p_{\ivec , \jvec}^{n} = 1 - \sum_{\ivec , \jvec} u_{\ivec , \jvec}^{n*} u_{\ivec , \jvec}^{n} \ . +\end{align*} +The deviation as a function of time is plotted in Figure \ref{fig:deviation}. \begin{figure} \centering \includegraphics[width=\linewidth]{images/probability_deviation.pdf} - \caption{Deviation of total probability, for time $t \in [0, T]$ where $T=0.008$.} + \caption{Deviation for $t \in [0, T]$ where $T=0.008$.} \label{fig:deviation} \end{figure} -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 can found in Figure \ref{fig:deviation}. When the wave interacts -with the barrier, it results in a larger 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 limitations of the computer, therefore 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 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 -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 results can be found in Appendix \ref{ap:figures}, in Figure \ref{fig:colormap_real_imag}. -\begin{figure} - \centering - \includegraphics[width=\linewidth]{images/color_map_0_prob.pdf} - \caption{The probability function $p_{\ivec, \jvec}^{n}$, at time $t=0$.} - \label{fig:colormap_0_prob} -\end{figure} -\begin{figure} - \centering - \includegraphics[width=\linewidth]{images/color_map_1_prob.pdf} - \caption{The probability function $p_{\ivec, \jvec}^{n}$, at time $t=0.001$.} - \label{fig:colormap_1_prob} -\end{figure} -\begin{figure} - \centering - \includegraphics[width=\linewidth]{images/color_map_2_prob.pdf} - \caption{The probability function $p_{\ivec, \jvec}^{n}$, at time $t=0.002$.} - \label{fig:colormap_2_prob} -\end{figure} -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_real_imag}. 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. - -To compare the probability function $p_{\ivec, \jvec}$ for all the time steps in -a colormap plot, with the real and imaginary part of $u_{\ivec, \jvec}$, we created -Figure \ref{fig:colormap_all}. Where we excluded all x- and y-ticks, and labels, to -better visualize the diffraction pattern. -\begin{figure} - \centering - \includegraphics[width=\linewidth]{images/color_map_all.pdf} - \caption{The time evolution of the probability function $p_{\ivec, \jvec}^{n}$ (top row), - Re($u_{\ivec, \jvec}$) (middle row), and Im($u_{\ivec, \jvec}$) (bottom row). - Time step $t=0$ in the left column, $t=0.001$ in the middle column, and $t=0.002$ - in the right column.} - \label{fig:colormap_all} -\end{figure} - \subsection{Particle detection}\label{ssec:particle_detection} % Problem 9: Plot detection probability for single-, double- and triple-slit -We simulated 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 are 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} - \caption{Probability of particle detection along a detector screen at time $t=0.002$, - when using a single-slit barrier.} - \label{fig:particle_detection_single} -\end{figure} -\begin{figure} - \centering - \includegraphics[width=\linewidth]{images/double_slit_detector.pdf} - \caption{Probability of particle detection along a detector screen at time $t=0.002$, - when using a double-slit barrier.} - \label{fig:particle_detection_double} -\end{figure} -\begin{figure} - \centering - \includegraphics[width=\linewidth]{images/triple_slit_detector.pdf} - \caption{Probability of particle detection along a detector screen at time $t=0.002$, - 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 is both constructive and destructive interference. -When we used a triple-slit barrier, we observed an increase in interference which -resulted in narrow peaks. In addition, the probability of detecting a particle at -the ends of the screen increased with the number of slits. + + \end{document} diff --git a/python_scripts/colormap.py b/python_scripts/colormap.py index ec3720a..f596e15 100644 --- a/python_scripts/colormap.py +++ b/python_scripts/colormap.py @@ -19,7 +19,6 @@ 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]) @@ -39,19 +38,16 @@ 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 @@ -64,26 +60,10 @@ 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", 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") + 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") # Close figures plt.close(fig1) diff --git a/python_scripts/colormap_all.py b/python_scripts/colormap_all.py deleted file mode 100644 index dc9786b..0000000 --- a/python_scripts/colormap_all.py +++ /dev/null @@ -1,62 +0,0 @@ -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, - "xtick.bottom": False, - "xtick.labelbottom": False, - "ytick.left": False, - "ytick.labelleft": False, - "axes.grid": False, - # "figure.autolayout": True - # "figure.constrained_layout.use": False, - # "figure.constrained_layout.h_pad": 0.04167, - # "figure.constrained_layout.w_pad": 0.04167 - # "figure.subplot.wspace": 0, - # "figure.subplot.hspace": 0 -} -plt.rcParams.update(params) - - -def plot(): - fig, axes = plt.subplots(figsize=(6,6), 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:]): - 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 - axes[0, i].imshow( - np.multiply(arr, arr.conj()).real, - interpolation="nearest", - cmap=sns.color_palette("mako", as_cmap=True) - ) - axes[1, i].imshow( - arr.real, - interpolation="nearest", - cmap=sns.color_palette("mako", as_cmap=True) - ) - axes[2, i].imshow( - arr.imag, - interpolation="nearest", - cmap=sns.color_palette("mako", as_cmap=True) - ) - - # Create tight subplots and save figure - fig.subplots_adjust(wspace=0, hspace=0) - fig.savefig(f"latex/images/color_map_all.pdf", bbox_inches="tight") - - -if __name__ == "__main__": - plot() - diff --git a/python_scripts/detector.py b/python_scripts/detector.py index 260933d..7ccea84 100644 --- a/python_scripts/detector.py +++ b/python_scripts/detector.py @@ -27,7 +27,6 @@ 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(); @@ -44,10 +43,8 @@ def plot(): slice *= norm slice = np.asarray([i * i.conjugate() for i in slice]) - 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") + ax.plot(x, slice) + plt.savefig(output) plt.close(fig) diff --git a/python_scripts/deviation.py b/python_scripts/deviation.py index cf50368..fb43137 100644 --- a/python_scripts/deviation.py +++ b/python_scripts/deviation.py @@ -21,17 +21,9 @@ def plot(): "data/probability_deviation_no_slits.txt", "data/probability_deviation_slits.txt", ] - labels = [ - "none", - "double-slit" - ] - colors = sns.color_palette("mako", n_colors=2) - - fig, ax = plt.subplots() - - for file, label, color in zip(files, labels, colors): + for file in files: with open(file) as f: - lines = f.readlines() + lines = f.readlines(); x = [] arr = [] for line in lines: @@ -39,13 +31,10 @@ def plot(): x.append(float(tmp[0])) arr.append(float(tmp[1])) - ax.plot(x, arr, label=label, color=color) - - ax.legend(title="Barrier") - ax.set_xlabel("Time (t)") - ax.set_ylabel("Deviation") - fig.savefig("latex/images/probability_deviation.pdf", bbox_inches="tight") + plt.plot(x,arr) + plt.savefig("latex/images/probability_deviation.pdf") if __name__ == "__main__": - plot() \ No newline at end of file + plot() + diff --git a/python_scripts/plot_v.py b/python_scripts/plot_v.py new file mode 100644 index 0000000..5d5d8b8 --- /dev/null +++ b/python_scripts/plot_v.py @@ -0,0 +1,40 @@ +import numpy as np +import matplotlib.pyplot as plt +import matplotlib +from matplotlib.animation import FuncAnimation +import ast + +import seaborn as sns +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(): + with open("v.txt") as f: + lines = f.readlines(); + size = int(lines[0]) + for line in lines[1:]: + arr = line.strip().split("\t") + arr = np.asarray(list(map(lambda x: ((a := complex(*ast.literal_eval(x)))*a.conjugate()).real, arr))) + + # print(sum(arr)) + arr = arr.reshape(size,size) + # print(arr) + + plt.imshow(arr.T, cmap="hot", interpolation="nearest") + plt.show() + + + + +if __name__ == "__main__": + plot()