Add parameters for python script, edit method, and add result for problem 7.
This commit is contained in:
parent
8b1c6a5dc8
commit
3539655862
@ -99,7 +99,7 @@
|
||||
\subfile{sections/methods}
|
||||
|
||||
% Results
|
||||
% \subfile{sections/results}
|
||||
\subfile{sections/results}
|
||||
|
||||
% Conclusion
|
||||
% \subfile{sections/conclusion}
|
||||
|
||||
@ -34,15 +34,64 @@ Using Equation \eqref{eq:schrodinger_dimensionless}, we get
|
||||
&= -\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}} \\
|
||||
& \quad - \frac{u_{\ivec, \jvec+1}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec, \jvec-1}^{n+1}}{2 \Delta y^{2}} + \frac{1}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n+1} \\
|
||||
& \quad - \frac{u_{\ivec+1, \jvec}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec-1, \jvec}^{n}}{2 \Delta x^{2}} \\
|
||||
& \quad - \frac{u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n}}{2 \Delta y^{2}} + \frac{1}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n} \bigg] \\
|
||||
& \quad - \frac{u_{\ivec, \jvec+1}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec, \jvec-1}^{n}}{2 \Delta y^{2}} + \frac{1}{2} v_{\ivec, \jvec} u_{\ivec, \jvec}^{n} \bigg]
|
||||
\end{align*}
|
||||
We rewrite the expression,
|
||||
We rewrite the expression and gather all terms containing the $n+1$ time step on
|
||||
the left hand side, and the terms containing $n$ time step on the right hand side.
|
||||
\begin{align*}
|
||||
& u_{\ivec, \jvec}^{n+1} - \frac{i \Delta t}{2 \Delta x^{2}} \big[ u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1} \big] \\
|
||||
& - \frac{i \Delta t}{2 \Delta y^{2}} \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} \\
|
||||
&= 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} \\
|
||||
& \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*}
|
||||
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*}
|
||||
and define
|
||||
\begin{align*}
|
||||
r \equiv \frac{i \Delta t}{2 \Delta h^{2}}
|
||||
\end{align*}
|
||||
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} \\
|
||||
&= u_{\ivec, \jvec}^{n} + r \big[ u_{\ivec+1, \jvec}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec-1, \jvec}^{n} \big] \\
|
||||
& \quad + r \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*}
|
||||
|
||||
|
||||
\section{Matrix structure}\label{ap:matrix_structure}
|
||||
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 =
|
||||
\begin{bmatrix}
|
||||
a_{0} & -r & 0 & -r & 0 & 0 & 0 & 0 & 0 \\
|
||||
-r & a_{1} & -r & 0 & -r & 0 & 0 & 0 & 0 \\
|
||||
0 & -r & a_{2} & 0 & 0 & -r & 0 & 0 & 0 \\
|
||||
-r & 0 & 0 & a_{3} & -r & 0 & -r & 0 & 0 \\
|
||||
0 & -r & 0 & -r & a_{4} & -r & 0 & -r & 0 \\
|
||||
0 & 0 & -r & 0 & -r & a_{5} & 0 & 0 & -r \\
|
||||
0 & 0 & 0 & -r & 0 & 0 & a_{6} & -r & 0 \\
|
||||
0 & 0 & 0 & 0 & -r & 0 & -r & a_{7} & -r \\
|
||||
0 & 0 & 0 & 0 & 0 & -r & 0 & -r & a_{8} \\
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
|
||||
\begin{align*}
|
||||
B =
|
||||
\begin{bmatrix}
|
||||
b_{0} & r & 0 & r & 0 & 0 & 0 & 0 & 0 \\
|
||||
r & b_{1} & r & 0 & r & 0 & 0 & 0 & 0 \\
|
||||
0 & r & b_{2} & 0 & 0 & r & 0 & 0 & 0 \\
|
||||
r & 0 & 0 & b_{3} & r & 0 & r & 0 & 0 \\
|
||||
0 & r & 0 & r & b_{4} & r & 0 & r & 0 \\
|
||||
0 & 0 & r & 0 & r & b_{5} & 0 & 0 & r \\
|
||||
0 & 0 & 0 & r & 0 & 0 & b_{6} & r & 0 \\
|
||||
0 & 0 & 0 & 0 & r & 0 & r & b_{7} & r \\
|
||||
0 & 0 & 0 & 0 & 0 & r & 0 & r & b_{8} \\
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\end{document}
|
||||
|
||||
@ -68,11 +68,15 @@ We get the Crank-Nicolson method (CN) when $\theta = 1/2$ gives Crank-Nicolson
|
||||
\end{align} %
|
||||
Using CN, we derive the discretized Schrödinger equation given by
|
||||
\begin{align*}
|
||||
& u_{\ivec, \jvec}^{n+1} - \frac{i \Delta t}{2 \Delta x^{2}} \big[ u_{\ivec+1, \jvec}^{n+1} - 2u_{\ivec, \jvec}^{n+1} + u_{\ivec-1, \jvec}^{n+1} \big] \\
|
||||
& - \frac{i \Delta t}{2 \Delta y^{2}} \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} \\
|
||||
&= 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} \numberthis \ .
|
||||
\label{eq:schrodinger_discretized}
|
||||
& 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} \\
|
||||
&= u_{\ivec, \jvec}^{n} + r \big[ u_{\ivec+1, \jvec}^{n} - 2u_{\ivec, \jvec}^{n} + u_{\ivec-1, \jvec}^{n} \big] \\
|
||||
& \quad + r \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} \numberthis \ ,
|
||||
\label{eq:schrodinger_discretized}
|
||||
\end{align*} %
|
||||
where $r$ is defined as
|
||||
\begin{align*}
|
||||
r \equiv \frac{i \Delta t}{2 \Delta h^{2}}
|
||||
\end{align*} %
|
||||
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}.
|
||||
@ -97,8 +101,20 @@ A, B are sparse csc matrix
|
||||
% & \bullet & \bullet & & & \bullet & & &
|
||||
% \end{pNiceArray}
|
||||
% \end{equation*}
|
||||
|
||||
\begin{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}
|
||||
A u^{n+1} = B u^{n} \ .
|
||||
\end{align}
|
||||
Here, both $u^{n+1}$ and $u^{n}$ are column vectors containing the internal points
|
||||
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 can be decomposed as submatrices of size $(M-2) \times (M-2)$, with
|
||||
the following pattern
|
||||
\begin{align*}
|
||||
A, B =
|
||||
\begin{bmatrix}
|
||||
\begin{matrix}
|
||||
\bullet & \bullet & \phantom{\bullet} \\
|
||||
@ -154,7 +170,13 @@ A, B are sparse csc matrix
|
||||
\phantom{\bullet} & \bullet & \bullet
|
||||
\end{matrix}
|
||||
\end{bmatrix}
|
||||
\end{equation*}
|
||||
\end{align*}
|
||||
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 filled matrices can be found in Appendix \ref{ap:matrix_structure}.
|
||||
|
||||
Notations:
|
||||
In addition, we use an equal step size in x- and y-direction, $h$ such that
|
||||
@ -172,7 +194,7 @@ 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 l l} % @{\extracolsep{\fill}}
|
||||
\begin{tabular}{l r} % @{\extracolsep{\fill}}
|
||||
\hline
|
||||
Position & Value \\
|
||||
\hline
|
||||
@ -189,7 +211,7 @@ a matrix $V$ that contains elements $v_{\ivec, \jvec}$.
|
||||
For the general setup of the wall, we used
|
||||
\begin{table}[H]
|
||||
\centering
|
||||
\begin{tabular}{l l} % @{\extracolsep{\fill}}
|
||||
\begin{tabular}{l r} % @{\extracolsep{\fill}}
|
||||
\hline
|
||||
Parameter & Value \\
|
||||
\hline
|
||||
@ -205,7 +227,7 @@ For the general setup of the wall, we used
|
||||
|
||||
\begin{table}[H]
|
||||
\centering
|
||||
\begin{tabular}{l l l} % @{\extracolsep{\fill}}
|
||||
\begin{tabular}{l r r} % @{\extracolsep{\fill}}
|
||||
\hline
|
||||
Simulation & $1$ & $2$ \\
|
||||
\hline
|
||||
|
||||
@ -4,8 +4,25 @@
|
||||
\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 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 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 for $t \in [0, T]$ where $T=0.008$.}
|
||||
\label{fig:deviation}
|
||||
\end{figure}
|
||||
|
||||
\subsection{Time evolution}\label{ssec:time_evolution}
|
||||
% Problem 8: Colormap, include plot of both Re and Im for different time steps
|
||||
|
||||
@ -4,6 +4,17 @@ import ast
|
||||
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():
|
||||
with open("data/color_map.txt") as f:
|
||||
|
||||
@ -4,6 +4,17 @@ import ast
|
||||
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():
|
||||
files = [
|
||||
|
||||
@ -4,6 +4,19 @@ 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)
|
||||
|
||||
wave_arr = []
|
||||
fig = plt.figure()
|
||||
ax = plt.gca()
|
||||
|
||||
@ -4,6 +4,19 @@ 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("data/probability_deviation.txt") as f:
|
||||
lines = f.readlines();
|
||||
@ -16,6 +29,7 @@ def plot():
|
||||
arr_narrow.append(float(tmp[1]))
|
||||
arr_wide.append(float(tmp[2]))
|
||||
|
||||
|
||||
plt.plot(x,arr_narrow)
|
||||
plt.plot(x,arr_wide)
|
||||
plt.savefig("latex/images/probability_deviation.pdf")
|
||||
|
||||
@ -4,6 +4,19 @@ 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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user